diff options
author | Fabrice Bellet <fabrice@bellet.info> | 2016-04-19 18:16:26 +0200 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2017-06-21 16:05:56 -0400 |
commit | 9103a5f2e184211fc160d1d3070ce4d043c71ff0 (patch) | |
tree | 7c5618c4d97329def994b99cf0e27b2a34dac09d | |
parent | 72ee528f7fdf82fb1a44958c18a0d4d5055d2d1a (diff) | |
download | libnice-9103a5f2e184211fc160d1d3070ce4d043c71ff0.tar.gz |
conncheck: use the right pair when retriggering a check
This patch completes the previous patch by adding a link back from the
discovered pair, to the parent pair that generated this check. This link
is needed by the ICE spec, to comply with section 8.1.1.1, "Regular
nomination", where the check to be retriggered is the initial check that
caused the discovery of the valid pair. When the valid pair is a
peer-reflexive pair, the retriggered check must target the succeeded
pair, and not the valid discovered pair.
Differential Revision: https://phabricator.freedesktop.org/D879
-rw-r--r-- | agent/conncheck.c | 21 | ||||
-rw-r--r-- | agent/conncheck.h | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/agent/conncheck.c b/agent/conncheck.c index 99cb6d2..79685df 100644 --- a/agent/conncheck.c +++ b/agent/conncheck.c @@ -847,6 +847,16 @@ priv_conn_check_tick_stream_nominate (NiceStream *stream, NiceAgent *agent) !p->nominated && !p->use_candidate_on_next_check && p->valid) { + /* According a ICE spec, sect 8.1.1.1. "Regular + * Nomination", we enqueue the check that produced this + * valid pair. When this pair has been discovered, we want + * to test its parent pair instead. + */ + if (p->succeeded_pair != NULL) { + g_assert (p->state == NICE_CHECK_DISCOVERED); + p = p->succeeded_pair; + } + g_assert (p->state == NICE_CHECK_SUCCEEDED); nice_debug ("Agent %p : restarting check %p with " "USE-CANDIDATE attrib (regular nomination)", agent, p); p->recheck_on_timeout = FALSE; @@ -2754,6 +2764,11 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, NiceStream *str * tcp-active we don't want to retrigger a check on a pair that * was FAILED when a peer-reflexive pair was created */ + if (p->succeeded_pair != NULL) { + g_assert (p->state == NICE_CHECK_DISCOVERED); + p = p->succeeded_pair; + } + nice_debug ("Agent %p : Found a matching pair %p for triggered check.", agent, p); if (p->state == NICE_CHECK_WAITING || @@ -2775,8 +2790,7 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, NiceStream *str p->recheck_on_timeout = TRUE; } } - else if (p->state == NICE_CHECK_SUCCEEDED || - p->state == NICE_CHECK_DISCOVERED) { + else if (p->state == NICE_CHECK_SUCCEEDED) { nice_debug ("Agent %p : Skipping triggered check, already completed..", agent); /* note: this is a bit unsure corner-case -- let's do the same state update as for processing responses to our own checks */ @@ -2943,6 +2957,7 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint pair->sockptr = local_cand->sockptr; pair->state = NICE_CHECK_DISCOVERED; parent_pair->discovered_pair = pair; + pair->succeeded_pair = parent_pair; nice_debug ("Agent %p : new pair %p state DISCOVERED", agent, pair); { gchar tmpbuf1[INET6_ADDRSTRLEN]; @@ -4163,7 +4178,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, NiceStream *stream, pair = priv_conn_check_add_for_candidate_pair_matched (agent, stream->id, component, local_candidate, remote_candidate, - NICE_CHECK_DISCOVERED); + NICE_CHECK_SUCCEEDED); if (pair) { pair->valid = TRUE; } diff --git a/agent/conncheck.h b/agent/conncheck.h index dd47ebe..c07fb22 100644 --- a/agent/conncheck.h +++ b/agent/conncheck.h @@ -90,6 +90,7 @@ struct _CandidateCheckPair gboolean mark_nominated_on_response_arrival; gboolean recheck_on_timeout; struct _CandidateCheckPair *discovered_pair; + struct _CandidateCheckPair *succeeded_pair; guint64 priority; guint32 prflx_priority; GTimeVal next_tick; /* next tick timestamp */ |