inputselector: Avoid deadlock when requesting pads

The deadlock was the following:
* One thread requests a new pad, the internal lock is kept while adding the pad
* Another thread (or the same one) requests the internal links of a pad (could
be that pad)... which also requires that lock.

That internal lock is not required when adding the pad to the element (which is
the last action when requesting a new pad). The fact it will be actually used
will be *after* the request pad function is released.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/512>
This commit is contained in:
Edward Hervey 2020-06-03 08:09:04 +02:00 committed by GStreamer Merge Bot
parent cc87357105
commit f2478618b5

View file

@ -1813,8 +1813,8 @@ gst_input_selector_request_new_pad (GstElement * element,
GST_OBJECT_FLAG_SET (sinkpad, GST_PAD_FLAG_PROXY_CAPS);
GST_OBJECT_FLAG_SET (sinkpad, GST_PAD_FLAG_PROXY_ALLOCATION);
gst_pad_set_active (sinkpad, TRUE);
gst_element_add_pad (GST_ELEMENT (sel), sinkpad);
GST_INPUT_SELECTOR_UNLOCK (sel);
gst_element_add_pad (GST_ELEMENT (sel), sinkpad);
return sinkpad;
}