Commit 0cca1560 authored by Olivier Crête's avatar Olivier Crête

component: Add a GCancellable to get of out blocking nice_agent_recv()

Otherwise, it may be stuck iterating the context forever if all of the
other sources are gone.
parent e0a7b934
......@@ -112,6 +112,7 @@ Component *
component_new (guint id, NiceAgent *agent, Stream *stream)
{
Component *component;
GSource *src;
component = g_slice_new0 (Component);
component->id = id;
......@@ -126,6 +127,10 @@ component_new (guint id, NiceAgent *agent, Stream *stream)
component->io_callback_id = 0;
component->own_ctx = g_main_context_new ();
component->stop_cancellable = g_cancellable_new ();
src = g_cancellable_source_new (component->stop_cancellable);
g_source_attach (src, component->own_ctx);
g_source_unref (src);
component->ctx = g_main_context_ref (component->own_ctx);
/* Start off with a fresh main context and all I/O paused. This
......@@ -205,6 +210,9 @@ component_free (Component *cmp)
component_deschedule_io_callback (cmp);
g_cancellable_cancel (cmp->stop_cancellable);
g_clear_object (&cmp->stop_cancellable);
if (cmp->ctx != NULL) {
g_main_context_unref (cmp->ctx);
cmp->ctx = NULL;
......
......@@ -186,6 +186,8 @@ struct _Component
Stream *stream; /* unowned, immutable: can be accessed without holding the
* agent lock */
GCancellable *stop_cancellable;
PseudoTcpSocket *tcp;
GSource* tcp_clock;
long last_clock_timeout;
......
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