Commit 532ccbbd authored by Olivier Crête's avatar Olivier Crête

conncheck: Separate valid and succeded states

RFC 5245 specifies that when a mapped-address differs from the address
from the request was sent, the mapped-address is used to select the
valid pair, but the source address of the check is used to select the
pair that succeeded, so they are not the same.
parent b6200446
......@@ -273,7 +273,7 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
{
gboolean keep_timer_going = FALSE;
guint s_inprogress = 0, s_succeeded = 0, s_discovered = 0,
s_nominated = 0, s_waiting_for_nomination = 0;
s_nominated = 0, s_waiting_for_nomination = 0, s_valid = 0;
guint frozen = 0, waiting = 0;
GSList *i, *k;
......@@ -342,6 +342,8 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
++s_succeeded;
else if (p->state == NICE_CHECK_DISCOVERED)
++s_discovered;
if (p->valid)
++s_valid;
if ((p->state == NICE_CHECK_SUCCEEDED || p->state == NICE_CHECK_DISCOVERED)
&& p->nominated)
......@@ -387,9 +389,9 @@ static gboolean priv_conn_check_tick_stream (Stream *stream, NiceAgent *agent, G
if (tick_counter++ % 50 == 0 || keep_timer_going != TRUE)
nice_debug ("Agent %p : timer tick #%u: %u frozen, %u in-progress, "
"%u waiting, %u succeeded, %u discovered, %u nominated, "
"%u waiting-for-nom.", agent,
"%u waiting-for-nom, %u valid.", agent,
tick_counter, frozen, s_inprogress, waiting, s_succeeded,
s_discovered, s_nominated, s_waiting_for_nomination);
s_discovered, s_nominated, s_waiting_for_nomination, s_valid);
}
return keep_timer_going;
......@@ -1313,7 +1315,7 @@ static void priv_update_check_list_failed_components (NiceAgent *agent, Stream *
static void priv_update_check_list_state_for_ready (NiceAgent *agent, Stream *stream, Component *component)
{
GSList *i;
guint succeeded = 0, nominated = 0;
guint valid = 0, nominated = 0;
g_assert (component);
......@@ -1321,9 +1323,8 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, Stream *st
for (i = stream->conncheck_list; i; i = i->next) {
CandidateCheckPair *p = i->data;
if (p->component_id == component->id) {
if (p->state == NICE_CHECK_SUCCEEDED ||
p->state == NICE_CHECK_DISCOVERED) {
++succeeded;
if (p->valid) {
++valid;
if (p->nominated == TRUE) {
++nominated;
}
......@@ -1331,7 +1332,7 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, Stream *st
}
}
if (nominated > 0) {
if (valid > 0) {
/* Only go to READY if no checks are left in progress. If there are
* any that are kept, then this function will be called again when the
* conncheck tick timer finishes them all */
......@@ -1350,7 +1351,7 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, Stream *st
component->id, NICE_COMPONENT_STATE_READY);
}
}
nice_debug ("Agent %p : conn.check list status: %u nominated, %u succeeded, c-id %u.", agent, nominated, succeeded, component->id);
nice_debug ("Agent %p : conn.check list status: %u nominated, %u valid, c-id %u.", agent, nominated, valid, component->id);
}
/*
......@@ -1373,8 +1374,7 @@ static void priv_mark_pair_nominated (NiceAgent *agent, Stream *stream, Componen
if (pair->remote == remotecand) {
nice_debug ("Agent %p : marking pair %p (%s) as nominated", agent, pair, pair->foundation);
pair->nominated = TRUE;
if (pair->state == NICE_CHECK_SUCCEEDED ||
pair->state == NICE_CHECK_DISCOVERED) {
if (pair->valid) {
priv_update_selected_pair (agent, component, pair);
/* Do not step down to CONNECTED if we're already at state READY*/
if (component->state != NICE_COMPONENT_STATE_READY) {
......@@ -2008,10 +2008,8 @@ static guint priv_prune_pending_checks (Stream *stream, guint component_id)
for (i = stream->conncheck_list; i; i = i->next) {
CandidateCheckPair *p = i->data;
if (p->component_id == component_id &&
(p->state == NICE_CHECK_SUCCEEDED ||
p->state == NICE_CHECK_DISCOVERED) &&
p->nominated == TRUE){
if (p->component_id == component_id && p->valid == TRUE &&
p->nominated == TRUE) {
if (p->priority > highest_nominated_priority) {
highest_nominated_priority = p->priority;
}
......@@ -2352,8 +2350,6 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
}
if (local_cand_matches == TRUE) {
/* note: this is same as "adding to VALID LIST" in the spec
text */
p->state = NICE_CHECK_SUCCEEDED;
nice_debug ("Agent %p : conncheck %p SUCCEEDED.", agent, p);
priv_conn_check_unfreeze_related (agent, stream, p);
......@@ -2380,6 +2376,11 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
nice_debug ("Agent %p : conncheck %p FAILED, %p DISCOVERED.", agent, p, new_pair);
}
/* note: this is same as "adding to VALID LIST" in the spec
text */
if (new_pair)
new_pair->valid = TRUE;
return new_pair;
}
......@@ -2459,6 +2460,8 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
/* note: this is same as "adding to VALID LIST" in the spec
text */
p->state = NICE_CHECK_SUCCEEDED;
p->valid = TRUE;
g_assert_not_reached ();
nice_debug ("Agent %p : Mapped address not found."
" conncheck %p SUCCEEDED.", agent, p);
priv_conn_check_unfreeze_related (agent, stream, p);
......
......@@ -87,6 +87,7 @@ struct _CandidateCheckPair
gboolean nominated;
gboolean controlling;
gboolean timer_restarted;
gboolean valid;
guint64 priority;
guint32 prflx_priority;
GTimeVal next_tick; /* next tick timestamp */
......
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