From d20de24c97dbb55625939fa9c7a69d0dfa6fefeb Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 25 May 2009 11:56:47 +0200 Subject: [PATCH] gsttask: avoid join to return early Unset the running flag after we released the lock for posting the stream-status message. If we set the running flag to FALSE too early, the join method will just continue without waiting for the message to be posted, leading to potential crashes. --- gst/gsttask.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gst/gsttask.c b/gst/gsttask.c index cc01792cf5..662a4f7bbe 100644 --- a/gst/gsttask.c +++ b/gst/gsttask.c @@ -243,14 +243,6 @@ done: task->abidata.ABI.thread = NULL; exit: - /* now we allow messing with the lock again by setting the running flag to - * FALSE. Together with the SIGNAL this is the sign for the _join() to - * complete. - * Note that we still have not dropped the final ref on the task. We could - * check here if there is a pending join() going on and drop the last ref - * 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. */ @@ -262,6 +254,14 @@ exit: * touch the priority when a custom callback has been installed. */ g_thread_set_priority (tself, G_THREAD_PRIORITY_NORMAL); } + /* now we allow messing with the lock again by setting the running flag to + * FALSE. Together with the SIGNAL this is the sign for the _join() to + * complete. + * Note that we still have not dropped the final ref on the task. We could + * check here if there is a pending join() going on and drop the last ref + * before releasing the lock as we can be sure that a ref is held by the + * caller of the join(). */ + task->running = FALSE; GST_TASK_SIGNAL (task); GST_OBJECT_UNLOCK (task);