summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@ocrete.ca>2022-08-18 09:22:02 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2022-10-17 11:11:14 +0200
commitfbd8b4a052005e10e60a4ae4bb79423e01cdcd37 (patch)
treeb0a88b5500d3e637758403e145bdf77ba7dfbe01
parent3f3b9d158788760a1a5d9f57e1aef6037894cdd9 (diff)
downloadlibnice-fbd8b4a052005e10e60a4ae4bb79423e01cdcd37.tar.gz
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.
-rw-r--r--agent/agent.h8
-rw-r--r--agent/conncheck.c20
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;
}