diff options
author | Edward Hervey <edward@centricular.com> | 2021-04-16 11:36:33 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2021-04-17 09:28:46 +0100 |
commit | b566cbe0222439aad0c67b39161e6ffdd3747ebe (patch) | |
tree | 620c69c2b6ea26b77b3a1c0892f5eabee0ae1c3e | |
parent | 93e6261db7a43b5ad50aade1742d3824e79c5ef1 (diff) | |
download | gstreamer-b566cbe0222439aad0c67b39161e6ffdd3747ebe.tar.gz |
queue2: Refuse all serialized queries when posting buffering messages
When posting buffering messages there are no safe places or timing to avoid
deadlocks.
Previously the code was trying to be "smart" by only forwarding serialized
queries if the queue was empty ... but that could happen when queue2 hadn't yet
posted a 100% buffering message. Meaning the pipeline might be paused and
pushing a serialized query downstream might never complete.
Therefore let's completely disable forwarding of serialized queries when
`queue2` is used as a buffering element (meaning `ALLOCATION` and `DRAIN`
queries).
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/797>
-rw-r--r-- | plugins/elements/gstqueue2.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c index cb230b31ad..894dd3042d 100644 --- a/plugins/elements/gstqueue2.c +++ b/plugins/elements/gstqueue2.c @@ -2783,10 +2783,14 @@ gst_queue2_handle_sink_query (GstPad * pad, GstObject * parent, * be pushed for sure) or we are not buffering. If we are buffering, * the pipeline waits to unblock downstream until our queue fills up * completely, which can not happen if we block on the query.. - * Therefore we only potentially block when we are not buffering. */ + * Therefore we only potentially block when we are not buffering. + * + * Update: Edward Hervey 2021: Realistically when posting buffering + * messages there are no safe places where we can block and forward a + * serialized query due to the potential of causing deadlocks. We + * therefore refuse any serialized queries in such cases. */ GST_QUEUE2_MUTEX_LOCK_CHECK (queue, queue->sinkresult, out_flushing); - if (QUEUE_IS_USING_QUEUE (queue) && (gst_queue2_is_empty (queue) - || !queue->use_buffering)) { + if (QUEUE_IS_USING_QUEUE (queue) && !queue->use_buffering) { if (!g_atomic_int_get (&queue->downstream_may_block)) { gst_queue2_locked_enqueue (queue, query, GST_QUEUE2_ITEM_TYPE_QUERY); @@ -2805,7 +2809,7 @@ gst_queue2_handle_sink_query (GstPad * pad, GstObject * parent, } } else { GST_DEBUG_OBJECT (queue, - "refusing query, we are not using the queue"); + "refusing query, we are not using the queue or we are posting buffering messages"); res = FALSE; } GST_QUEUE2_MUTEX_UNLOCK (queue); |