diff options
author | Alexander Schrab <alexas@axis.com> | 2013-04-10 11:06:52 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2013-04-10 10:36:19 +0100 |
commit | 3320f29a88df3a90aa4556fca5f08a738f34a8c9 (patch) | |
tree | 0f25f53688800fded7575f7bc15abf0a02220c34 /gst/debugutils | |
parent | 4a9c3d4f163a558eecd0f2d1f6685af8139ac2ce (diff) | |
download | gstreamer-plugins-bad-3320f29a88df3a90aa4556fca5f08a738f34a8c9.tar.gz |
watchdog: race between g_main_loop_run/_quit fixed
https://bugzilla.gnome.org/show_bug.cgi?id=697694
Diffstat (limited to 'gst/debugutils')
-rw-r--r-- | gst/debugutils/gstwatchdog.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/gst/debugutils/gstwatchdog.c b/gst/debugutils/gstwatchdog.c index 3f245f6a9..bbc903a1c 100644 --- a/gst/debugutils/gstwatchdog.c +++ b/gst/debugutils/gstwatchdog.c @@ -228,6 +228,18 @@ gst_watchdog_trigger (gpointer ptr) return FALSE; } +static gboolean +gst_watchdog_quit_mainloop (gpointer ptr) +{ + GstWatchdog *watchdog = GST_WATCHDOG (ptr); + + GST_DEBUG_OBJECT (watchdog, "watchdog quit"); + + g_main_loop_quit (watchdog->main_loop); + + return FALSE; +} + static void gst_watchdog_feed (GstWatchdog * watchdog) { @@ -260,6 +272,7 @@ static gboolean gst_watchdog_stop (GstBaseTransform * trans) { GstWatchdog *watchdog = GST_WATCHDOG (trans); + GSource *quit_source; GST_DEBUG_OBJECT (watchdog, "stop"); @@ -268,7 +281,15 @@ gst_watchdog_stop (GstBaseTransform * trans) g_source_unref (watchdog->source); watchdog->source = NULL; } - g_main_loop_quit (watchdog->main_loop); + + /* dispatch an idle event that trigger g_main_loop_quit to avoid race + * between g_main_loop_run and g_main_loop_quit */ + quit_source = g_idle_source_new (); + g_source_set_callback (quit_source, gst_watchdog_quit_mainloop, watchdog, + NULL); + g_source_attach (quit_source, watchdog->main_context); + g_source_unref (quit_source); + g_thread_join (watchdog->thread); g_main_loop_unref (watchdog->main_loop); g_main_context_unref (watchdog->main_context); |