GNOME Bugzilla – Bug 721253
multiqueue: May cause hanging if shut down while handling a serialized query
Last modified: 2014-01-06 10:01:24 UTC
I use playbin to playing a http stream. When the pipeline did not construct finished, I called gst_element_set_state(playbin, GST_STATE_NULL); At this time, application hang. This is call stack of threads that cause haning. ======================
+ Trace 232972
Thread 5 (Thread 0x2b98a480 (LWP 22769))
=========================== I found the root cause is at function gst_multi_queue_sink_query, g_cond_wait (&sq->query_handled, &mq->qlock); It will wait the query condition to be signaled. But because the whole pileline did not construct finished and want to stop immediately, the sq->query_handled have no chance to be signaled. So at function gst_multi_queue_change_state case GST_STATE_CHANGE_PAUSED_TO_READY:{ GList *tmp; /* Un-wait all waiting pads */ GST_MULTI_QUEUE_MUTEX_LOCK (mqueue); for (tmp = mqueue->queues; tmp; tmp = g_list_next (tmp)) { sq = (GstSingleQueue *) tmp->data; sq->flushing = TRUE; g_cond_signal (&sq->turn); g_cond_signal (&sq->query_handled); //I add this line =========== } GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue); break; } And I test serveral hours to do quick switch: 1. create playin 2. set state playing 3. sleep 100 ms 4. set state null This will be OK. //========================== And I check the codes of 1.2.1, there are some other lines will call g_cond_signal (&sq->query_handled). But I think add it to gst_multi_queue_change_state is better and safer.
Anther thread callstack:
+ Trace 232973
Thread 3 (Thread 0x2d6fe480 (LWP 22776))
You also need to set sq->last_query=FALSE here. Can you provide this patch in "git format-patch" format? For this commit the change locally (make sure to set up your real name and mail address in git) and then do "git format-patch -1".
Created attachment 265118 [details] [review] diff
(In reply to comment #3) > Created an attachment (id=265118) [details] [review] > diff Index: gstmultiqueue.c =================================================================== --- gstmultiqueue.c (revision 41444) +++ gstmultiqueue.c (working copy) @@ -712,6 +712,9 @@ sq = (GstSingleQueue *) tmp->data; sq->flushing = TRUE; g_cond_signal (&sq->turn); + + sq->last_query = FALSE; + g_cond_signal (&sq->query_handled); } GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue); break;
Could you please attach the patch in git format-patch format?
Similar change might be necessary in the other queues too. Should be checked before pushing this.
Created attachment 265201 [details] [review] fix multiqueue hanging when stopping signal query_handled when stopping multiqueue
(In reply to comment #7) > Created an attachment (id=265201) [details] [review] > fix multiqueue hanging when stopping > > signal query_handled when stopping multiqueue I checked gstqueue and gstqueue2. And I think queue and queue2 don't have this problem.
Please also provide a proper commit message like the following in the future :) commit 1de533735b93ec8cbad346267f99e6519d0e3cc8 Author: YanpingZhang <zhangyanping210@163.com> Date: Fri Jan 3 11:47:23 2014 +0800 multiqueue: Fix hanging if shut down while handling a serialized query https://bugzilla.gnome.org/show_bug.cgi?id=721253