[glib/glib-2-52] gio: Drop redundant g_source_is_destroyed() calls



commit e4ce400e8f7fe8dee651058a12c8665f7280ae38
Author: Philip Withnall <withnall endlessm com>
Date:   Sun Feb 5 16:34:54 2017 +0100

    gio: Drop redundant g_source_is_destroyed() calls
    
    These calls cause race warnings from tsan, but are not a thread safety
    problem, because we can only ever observe single bit changes: all
    modifications to the GSource.flags field are done with a lock held; all
    reads are of independent fields, so no intermediate state can ever be
    observed. This assumes that a non-atomic read will consistently give us
    an old value or a new value.
    
    In any case, these g_source_is_destroyed() calls can happen from any
    thread, and the state could be changed from another thread immediately
    after the call returns; so the checks are pointless. In addition,
    calling g_source_set_ready_time() or g_source_destroy() on a destroyed
    source is not a problem.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778049

 gio/gcancellable.c |    3 +--
 gio/gsubprocess.c  |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index 2d09836..bda7910 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -650,8 +650,7 @@ cancellable_source_cancelled (GCancellable *cancellable,
 {
   GSource *source = user_data;
 
-  if (!g_source_is_destroyed (source))
-    g_source_set_ready_time (source, 0);
+  g_source_set_ready_time (source, 0);
 }
 
 static gboolean
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c
index 5fd5355..bec991c 100644
--- a/gio/gsubprocess.c
+++ b/gio/gsubprocess.c
@@ -1499,8 +1499,7 @@ g_subprocess_communicate_state_free (gpointer data)
 
   if (state->cancellable_source)
     {
-      if (!g_source_is_destroyed (state->cancellable_source))
-        g_source_destroy (state->cancellable_source);
+      g_source_destroy (state->cancellable_source);
       g_source_unref (state->cancellable_source);
     }
 


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