summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Bellet <fabrice@bellet.info>2016-06-07 10:52:02 +0200
committerOlivier CrĂȘte <olivier.crete@collabora.com>2016-06-20 18:10:17 -0400
commit8f74fa48670a927531fa362366c7ee66406e40d1 (patch)
tree3a26f06e23c51006d2547444b11f76b69e54083d
parent8b1fa8467fc6e6113ab08bb4edc233e597544728 (diff)
downloadlibnice-8f74fa48670a927531fa362366c7ee66406e40d1.tar.gz
agent: rework gathering failures on auto-generated IPs
This patch reworks commit fc4d3aa "ignore gathering failures on auto-generated IPs", that introduces a regression in the test-fullmode check, when turn is on and use_loopback is off. The part of the test that fails is when nice_agent_gather_candidates (ragent...) should return false when the port range for the second component is already busy, line 385. In this case, agent->local_address is null, so the code path added by commit fc4d3aa is taken, and the function will return true, even when not local address has been gathered. The proper fix is to swap the inner and outer loops (on components, and on local addresses), and to go to error when all local addresses of a given component have failed, and to return false only in this case.
-rw-r--r--agent/agent.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/agent/agent.c b/agent/agent.c
index f6c7a36..3d21d9b 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -2742,29 +2742,30 @@ nice_agent_gather_candidates (
}
}
- /* generate a local host candidate for each local address */
- for (i = local_addresses; i; i = i->next) {
- NiceAddress *addr = i->data;
- NiceCandidate *host_candidate;
+ for (cid = 1; cid <= stream->n_components; cid++) {
+ NiceComponent *component = nice_stream_find_component_by_id (stream, cid);
+ gboolean found_local_address = FALSE;
+ enum {
+ ADD_HOST_MIN = 0,
+ ADD_HOST_UDP = ADD_HOST_MIN,
+ ADD_HOST_TCP_ACTIVE,
+ ADD_HOST_TCP_PASSIVE,
+ ADD_HOST_MAX = ADD_HOST_TCP_PASSIVE
+ } add_type;
+
+ if (component == NULL)
+ continue;
+
+ /* generate a local host candidate for each local address */
+ for (i = local_addresses; i; i = i->next) {
+ NiceAddress *addr = i->data;
+ NiceCandidate *host_candidate;
#ifdef HAVE_GUPNP
- gchar local_ip[NICE_ADDRESS_STRING_LEN];
- nice_address_to_string (addr, local_ip);
+ gchar local_ip[NICE_ADDRESS_STRING_LEN];
+ nice_address_to_string (addr, local_ip);
#endif
- for (cid = 1; cid <= stream->n_components; cid++) {
- NiceComponent *component = nice_stream_find_component_by_id (stream, cid);
- enum {
- ADD_HOST_MIN = 0,
- ADD_HOST_UDP = ADD_HOST_MIN,
- ADD_HOST_TCP_ACTIVE,
- ADD_HOST_TCP_PASSIVE,
- ADD_HOST_MAX = ADD_HOST_TCP_PASSIVE
- } add_type;
-
- if (component == NULL)
- continue;
-
for (add_type = ADD_HOST_MIN; add_type <= ADD_HOST_MAX; add_type++) {
NiceCandidateTransport transport;
guint current_port;
@@ -2814,8 +2815,7 @@ nice_agent_gather_candidates (
} else if (res == HOST_CANDIDATE_FAILED) {
nice_debug ("Agent %p: Could ot retrieive component %d/%d", agent,
stream->id, cid);
- ret = FALSE;
- goto error;
+ continue;
} else if (res == HOST_CANDIDATE_CANT_CREATE_SOCKET) {
if (nice_debug_is_enabled ()) {
gchar ip[NICE_ADDRESS_STRING_LEN];
@@ -2824,14 +2824,10 @@ nice_agent_gather_candidates (
" s%d:%d. Invalid interface?", agent, ip, stream->id,
component->id);
}
- if (agent->local_addresses == NULL) {
- /* Ignore when an auto-generated address fails. */
- continue;
- }
- ret = FALSE;
- goto error;
+ continue;
}
+ found_local_address = TRUE;
nice_address_set_port (addr, 0);
@@ -2888,6 +2884,13 @@ nice_agent_gather_candidates (
}
}
}
+ /* Go to error if we could not find a local address for a given
+ * component
+ */
+ if (!found_local_address) {
+ ret = FALSE;
+ goto error;
+ }
}
stream->gathering = TRUE;