summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Bellet <fabrice@bellet.info>2020-10-23 17:38:53 +0200
committerOlivier CrĂȘte <olivier.crete@ocrete.ca>2021-11-02 20:35:09 +0000
commitc95350259a18af5e9d1c0ceffdb28f66c9663557 (patch)
treedd9cf3e8eae92eb11f7ce5e6deb291f860be1a65
parent8071d074c14a54562d9b06797bb6ca16ab23898a (diff)
conncheck: schedule the connection check in most relevant places
The patch invokes the conncheck timer creation where it makes most sense: when a new pair is inserted in the conncheck list, and when a pair is added to the triggered check list (because the conncheck scheduler works on these two lists).
-rw-r--r--agent/agent.c5
-rw-r--r--agent/conncheck.c19
-rw-r--r--agent/conncheck.h1
3 files changed, 10 insertions, 15 deletions
diff --git a/agent/agent.c b/agent/agent.c
index f57f980..6745bee 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -3957,7 +3957,6 @@ nice_agent_set_remote_credentials (
g_strlcpy (stream->remote_password, pwd, NICE_STREAM_MAX_PWD);
conn_check_remote_credentials_set(agent, stream);
- conn_check_schedule_next (agent);
ret = TRUE;
goto done;
@@ -4061,10 +4060,8 @@ _set_remote_candidates_locked (NiceAgent *agent, NiceStream *stream,
}
}
- if (added > 0) {
+ if (added > 0)
conn_check_remote_candidates_set(agent, stream, component);
- conn_check_schedule_next (agent);
- }
return added;
}
diff --git a/agent/conncheck.c b/agent/conncheck.c
index 98f36e1..53faba3 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -80,6 +80,7 @@ static CandidateCheckPair *priv_conn_check_add_for_candidate_pair_matched (
NiceCandidate *local, NiceCandidate *remote, NiceCheckState initial_state);
static gboolean priv_conn_keepalive_tick_agent_locked (NiceAgent *agent,
gpointer pointer);
+static void priv_schedule_next (NiceAgent *agent);
static gint64 priv_timer_remainder (gint64 timer, gint64 now)
{
@@ -303,8 +304,10 @@ priv_add_pair_to_triggered_check_queue (NiceAgent *agent, CandidateCheckPair *pa
g_assert (pair);
if (agent->triggered_check_queue == NULL ||
- g_slist_find (agent->triggered_check_queue, pair) == NULL)
+ g_slist_find (agent->triggered_check_queue, pair) == NULL) {
agent->triggered_check_queue = g_slist_append (agent->triggered_check_queue, pair);
+ priv_schedule_next (agent);
+ }
}
/* Remove the pair from the triggered checks list
@@ -1743,7 +1746,7 @@ static gboolean priv_turn_allocate_refresh_tick_agent_locked (NiceAgent *agent,
/*
* Initiates the next pending connectivity check.
*/
-void conn_check_schedule_next (NiceAgent *agent)
+static void priv_schedule_next (NiceAgent *agent)
{
if (agent->discovery_unsched_items > 0)
nice_debug ("Agent %p : WARN: starting conn checks before local candidate gathering is finished.", agent);
@@ -2363,6 +2366,8 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
stream->conncheck_list = g_slist_insert_sorted (stream->conncheck_list, pair,
(GCompareFunc)conn_check_compare);
+ priv_schedule_next (agent);
+
nice_debug ("Agent %p : added a new pair %p with foundation '%s' and "
"transport %s:%s to stream %u component %u",
agent, pair, pair->foundation,
@@ -3141,20 +3146,17 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, NiceStream *str
/* If the component for this pair is in failed state, move it
* back to connecting, and reinitiate the timers
*/
- if (component->state == NICE_COMPONENT_STATE_FAILED) {
+ if (component->state == NICE_COMPONENT_STATE_FAILED)
agent_signal_component_state_change (agent, stream->id,
component->id, NICE_COMPONENT_STATE_CONNECTING);
- conn_check_schedule_next (agent);
/* If the component if in ready state, move it back to
* connected as this failed pair with a higher priority
* than the nominated pair requires to pursue the
* conncheck
*/
- } else if (component->state == NICE_COMPONENT_STATE_READY) {
+ else if (component->state == NICE_COMPONENT_STATE_READY)
agent_signal_component_state_change (agent, stream->id,
component->id, NICE_COMPONENT_STATE_CONNECTED);
- conn_check_schedule_next (agent);
- }
}
break;
case NICE_CHECK_SUCCEEDED:
@@ -4109,9 +4111,6 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
resp);
}
priv_add_new_turn_refresh (agent, d, relay_cand, lifetime);
-
- /* In case a new candidate has been added */
- conn_check_schedule_next (agent);
}
d->stun_message.buffer = NULL;
diff --git a/agent/conncheck.h b/agent/conncheck.h
index 358ad28..7525df7 100644
--- a/agent/conncheck.h
+++ b/agent/conncheck.h
@@ -111,7 +111,6 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, NiceCompone
int conn_check_add_for_local_candidate (NiceAgent *agent, guint stream_id, NiceComponent *component, NiceCandidate *local);
gboolean conn_check_add_for_candidate_pair (NiceAgent *agent, guint stream_id, NiceComponent *component, NiceCandidate *local, NiceCandidate *remote);
void conn_check_free (NiceAgent *agent);
-void conn_check_schedule_next (NiceAgent *agent);
int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair);
void conn_check_prune_stream (NiceAgent *agent, NiceStream *stream);
gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceSocket *udp_socket, const NiceAddress *from, gchar *buf, guint len);