Commit cbf0162d authored by Fabrice Bellet's avatar Fabrice Bellet
Browse files

agent: stay in aggressive mode after stun requests have been sent

This patch updates the previous commit "agent: stay in aggressive mode
after conncheck has started", by accepting to switch from aggressive to
regular mode, while no stun request has been sent. It gives the agent
some extra delay to still accept remote tcp candidates, after its state
already changed from gathering to connecting.
parent 010ecd50
Pipeline #144098 failed with stages
in 9 minutes and 16 seconds
......@@ -3733,11 +3733,7 @@ static gboolean priv_add_remote_candidate (
if (agent->controlling_mode &&
agent->nomination_mode == NICE_NOMINATION_MODE_AGGRESSIVE &&
transport != NICE_CANDIDATE_TRANSPORT_UDP) {
if (component->state < NICE_COMPONENT_STATE_CONNECTING) {
nice_debug ("Agent %p : we have a TCP candidate, switching back "
"to regular nomination mode", agent);
agent->nomination_mode = NICE_NOMINATION_MODE_REGULAR;
} else {
if (conn_check_stun_transactions_count (agent) > 0) {
/* changing nomination mode from aggressive to regular while
* conncheck is ongoing may cause unexpected results (inflight
* aggressive stun requests may nominate a pair unilaterally)
......@@ -3745,6 +3741,10 @@ static gboolean priv_add_remote_candidate (
nice_debug ("Agent %p : we have a TCP candidate, but conncheck "
"has started already in aggressive mode, ignore it", agent);
goto errors;
} else {
nice_debug ("Agent %p : we have a TCP candidate, switching back "
"to regular nomination mode", agent);
agent->nomination_mode = NICE_NOMINATION_MODE_REGULAR;
}
}
}
......
......@@ -536,6 +536,24 @@ priv_conn_check_unfreeze_maybe (NiceAgent *agent, CandidateCheckPair *pair)
}
}
guint
conn_check_stun_transactions_count (NiceAgent *agent)
{
GSList *i, *j;
guint count = 0;
for (i = agent->streams; i ; i = i->next) {
NiceStream *s = i->data;
for (j = s->conncheck_list; j ; j = j->next) {
CandidateCheckPair *p = j->data;
if (p->stun_transactions)
count += g_slist_length (p->stun_transactions);
}
}
return count;
}
/*
* Create a new STUN transaction and add it to the list
* of ongoing stun transactions of a pair.
......
......@@ -124,6 +124,7 @@ void conn_check_update_selected_pair (NiceAgent *agent,
void conn_check_update_check_list_state_for_ready (NiceAgent *agent,
NiceStream *stream, NiceComponent *component);
void conn_check_unfreeze_related (NiceAgent *agent, CandidateCheckPair *pair);
guint conn_check_stun_transactions_count (NiceAgent *agent);
#endif /*_NICE_CONNCHECK_H */
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