From: Wim Taymans Date: Thu, 7 Oct 2004 18:34:57 +0000 (+0000) Subject: gst/gstthread.c: Make sure no iteration happens while performing the state change... X-Git-Tag: RELEASE-0_8_8~107 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=625722ecdc81a6af73a9c609e7abe623a59bd19a;p=platform%2Fupstream%2Fgstreamer.git gst/gstthread.c: Make sure no iteration happens while performing the state change as it could mess up the internal co... Original commit message from CVS: * gst/gstthread.c: (gst_thread_change_state), (gst_thread_child_state_change): Make sure no iteration happens while performing the state change as it could mess up the internal consistency of the thread state. --- diff --git a/ChangeLog b/ChangeLog index 3b85b80..bddb5e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-10-07 Wim Taymans + * gst/gstthread.c: (gst_thread_change_state), + (gst_thread_child_state_change): + Make sure no iteration happens while performing + the state change as it could mess up the internal + consistency of the thread state. + +2004-10-07 Wim Taymans + * gst/gstthread.c: (gst_thread_dispose), (gst_thread_sync), (gst_thread_change_state), (gst_thread_child_state_change): Do not try to grab the iterate lock in the state change method diff --git a/gst/gstthread.c b/gst/gstthread.c index 48578c4..29e36de 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -445,8 +445,6 @@ gst_thread_change_state (GstElement * element) gst_element_state_get_name (GST_STATE (element)), gst_element_state_get_name (GST_STATE_PENDING (element))); - transition = GST_STATE_TRANSITION (element); - thread = GST_THREAD (element); /* boolean to check if we called the state change in the same thread as @@ -458,12 +456,15 @@ gst_thread_change_state (GstElement * element) gst_thread_sync (thread, is_self); - /* FIXME: (or GStreamers ideas about "threading"): the element variables are - commonly accessed by multiple threads at the same time (see bug #111146 - for an example) */ - if (transition != GST_STATE_TRANSITION (element)) { - g_warning ("inconsistent state information, fix threading please"); - } + /* no iteration is allowed during this state change because an iteration + * can cause another state change conflicting with this one */ + /* do not try to grab the lock if this method is called from the + * same thread as the iterate thread, the lock might be held and we + * might deadlock */ + if (!is_self) + g_mutex_lock (thread->iterate_lock); + + transition = GST_STATE_TRANSITION (element); switch (transition) { case GST_STATE_NULL_TO_READY: @@ -560,11 +561,6 @@ gst_thread_change_state (GstElement * element) GST_LOG_OBJECT (thread, "unlocking lock"); g_mutex_unlock (thread->lock); - /* do not try to grab the lock if this method is called from the - * same thread as the iterate thread, the lock might be held and we - * might deadlock */ - if (!is_self) - g_mutex_lock (thread->iterate_lock); if (GST_ELEMENT_CLASS (parent_class)->change_state) { ret = GST_ELEMENT_CLASS (parent_class)->change_state (GST_ELEMENT (thread)); } else { @@ -583,6 +579,9 @@ error_out: g_mutex_unlock (thread->lock); + if (!is_self) + g_mutex_unlock (thread->iterate_lock); + return GST_STATE_FAILURE; }