[Pkg-telepathy-commits] [libnice] 155/265: component: Add a GCancellable to get of out blocking nice_agent_recv()

Simon McVittie smcv at debian.org
Wed May 14 12:05:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit 0cca15608aea922eb90c557f5cb38fd2ad416b69
Author: Olivier Crête <olivier.crete at collabora.com>
Date:   Mon Feb 24 23:02:04 2014 -0500

    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.
---
 agent/component.c | 8 ++++++++
 agent/component.h | 2 ++
 2 files changed, 10 insertions(+)

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;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list