Commit 8ac6682c authored by Youness Alaoui's avatar Youness Alaoui

Make sure that candidate pairs are created correctly when the remote...

Make sure that candidate pairs are created correctly when the remote candidates were added before the local candidates were gathered. This is a threading race condition fix.
parent 8d48664b
......@@ -106,6 +106,7 @@ agent_find_component (
Stream *agent_find_stream (NiceAgent *agent, guint stream_id);
void agent_gathering_done (NiceAgent *agent);
void agent_signal_gathering_done (NiceAgent *agent);
void agent_signal_new_selected_pair (
......
......@@ -554,6 +554,39 @@ nice_agent_set_property (
}
void agent_gathering_done (NiceAgent *agent)
{
GSList *i, *j, *k, *l, *m;
for (i = agent->streams; i; i = i->next) {
Stream *stream = i->data;
for (j = stream->components; j; j = j->next) {
Component *component = j->data;
for (k = component->local_candidates; k; k = k->next) {
NiceCandidate *local_candidate = k->data;
for (l = component->remote_candidates; l; l = l->next) {
NiceCandidate *remote_candidate = l->data;
for (m = stream->conncheck_list; m; m = m->next) {
CandidateCheckPair *p = m->data;
if (p->local == local_candidate && p->remote == remote_candidate)
break;
}
if (m == NULL) {
conn_check_add_for_candidate (agent, stream->id, component, remote_candidate);
}
}
}
}
}
agent_signal_gathering_done (agent);
}
void agent_signal_gathering_done (NiceAgent *agent)
{
g_mutex_unlock (agent->mutex);
......@@ -781,9 +814,9 @@ nice_agent_gather_candidates (
/* note: no async discoveries pending, signal that we are ready */
if (agent->discovery_unsched_items == 0)
agent_signal_gathering_done (agent);
else {
if (agent->discovery_unsched_items == 0) {
agent_gathering_done (agent);
} else {
g_assert (agent->discovery_list);
discovery_schedule (agent);
}
......
......@@ -130,6 +130,7 @@ static gboolean priv_conn_check_unfreeze_next (NiceAgent *agent)
Stream *stream = i->data;
guint64 max_frozen_priority = 0;
for (j = stream->conncheck_list; j ; j = j->next) {
CandidateCheckPair *p = j->data;
......
......@@ -562,7 +562,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
discovery_free (agent);
agent_signal_gathering_done (agent);
agent_gathering_done (agent);
/* note: no pending timers, return FALSE to stop timer */
return FALSE;
......
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