Task: call leave_thread before signaling
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 21 Apr 2009 12:42:05 +0000 (14:42 +0200)
committerWim Taymans <wim@metal.(none)>
Mon, 11 May 2009 21:49:19 +0000 (23:49 +0200)
Call the leave_thread callback before we signal the thread performing the _join
so that we can be sure that the listener still has valid info in the callback.

gst/gsttask.c

index 9b2dd0e..5ef1c57 100644 (file)
@@ -213,13 +213,16 @@ exit:
    * before releasing the lock as we can be sure that a ref is held by the
    * caller of the join(). */
   task->running = FALSE;
+  if (priv->thr_callbacks.leave_thread) {
+    /* fire the leave_thread callback when we need to. We need to do this before
+     * we signal the task and with the task lock released. */
+    GST_OBJECT_UNLOCK (task);
+    priv->thr_callbacks.leave_thread (task, tself, priv->thr_user_data);
+    GST_OBJECT_LOCK (task);
+  }
   GST_TASK_SIGNAL (task);
   GST_OBJECT_UNLOCK (task);
 
-  /* fire the leave_thread callback when we need to */
-  if (priv->thr_callbacks.leave_thread)
-    priv->thr_callbacks.leave_thread (task, tself, priv->thr_user_data);
-
   GST_DEBUG ("Exit task %p, thread %p", task, g_thread_self ());
 
   gst_object_unref (task);