Commit c9535025 authored by Fabrice Bellet's avatar Fabrice Bellet Committed by Olivier Crête

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).
parent 8071d074
...@@ -3957,7 +3957,6 @@ nice_agent_set_remote_credentials ( ...@@ -3957,7 +3957,6 @@ nice_agent_set_remote_credentials (
g_strlcpy (stream->remote_password, pwd, NICE_STREAM_MAX_PWD); g_strlcpy (stream->remote_password, pwd, NICE_STREAM_MAX_PWD);
conn_check_remote_credentials_set(agent, stream); conn_check_remote_credentials_set(agent, stream);
conn_check_schedule_next (agent);
ret = TRUE; ret = TRUE;
goto done; goto done;
...@@ -4061,10 +4060,8 @@ _set_remote_candidates_locked (NiceAgent *agent, NiceStream *stream, ...@@ -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_remote_candidates_set(agent, stream, component);
conn_check_schedule_next (agent);
}
return added; return added;
} }
......
...@@ -80,6 +80,7 @@ static CandidateCheckPair *priv_conn_check_add_for_candidate_pair_matched ( ...@@ -80,6 +80,7 @@ static CandidateCheckPair *priv_conn_check_add_for_candidate_pair_matched (
NiceCandidate *local, NiceCandidate *remote, NiceCheckState initial_state); NiceCandidate *local, NiceCandidate *remote, NiceCheckState initial_state);
static gboolean priv_conn_keepalive_tick_agent_locked (NiceAgent *agent, static gboolean priv_conn_keepalive_tick_agent_locked (NiceAgent *agent,
gpointer pointer); gpointer pointer);
static void priv_schedule_next (NiceAgent *agent);
static gint64 priv_timer_remainder (gint64 timer, gint64 now) static gint64 priv_timer_remainder (gint64 timer, gint64 now)
{ {
...@@ -303,8 +304,10 @@ priv_add_pair_to_triggered_check_queue (NiceAgent *agent, CandidateCheckPair *pa ...@@ -303,8 +304,10 @@ priv_add_pair_to_triggered_check_queue (NiceAgent *agent, CandidateCheckPair *pa
g_assert (pair); g_assert (pair);
if (agent->triggered_check_queue == NULL || 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); agent->triggered_check_queue = g_slist_append (agent->triggered_check_queue, pair);
priv_schedule_next (agent);
}
} }
/* Remove the pair from the triggered checks list /* Remove the pair from the triggered checks list
...@@ -1743,7 +1746,7 @@ static gboolean priv_turn_allocate_refresh_tick_agent_locked (NiceAgent *agent, ...@@ -1743,7 +1746,7 @@ static gboolean priv_turn_allocate_refresh_tick_agent_locked (NiceAgent *agent,
/* /*
* Initiates the next pending connectivity check. * 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) if (agent->discovery_unsched_items > 0)
nice_debug ("Agent %p : WARN: starting conn checks before local candidate gathering is finished.", agent); 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, ...@@ -2363,6 +2366,8 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
stream->conncheck_list = g_slist_insert_sorted (stream->conncheck_list, pair, stream->conncheck_list = g_slist_insert_sorted (stream->conncheck_list, pair,
(GCompareFunc)conn_check_compare); (GCompareFunc)conn_check_compare);
priv_schedule_next (agent);
nice_debug ("Agent %p : added a new pair %p with foundation '%s' and " nice_debug ("Agent %p : added a new pair %p with foundation '%s' and "
"transport %s:%s to stream %u component %u", "transport %s:%s to stream %u component %u",
agent, pair, pair->foundation, agent, pair, pair->foundation,
...@@ -3141,20 +3146,17 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, NiceStream *str ...@@ -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 /* If the component for this pair is in failed state, move it
* back to connecting, and reinitiate the timers * 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, agent_signal_component_state_change (agent, stream->id,
component->id, NICE_COMPONENT_STATE_CONNECTING); component->id, NICE_COMPONENT_STATE_CONNECTING);
conn_check_schedule_next (agent);
/* If the component if in ready state, move it back to /* If the component if in ready state, move it back to
* connected as this failed pair with a higher priority * connected as this failed pair with a higher priority
* than the nominated pair requires to pursue the * than the nominated pair requires to pursue the
* conncheck * 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, agent_signal_component_state_change (agent, stream->id,
component->id, NICE_COMPONENT_STATE_CONNECTED); component->id, NICE_COMPONENT_STATE_CONNECTED);
conn_check_schedule_next (agent);
}
} }
break; break;
case NICE_CHECK_SUCCEEDED: case NICE_CHECK_SUCCEEDED:
...@@ -4109,9 +4111,6 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage * ...@@ -4109,9 +4111,6 @@ static gboolean priv_map_reply_to_relay_request (NiceAgent *agent, StunMessage *
resp); resp);
} }
priv_add_new_turn_refresh (agent, d, relay_cand, lifetime); 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; d->stun_message.buffer = NULL;
......
...@@ -111,7 +111,6 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, NiceCompone ...@@ -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); 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); 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_free (NiceAgent *agent);
void conn_check_schedule_next (NiceAgent *agent);
int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair); int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair);
void conn_check_prune_stream (NiceAgent *agent, NiceStream *stream); 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); gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream, NiceComponent *component, NiceSocket *udp_socket, const NiceAddress *from, gchar *buf, guint len);
......
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