[farsight2/master] Add flag to prevent race conditions

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:25:10 PST 2008


---
 gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c b/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c
index 3367720..935c4fc 100644
--- a/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c
+++ b/gst-libs/ext/fsupnp/fs-upnp-simple-igd-thread.c
@@ -30,6 +30,8 @@ struct _FsUpnpSimpleIgdThreadPrivate
   GMainLoop *loop;
   GMainContext *context;
   GMutex *mutex;
+
+  gboolean quit_loop;
 };
 
 
@@ -96,6 +98,7 @@ fs_upnp_simple_igd_thread_dispose (GObject *object)
   FS_UPNP_SIMPLE_IGD_THREAD_LOCK (self);
   if (self->priv->loop)
     g_main_loop_quit (self->priv->loop);
+  self->priv->quit_loop = TRUE;
   FS_UPNP_SIMPLE_IGD_THREAD_UNLOCK (self);
 
   g_thread_join (self->priv->thread);
@@ -120,11 +123,15 @@ thread_func (gpointer data)
 {
   FsUpnpSimpleIgdThread *self = data;
   GMainLoop *loop = g_main_loop_new (self->priv->context, FALSE);
+  gboolean quit_loop;
+
   FS_UPNP_SIMPLE_IGD_THREAD_LOCK (self);
   self->priv->loop = loop;
+  quit_loop = self->priv->quit_loop;
   FS_UPNP_SIMPLE_IGD_THREAD_UNLOCK (self);
 
-  g_main_loop_run (loop);
+  if (!quit_loop)
+    g_main_loop_run (loop);
 
   FS_UPNP_SIMPLE_IGD_THREAD_LOCK (self);
   self->priv->loop = NULL;
-- 
1.5.6.5




More information about the farsight-commits mailing list