diff options
Diffstat (limited to 'agent')
-rw-r--r-- | agent/agent.h | 8 | ||||
-rw-r--r-- | agent/conncheck.c | 20 |
2 files changed, 18 insertions, 10 deletions
diff --git a/agent/agent.h b/agent/agent.h index 1d36a76..1746b62 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -260,9 +260,11 @@ GType nice_agent_get_type (void); /** * NICE_AGENT_MAX_REMOTE_CANDIDATES: * - * A hard limit for the number of remote candidates. This - * limit is enforced to protect against malevolent remote - * clients. + * Was a limit on the number of remote candidates one can set, but is + * no longer used by libnice itself. + * + * Deprecated: 0.1.20: Replace with dynamic value based on the + * #NiceAgent::max-connectivity-checks property */ #define NICE_AGENT_MAX_REMOTE_CANDIDATES 25 diff --git a/agent/conncheck.c b/agent/conncheck.c index a8bc679..a67e291 100644 --- a/agent/conncheck.c +++ b/agent/conncheck.c @@ -3316,16 +3316,11 @@ static IncomingCheck *priv_store_pending_check (NiceAgent *agent, NiceComponent uint16_t username_len, uint32_t priority, gboolean use_candidate) { IncomingCheck *icheck = NULL; - nice_debug ("Agent %p : Storing pending check.", agent); + guint max_incoming_checks = agent->max_conn_checks * 2; - if (g_queue_get_length (&component->incoming_checks) >= - NICE_AGENT_MAX_REMOTE_CANDIDATES) { - nice_debug ("Agent %p : WARN: unable to store information for early incoming check.", agent); - return icheck; - } + nice_debug ("Agent %p : Storing pending check.", agent); icheck = g_slice_new0 (IncomingCheck); - g_queue_push_tail (&component->incoming_checks, icheck); icheck->from = *from; icheck->local_socket = sockptr; icheck->priority = priority; @@ -3334,6 +3329,17 @@ static IncomingCheck *priv_store_pending_check (NiceAgent *agent, NiceComponent icheck->username = NULL; if (username_len > 0) icheck->username = g_memdup (username, username_len); + g_queue_push_tail (&component->incoming_checks, icheck); + + if (g_queue_get_length (&component->incoming_checks) >= max_incoming_checks) { + IncomingCheck *old_icheck = g_queue_pop_head (&component->incoming_checks); + + g_free (old_icheck->username); + g_slice_free (IncomingCheck, old_icheck); + + nice_debug ("Agent %p : WARN: Over %d early checks, dropping the oldest", + agent, max_incoming_checks); + } return icheck; } |