Commit 0176c2fa authored by Fabrice Bellet's avatar Fabrice Bellet
Browse files

conncheck: make the stopping criterion a bit more clear

This patch doesn't change the logic of the selection of the pair for
nomination, it makes the code a bit more simple to read.
parent acda4a08
...@@ -935,7 +935,6 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -935,7 +935,6 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
guint s_succeeded = 0; guint s_succeeded = 0;
guint s_discovered = 0; guint s_discovered = 0;
guint s_nominated = 0; guint s_nominated = 0;
guint s_selected_for_nomination = 0;
guint s_waiting_for_nomination = 0; guint s_waiting_for_nomination = 0;
guint s_valid = 0; guint s_valid = 0;
guint s_frozen = 0; guint s_frozen = 0;
...@@ -961,7 +960,6 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -961,7 +960,6 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
break; break;
} }
/* we compute some stream-wide counter values */ /* we compute some stream-wide counter values */
for (i = stream->conncheck_list; i ; i = i->next) { for (i = stream->conncheck_list; i ; i = i->next) {
CandidateCheckPair *p = i->data; CandidateCheckPair *p = i->data;
...@@ -977,8 +975,6 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -977,8 +975,6 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
s_discovered++; s_discovered++;
if (p->valid) if (p->valid)
s_valid++; s_valid++;
if (p->use_candidate_on_next_check)
s_selected_for_nomination++;
if ((p->state == NICE_CHECK_SUCCEEDED || p->state == NICE_CHECK_DISCOVERED) if ((p->state == NICE_CHECK_SUCCEEDED || p->state == NICE_CHECK_DISCOVERED)
&& p->nominated) && p->nominated)
...@@ -1013,10 +1009,14 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -1013,10 +1009,14 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
NiceComponent *component = i->data; NiceComponent *component = i->data;
CandidateCheckPair *other_component_pair = NULL; CandidateCheckPair *other_component_pair = NULL;
CandidateCheckPair *this_component_pair = NULL; CandidateCheckPair *this_component_pair = NULL;
NiceCandidate *lcand1 = NULL;
NiceCandidate *rcand1 = NULL;
NiceCandidate *lcand2, *rcand2;
gboolean already_done = FALSE; gboolean already_done = FALSE;
gboolean use_other_component = FALSE; gboolean found_other_component_pair = FALSE;
gboolean use_other_stream = FALSE; gboolean found_other_stream_pair = FALSE;
const gchar *stopping_criterion = NULL; gboolean first_nomination = FALSE;
gboolean stopping_criterion;
/* p_xxx counters are component-wide */ /* p_xxx counters are component-wide */
guint p_valid = 0; guint p_valid = 0;
guint p_frozen = 0; guint p_frozen = 0;
...@@ -1064,6 +1064,9 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -1064,6 +1064,9 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
} }
} }
if (other_stream_pair == NULL && other_component_pair == NULL)
first_nomination = TRUE;
/* We choose a pair to be nominated in the list of valid /* We choose a pair to be nominated in the list of valid
* pairs. * pairs.
* *
...@@ -1100,41 +1103,45 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -1100,41 +1103,45 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
/* highest priority pair */ /* highest priority pair */
this_component_pair = p; this_component_pair = p;
if (other_component_pair == NULL && lcand1 = p->local;
other_stream_pair == NULL) { rcand1 = p->remote;
if (first_nomination)
/* use the highest priority pair */ /* use the highest priority pair */
break; break;
}
if (other_component_pair) {
lcand2 = other_component_pair->local;
rcand2 = other_component_pair->remote;
}
if (other_component_pair && if (other_component_pair &&
p->local->transport == lcand1->transport == lcand2->transport &&
other_component_pair->local->transport && nice_address_equal_no_port (&lcand1->addr, &lcand2->addr) &&
nice_address_equal_no_port (&p->local->addr, nice_address_equal_no_port (&rcand1->addr, &rcand2->addr)) {
&other_component_pair->local->addr) &&
nice_address_equal_no_port (&p->remote->addr,
&other_component_pair->remote->addr)) {
/* else continue the research with lower priority /* else continue the research with lower priority
* pairs, compatible with a nominated pair of * pairs, compatible with a nominated pair of
* another component * another component
*/ */
this_component_pair = p; this_component_pair = p;
use_other_component = TRUE; found_other_component_pair = TRUE;
break; break;
} }
if (other_component_pair == NULL && if (other_stream_pair) {
p->local->transport == lcand2 = other_stream_pair->local;
other_stream_pair->local->transport && rcand2 = other_stream_pair->remote;
nice_address_equal_no_port (&p->local->addr, }
&other_stream_pair->local->addr) && if (other_stream_pair &&
nice_address_equal_no_port (&p->remote->addr, other_component_pair == NULL &&
&other_stream_pair->remote->addr)) { lcand1->transport == lcand2->transport &&
nice_address_equal_no_port (&lcand1->addr, &lcand2->addr) &&
nice_address_equal_no_port (&rcand1->addr, &rcand2->addr)) {
/* else continue the research with lower priority /* else continue the research with lower priority
* pairs, compatible with a nominated pair of * pairs, compatible with a nominated pair of
* another stream * another stream
*/ */
this_component_pair = p; this_component_pair = p;
use_other_stream = TRUE; found_other_stream_pair = TRUE;
break; break;
} }
} }
...@@ -1145,7 +1152,7 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -1145,7 +1152,7 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
continue; continue;
/* The stopping criterion tries to select a set of pairs of /* The stopping criterion tries to select a set of pairs of
* the same kind (transport/type) for all components of the * the same kind (transport/type) for all components of a
* stream, and for all streams, when possible (see last * stream, and for all streams, when possible (see last
* paragraph). * paragraph).
* *
...@@ -1157,13 +1164,13 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -1157,13 +1164,13 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
* - or stop if the conncheck cannot evolve more * - or stop if the conncheck cannot evolve more
* *
* Else when the stream has a nominated pair in another * Else when the stream has a nominated pair in another
* component we apply the stopping criterion : * component we apply this criterion:
* - stop if we have a valid pair of the same kind than the * - stop if we have a valid pair of the same kind than this
* other nominated pair. * other nominated pair.
* - or stop if the conncheck cannot evolve more * - or stop if the conncheck cannot evolve more
* *
* Else when another stream has a nominated pair we apply the * Else when another stream has a nominated pair we apply the
* following criterion * following criterion:
* - stop if we have a valid pair of the same kind than the * - stop if we have a valid pair of the same kind than the
* other nominated pair. * other nominated pair.
* - or stop if the conncheck cannot evolve more * - or stop if the conncheck cannot evolve more
...@@ -1174,26 +1181,32 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -1174,26 +1181,32 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
* component. We think it's still a better choice than marking * component. We think it's still a better choice than marking
* this component 'failed'. * this component 'failed'.
*/ */
if (other_stream_pair == NULL && stopping_criterion = FALSE;
other_component_pair == NULL && if (first_nomination && p_host_host_valid > 0) {
p_host_host_valid > 0) stopping_criterion = TRUE;
stopping_criterion = "valid host:host pair"; nice_debug ("Agent %p : stopping criterion: "
else if (other_stream_pair == NULL && "valid host-host pair", agent);
other_component_pair == NULL && } else if (first_nomination &&
p_valid >= NICE_MIN_NUMBER_OF_VALID_PAIRS) p_valid >= NICE_MIN_NUMBER_OF_VALID_PAIRS) {
stopping_criterion = "*some* valid pairs"; stopping_criterion = TRUE;
else if (use_other_component) nice_debug ("Agent %p : stopping criterion: "
stopping_criterion = "pair compatible with another component"; "*some* valid pairs", agent);
else if (use_other_stream) } else if (found_other_component_pair) {
stopping_criterion = "pair compatible with another stream"; stopping_criterion = TRUE;
else if (p_waiting == 0 && p_inprogress == 0 && p_frozen == 0) nice_debug ("Agent %p : stopping criterion: "
stopping_criterion = "no more pairs to check"; "matching pair in another component", agent);
} else if (found_other_stream_pair) {
if (stopping_criterion == NULL) stopping_criterion = TRUE;
continue; nice_debug ("Agent %p : stopping criterion: "
"matching pair in another stream", agent);
} else if (p_waiting == 0 && p_inprogress == 0 && p_frozen == 0) {
stopping_criterion = TRUE;
nice_debug ("Agent %p : stopping criterion: "
"no more pairs to check", agent);
}
nice_debug ("Agent %p : stopping criterion: %s", if (!stopping_criterion)
agent, stopping_criterion); continue;
/* when the stopping criterion is reached, we add the /* when the stopping criterion is reached, we add the
* selected pair for this component to the triggered checks * selected pair for this component to the triggered checks
...@@ -1202,10 +1215,8 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) ...@@ -1202,10 +1215,8 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent)
nice_debug ("Agent %p : restarting check of %s:%s pair %p with " nice_debug ("Agent %p : restarting check of %s:%s pair %p with "
"USE-CANDIDATE attrib (regular nomination) for " "USE-CANDIDATE attrib (regular nomination) for "
"stream %d component %d", agent, "stream %d component %d", agent,
priv_candidate_transport_to_string priv_candidate_transport_to_string (lcand1->transport),
(this_component_pair->local->transport), priv_candidate_transport_to_string (rcand1->transport),
priv_candidate_transport_to_string
(this_component_pair->remote->transport),
this_component_pair, stream->id, component->id); this_component_pair, stream->id, component->id);
this_component_pair->use_candidate_on_next_check = TRUE; this_component_pair->use_candidate_on_next_check = TRUE;
priv_add_pair_to_triggered_check_queue (agent, this_component_pair); priv_add_pair_to_triggered_check_queue (agent, this_component_pair);
......
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