Commit 8f74fa48 authored by Fabrice Bellet's avatar Fabrice Bellet Committed by Olivier Crête

agent: rework gathering failures on auto-generated IPs

This patch reworks commit fc4d3aab "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 fc4d3aab 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.
parent 8b1fa846
......@@ -2742,18 +2742,9 @@ 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;
#ifdef HAVE_GUPNP
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);
gboolean found_local_address = FALSE;
enum {
ADD_HOST_MIN = 0,
ADD_HOST_UDP = ADD_HOST_MIN,
......@@ -2765,6 +2756,16 @@ nice_agent_gather_candidates (
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);
#endif
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;
}
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;
......
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