discoverer: Validate timeouts before processing them

This avoids a race where the timeout callback is scheduled to run but we
get sufficient information to finish discovery before actually getting
around to executing the callback. See the documentation of
g_source_is_destroyed() for more details.

https://bugzilla.gnome.org/show_bug.cgi?id=639730
This commit is contained in:
Arun Raghavan 2011-01-17 15:30:08 +05:30 committed by Tim-Philipp Müller
parent e730ce71dc
commit 65a298fdee

View file

@ -1153,12 +1153,14 @@ discoverer_bus_cb (GstBus * bus, GstMessage * msg, GstDiscoverer * dc)
static gboolean static gboolean
async_timeout_cb (GstDiscoverer * dc) async_timeout_cb (GstDiscoverer * dc)
{ {
dc->priv->timeoutid = 0; if (!g_source_is_destroyed (g_main_current_source ())) {
GST_DEBUG ("Setting result to TIMEOUT"); dc->priv->timeoutid = 0;
dc->priv->current_info->result = GST_DISCOVERER_TIMEOUT; GST_DEBUG ("Setting result to TIMEOUT");
dc->priv->processing = FALSE; dc->priv->current_info->result = GST_DISCOVERER_TIMEOUT;
discoverer_collect (dc); dc->priv->processing = FALSE;
discoverer_cleanup (dc); discoverer_collect (dc);
discoverer_cleanup (dc);
}
return FALSE; return FALSE;
} }