summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Bellet <fabrice@bellet.info>2020-04-23 17:12:41 +0200
committerFabrice Bellet <fabrice@bellet.info>2020-05-08 17:24:29 +0200
commitcbf0162d7f0b9b2800acfe09f767ce8676f09e97 (patch)
tree86be27d2a7e176de4270a12f5d8eced1c4d0987b
parent010ecd50341b0f861f9e395f552cee94bab79825 (diff)
downloadlibnice-cbf0162d7f0b9b2800acfe09f767ce8676f09e97.tar.gz
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.
-rw-r--r--agent/agent.c10
-rw-r--r--agent/conncheck.c18
-rw-r--r--agent/conncheck.h1
3 files changed, 24 insertions, 5 deletions
diff --git a/agent/agent.c b/agent/agent.c
index 5d3fbb4..110d242 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -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;
}
}
}
diff --git a/agent/conncheck.c b/agent/conncheck.c
index fc4b3eb..927a402 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -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.
diff --git a/agent/conncheck.h b/agent/conncheck.h
index 7b11743..50fa0b1 100644
--- a/agent/conncheck.h
+++ b/agent/conncheck.h
@@ -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 */