summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2014-02-25 04:02:04 (GMT)
committerOlivier CrĂȘte <olivier.crete@collabora.com>2014-02-25 05:51:31 (GMT)
commit0cca15608aea922eb90c557f5cb38fd2ad416b69 (patch)
tree683064768b859585e24fd2829dd26c31e8ac85fb
parente0a7b9343237f6cf31b96082c6c6939526aabf5f (diff)
downloadlibnice-0cca15608aea922eb90c557f5cb38fd2ad416b69.tar.gz
libnice-0cca15608aea922eb90c557f5cb38fd2ad416b69.tar.xz
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.
-rw-r--r--agent/component.c8
-rw-r--r--agent/component.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/agent/component.c b/agent/component.c
index d22816e..3bee9b4 100644
--- a/agent/component.c
+++ b/agent/component.c
@@ -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;
diff --git a/agent/component.h b/agent/component.h
index 6433a85..143c212 100644
--- a/agent/component.h
+++ b/agent/component.h
@@ -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;