From ff14e1a9e3d204b24ae13fcb3a384b08804ab6f0 Mon Sep 17 00:00:00 2001 From: Robert Rosengren Date: Wed, 13 Nov 2024 15:49:57 +0100 Subject: [PATCH] udpsrc: protect cancellable from unlock/unlock_stop race Protect cancellable from simultaneous unlock and unlock_stop calls from basesrc class. Part-of: --- subprojects/gst-plugins-good/gst/udp/gstudpsrc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/udp/gstudpsrc.c b/subprojects/gst-plugins-good/gst/udp/gstudpsrc.c index 96cdcf778d..10fa5fc7f5 100644 --- a/subprojects/gst-plugins-good/gst/udp/gstudpsrc.c +++ b/subprojects/gst-plugins-good/gst/udp/gstudpsrc.c @@ -932,8 +932,7 @@ gst_udpsrc_free_cancellable (GstUDPSrc * src) g_cancellable_release_fd (src->cancellable); src->made_cancel_fd = FALSE; } - g_object_unref (src->cancellable); - src->cancellable = NULL; + g_clear_object (&src->cancellable); } static GstFlowReturn @@ -1954,7 +1953,9 @@ gst_udpsrc_unlock (GstBaseSrc * bsrc) src = GST_UDPSRC (bsrc); GST_LOG_OBJECT (src, "Flushing"); + GST_OBJECT_LOCK (src); g_cancellable_cancel (src->cancellable); + GST_OBJECT_UNLOCK (src); return TRUE; } @@ -1968,8 +1969,10 @@ gst_udpsrc_unlock_stop (GstBaseSrc * bsrc) GST_LOG_OBJECT (src, "No longer flushing"); + GST_OBJECT_LOCK (src); gst_udpsrc_free_cancellable (src); gst_udpsrc_create_cancellable (src); + GST_OBJECT_UNLOCK (src); return TRUE; }