udpsrc: protect cancellable from unlock/unlock_stop race

Protect cancellable from simultaneous unlock and unlock_stop calls from
basesrc class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7885>
This commit is contained in:
Robert Rosengren 2024-11-13 15:49:57 +01:00 committed by GStreamer Marge Bot
parent 591ddfe203
commit ff14e1a9e3

View file

@ -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;
}