Commit 1949b89f authored by Olivier Crête's avatar Olivier Crête

component: Add API to cleanly remove a base socket

parent 93330f1f
...@@ -4872,7 +4872,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data) ...@@ -4872,7 +4872,7 @@ component_io_cb (GSocket *gsocket, GIOCondition condition, gpointer user_data)
stream->id, component->id, NICE_COMPONENT_STATE_FAILED); stream->id, component->id, NICE_COMPONENT_STATE_FAILED);
} }
nice_component_detach_socket (component, socket_source->socket); nice_component_remove_socket (component, socket_source->socket);
agent_unlock (); agent_unlock ();
g_object_unref (agent); g_object_unref (agent);
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
......
...@@ -82,6 +82,10 @@ static void ...@@ -82,6 +82,10 @@ static void
nice_component_schedule_io_callback (NiceComponent *component); nice_component_schedule_io_callback (NiceComponent *component);
static void static void
nice_component_deschedule_io_callback (NiceComponent *component); nice_component_deschedule_io_callback (NiceComponent *component);
static void
nice_component_detach_socket (NiceComponent *component, NiceSocket *nicesock);
static void
nice_component_clear_selected_pair (NiceComponent *component);
void void
...@@ -152,6 +156,45 @@ nice_component_new (guint id, NiceAgent *agent, NiceStream *stream) ...@@ -152,6 +156,45 @@ nice_component_new (guint id, NiceAgent *agent, NiceStream *stream)
NULL); NULL);
} }
void
nice_component_remove_socket (NiceComponent *cmp, NiceSocket *nsocket)
{
GSList *i;
for (i = cmp->local_candidates; i;) {
NiceCandidate *candidate = i->data;
GSList *next = i->next;
if (!nice_socket_is_based_on (candidate->sockptr, nsocket)) {
i = next;
continue;
}
if (candidate == cmp->selected_pair.local) {
nice_component_clear_selected_pair (cmp);
agent_signal_component_state_change (cmp->agent, cmp->stream->id,
cmp->id, NICE_COMPONENT_STATE_FAILED);
}
refresh_prune_candidate (cmp->agent, candidate);
if (candidate->sockptr != nsocket) {
discovery_prune_socket (cmp->agent, candidate->sockptr);
conn_check_prune_socket (cmp->agent, cmp->stream, cmp,
candidate->sockptr);
nice_component_detach_socket (cmp, candidate->sockptr);
}
agent_remove_local_candidate (cmp->agent, candidate);
nice_candidate_free (candidate);
cmp->local_candidates = g_slist_delete_link (cmp->local_candidates, i);
i = next;
}
discovery_prune_socket (cmp->agent, nsocket);
conn_check_prune_socket (cmp->agent, cmp->stream, cmp, nsocket);
nice_component_detach_socket (cmp, nsocket);
}
void void
nice_component_clean_turn_servers (NiceComponent *cmp) nice_component_clean_turn_servers (NiceComponent *cmp)
{ {
...@@ -541,7 +584,7 @@ nice_component_reattach_all_sockets (NiceComponent *component) ...@@ -541,7 +584,7 @@ nice_component_reattach_all_sockets (NiceComponent *component)
/** /**
* nice_component_detach_socket: * nice_component_detach_socket:
* @component: a #Component * @component: a #NiceComponent
* @socket: the socket to detach the source for * @socket: the socket to detach the source for
* *
* Detach the #GSource for the single specified @socket. It also closes it * Detach the #GSource for the single specified @socket. It also closes it
...@@ -549,7 +592,7 @@ nice_component_reattach_all_sockets (NiceComponent *component) ...@@ -549,7 +592,7 @@ nice_component_reattach_all_sockets (NiceComponent *component)
* *
* If the @socket doesn’t exist in this @component, do nothing. * If the @socket doesn’t exist in this @component, do nothing.
*/ */
void static void
nice_component_detach_socket (NiceComponent *component, NiceSocket *nicesock) nice_component_detach_socket (NiceComponent *component, NiceSocket *nicesock)
{ {
GSList *l; GSList *l;
...@@ -1281,7 +1324,7 @@ static GSourceFuncs component_source_funcs = { ...@@ -1281,7 +1324,7 @@ static GSourceFuncs component_source_funcs = {
}; };
/** /**
* component_source_new: * nice_component_source_new:
* @agent: a #NiceAgent * @agent: a #NiceAgent
* @stream_id: The stream's id * @stream_id: The stream's id
* @component_id: The component's number * @component_id: The component's number
......
...@@ -261,8 +261,7 @@ void ...@@ -261,8 +261,7 @@ void
nice_component_attach_socket (NiceComponent *component, NiceSocket *nsocket); nice_component_attach_socket (NiceComponent *component, NiceSocket *nsocket);
void void
nice_component_detach_socket (NiceComponent *component, NiceSocket *nsocket); nice_component_remove_socket (NiceComponent *component, NiceSocket *nsocket);
void void
nice_component_detach_all_sockets (NiceComponent *component); nice_component_detach_all_sockets (NiceComponent *component);
......
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