Commit 62991736 authored by Olivier Crête's avatar Olivier Crête 👻

discovery: Clean up error handling in discovery_add_relay_candidate

parent 305ce1a9
...@@ -583,8 +583,6 @@ discovery_add_relay_candidate ( ...@@ -583,8 +583,6 @@ discovery_add_relay_candidate (
NiceCandidate *candidate; NiceCandidate *candidate;
Component *component; Component *component;
Stream *stream; Stream *stream;
gboolean result = FALSE;
gboolean errors = FALSE;
NiceSocket *relay_socket = NULL; NiceSocket *relay_socket = NULL;
if (!agent_find_component (agent, stream_id, component_id, &stream, &component)) if (!agent_find_component (agent, stream_id, component_id, &stream, &component))
...@@ -610,41 +608,35 @@ discovery_add_relay_candidate ( ...@@ -610,41 +608,35 @@ discovery_add_relay_candidate (
base_socket, &turn->server, base_socket, &turn->server,
turn->username, turn->password, turn->username, turn->password,
agent_to_turn_socket_compatibility (agent)); agent_to_turn_socket_compatibility (agent));
if (relay_socket) { if (!relay_socket)
candidate->sockptr = relay_socket; goto errors;
candidate->base_addr = base_socket->addr;
priv_generate_candidate_credentials (agent, candidate);
/* Google uses the turn username as the candidate username */ candidate->sockptr = relay_socket;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) { candidate->base_addr = base_socket->addr;
g_free (candidate->username);
candidate->username = g_strdup (turn->username);
}
priv_assign_foundation (agent, candidate); priv_generate_candidate_credentials (agent, candidate);
result = priv_add_local_candidate_pruned (component, candidate); /* Google uses the turn username as the candidate username */
if (result) { if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
component->sockets = g_slist_append (component->sockets, relay_socket); g_free (candidate->username);
agent_signal_new_candidate (agent, candidate); candidate->username = g_strdup (turn->username);
} else {
/* error: duplicate candidate */
errors = TRUE;
}
} else {
/* error: socket factory make */
errors = TRUE;
} }
/* clean up after errors */ priv_assign_foundation (agent, candidate);
if (errors) {
if (candidate) if (!priv_add_local_candidate_pruned (component, candidate))
nice_candidate_free (candidate), candidate = NULL; goto errors;
if (relay_socket)
nice_socket_free (relay_socket); component->sockets = g_slist_append (component->sockets, relay_socket);
} agent_signal_new_candidate (agent, candidate);
return candidate; return candidate;
errors:
nice_candidate_free (candidate);
if (relay_socket)
nice_socket_free (relay_socket);
return NULL;
} }
/* /*
......
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