Commit fbd8b4a0 authored by Olivier Crête's avatar Olivier Crête Committed by Olivier Crête

conncheck: Limit ichecks based on property

Limit the number of stored incoming checks based on the property
limiting the number of total connectivity checks instead of using
the fixed limit on the number of remote candidates.
parent 3f3b9d15
...@@ -260,9 +260,11 @@ GType nice_agent_get_type (void); ...@@ -260,9 +260,11 @@ GType nice_agent_get_type (void);
/** /**
* NICE_AGENT_MAX_REMOTE_CANDIDATES: * NICE_AGENT_MAX_REMOTE_CANDIDATES:
* *
* A hard limit for the number of remote candidates. This * Was a limit on the number of remote candidates one can set, but is
* limit is enforced to protect against malevolent remote * no longer used by libnice itself.
* clients. *
* Deprecated: 0.1.20: Replace with dynamic value based on the
* #NiceAgent::max-connectivity-checks property
*/ */
#define NICE_AGENT_MAX_REMOTE_CANDIDATES 25 #define NICE_AGENT_MAX_REMOTE_CANDIDATES 25
......
...@@ -3316,16 +3316,11 @@ static IncomingCheck *priv_store_pending_check (NiceAgent *agent, NiceComponent ...@@ -3316,16 +3316,11 @@ static IncomingCheck *priv_store_pending_check (NiceAgent *agent, NiceComponent
uint16_t username_len, uint32_t priority, gboolean use_candidate) uint16_t username_len, uint32_t priority, gboolean use_candidate)
{ {
IncomingCheck *icheck = NULL; 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_debug ("Agent %p : Storing pending check.", agent);
NICE_AGENT_MAX_REMOTE_CANDIDATES) {
nice_debug ("Agent %p : WARN: unable to store information for early incoming check.", agent);
return icheck;
}
icheck = g_slice_new0 (IncomingCheck); icheck = g_slice_new0 (IncomingCheck);
g_queue_push_tail (&component->incoming_checks, icheck);
icheck->from = *from; icheck->from = *from;
icheck->local_socket = sockptr; icheck->local_socket = sockptr;
icheck->priority = priority; icheck->priority = priority;
...@@ -3334,6 +3329,17 @@ static IncomingCheck *priv_store_pending_check (NiceAgent *agent, NiceComponent ...@@ -3334,6 +3329,17 @@ static IncomingCheck *priv_store_pending_check (NiceAgent *agent, NiceComponent
icheck->username = NULL; icheck->username = NULL;
if (username_len > 0) if (username_len > 0)
icheck->username = g_memdup (username, username_len); 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; return icheck;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment