After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 549504 - Thread-safe version of gst_pad_get_internal_links()
Thread-safe version of gst_pad_get_internal_links()
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 0.10.21
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-08-26 20:37 UTC by Olivier Crête
Modified: 2008-09-01 11:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add gst_pad_iterate_internal_links() (17.93 KB, patch)
2008-08-26 20:38 UTC, Olivier Crête
reviewed Details | Review
slightly updated version to deal with parent-less pads (18.07 KB, patch)
2008-08-28 19:38 UTC, Olivier Crête
none Details | Review
Separate first part: Implement gst_pad_iterate_internal_links() (12.10 KB, patch)
2008-08-30 00:15 UTC, Olivier Crête
committed Details | Review
Part 2: Use _iterate_internal_links() to push events/queries (6.00 KB, patch)
2008-08-30 00:19 UTC, Olivier Crête
committed Details | Review

Description Olivier Crête 2008-08-26 20:37:55 UTC
gst_pad_get_internal_links() is not thread safe. If pads are removed from a running element (like a tee), it can cause a crash when it tries to push an event onto a no-longer-existing pad.

I propose adding a gst_pad_iterate_internal_links() that returns a GstIterator* and is thread-safe.

I'm attaching a sample implementation.
Comment 1 Olivier Crête 2008-08-26 20:38:54 UTC
Created attachment 117422 [details] [review]
Add gst_pad_iterate_internal_links()
Comment 2 Wim Taymans 2008-08-28 15:44:02 UTC
This looks like a good thing to do and it seems possible to implement without breaking too much API.
Comment 3 Olivier Crête 2008-08-28 19:38:39 UTC
Created attachment 117546 [details] [review]
slightly updated version to deal with parent-less pads

_iterate_internal_links() returns NULL if the parent is not an element, the previous version of the patch crashed on that case, new patch doesn't.
Comment 4 Olivier Crête 2008-08-30 00:15:40 UTC
Created attachment 117611 [details] [review]
Separate first part: Implement gst_pad_iterate_internal_links()
Comment 5 Olivier Crête 2008-08-30 00:19:02 UTC
Created attachment 117612 [details] [review]
Part 2: Use _iterate_internal_links() to push events/queries

As requested, here are the separated patches. The first implements the new method, with the fallback (as well as the gstghostpad part). The second uses it to dispatch events and queries.

Also, I haven't implemented it in the elements that return a static list of pads on the query (I believe all elements that currently implement it do that), because there is no threading issue there.
Comment 6 Wim Taymans 2008-09-01 10:43:44 UTC
I slightly changed the _iterate_internal_links_default() function so that it does not keep a pad-local GList. Also added some comments.

        Based on patch by: Olivier Crete <tester at tester dot ca>

        * docs/gst/gstreamer-sections.txt:
        * win32/common/libgstreamer.def:
        * gst/gstpad.c: (gst_pad_init),
        (gst_pad_set_iterate_internal_links_function),
        (int_link_iter_data_free), (iterate_pad),
        (gst_pad_iterate_internal_links_default),
        (gst_pad_iterate_internal_links), (gst_pad_get_internal_links):
        * gst/gstpad.h:
        Add threadsafe replacement functions for getting internal links of an
        element. Deprecate the old internal links functions.
        API:GstPad::gst_pad_set_iterate_internal_links_function()
        API:GstPad::GstPadIterIntLinkFunction
        API:GstPad::gst_pad_iterate_internal_links()
        API:GstPad::gst_pad_iterate_internal_links_default()

        * gst/gstghostpad.c: (gst_proxy_pad_do_iterate_internal_links),
        (gst_proxy_pad_init):
        Implement threadsafe internal links.

        * tests/check/elements/tee.c: (GST_START_TEST), (tee_suite):
        Unit test for internal links on tee. See #549504.
Comment 7 Wim Taymans 2008-09-01 11:29:58 UTC
        Patch by: Olivier Crete <tester at tester dot ca>

        * gst/gstpad.c: (gst_pad_iterate_internal_links_default),
        (gst_pad_event_default_dispatch), (gst_pad_dispatcher):
        Use thread-safe internal links iterator. Fixes #549504.