[gnome-builder] egg-task-cache: handle cancelled tasks when freeing cancelled state



commit 8bb871eca2bf38013263f7631f833f70bb57759d
Author: Christian Hergert <chergert redhat com>
Date:   Mon Mar 6 14:22:28 2017 -0800

    egg-task-cache: handle cancelled tasks when freeing cancelled state
    
    If we reached this via the cancellation of the task (and then free'ing of
    the GTask), then we shouldn't try to disconnect or we'll dead-lock.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779660

 contrib/egg/egg-task-cache.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/contrib/egg/egg-task-cache.c b/contrib/egg/egg-task-cache.c
index 8dc8540..3a9f602 100644
--- a/contrib/egg/egg-task-cache.c
+++ b/contrib/egg/egg-task-cache.c
@@ -235,9 +235,13 @@ cancelled_data_free (gpointer data)
 
   g_clear_pointer (&cancelled->key, cancelled->self->key_destroy_func);
 
-  g_cancellable_disconnect (cancelled->cancellable, cancelled->cancelled_id);
-  g_clear_object (&cancelled->cancellable);
-  cancelled->cancelled_id = 0;
+  if (cancelled->cancelled_id != 0)
+    {
+      g_cancellable_disconnect (cancelled->cancellable, cancelled->cancelled_id);
+      cancelled->cancelled_id = 0;
+
+      g_clear_object (&cancelled->cancellable);
+    }
 
   cancelled->self = NULL;
 
@@ -477,6 +481,8 @@ egg_task_cache_cancelled_cb (GCancellable *cancellable,
   self = (EggTaskCache *)g_task_get_source_object (task);
   data = (CancelledData *)g_task_get_task_data (task);
 
+  data->cancelled_id = 0;
+
   if ((queued = g_hash_table_lookup (self->queued, data->key)))
     {
       gsize i;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]