mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 20:51:13 +00:00
bus: Make removing of signal/bus watches thread-safe
Between getting the GSource with the mutex and destroying it, something else might've destroyed it already and we would have a dangling pointer. Keep an additional reference just in case.
This commit is contained in:
parent
8de3344ecc
commit
2108c6228a
1 changed files with 12 additions and 5 deletions
17
gst/gstbus.c
17
gst/gstbus.c
|
@ -1044,7 +1044,7 @@ gst_bus_add_watch (GstBus * bus, GstBusFunc func, gpointer user_data)
|
|||
gboolean
|
||||
gst_bus_remove_watch (GstBus * bus)
|
||||
{
|
||||
GSource *watch_id;
|
||||
GSource *source;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUS (bus), FALSE);
|
||||
|
||||
|
@ -1061,11 +1061,15 @@ gst_bus_remove_watch (GstBus * bus)
|
|||
goto error;
|
||||
}
|
||||
|
||||
watch_id = bus->priv->signal_watch;
|
||||
source =
|
||||
bus->priv->signal_watch ? g_source_ref (bus->priv->signal_watch) : NULL;
|
||||
|
||||
GST_OBJECT_UNLOCK (bus);
|
||||
|
||||
g_source_destroy (watch_id);
|
||||
if (source) {
|
||||
g_source_destroy (source);
|
||||
g_source_unref (source);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -1459,13 +1463,16 @@ gst_bus_remove_signal_watch (GstBus * bus)
|
|||
GST_DEBUG_OBJECT (bus, "removing signal watch %u",
|
||||
g_source_get_id (bus->priv->signal_watch));
|
||||
|
||||
source = bus->priv->signal_watch;
|
||||
source =
|
||||
bus->priv->signal_watch ? g_source_ref (bus->priv->signal_watch) : NULL;
|
||||
|
||||
done:
|
||||
GST_OBJECT_UNLOCK (bus);
|
||||
|
||||
if (source)
|
||||
if (source) {
|
||||
g_source_destroy (source);
|
||||
g_source_unref (source);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue