[glib: 5/9] glocalfilemonitor: Fix data race in local file monitor



commit 6336864171d0d14297de5af2aba0a5de00a8d257
Author: Tomasz Miąsko <tomasz miasko gmail com>
Date:   Fri Feb 22 00:00:00 2019 +0000

    glocalfilemonitor: Fix data race in local file monitor
    
    Ensure that source is attached to the context before it migth be used
    from another thread, since otherwise operation on source are
    unsynchronized and not thread-safe.
    
    In particular there was a data race between g_source_attach and
    g_source_set_ready_time (used from g_file_monitor_source_handle_event).

 gio/glocalfilemonitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index 8a4c4ec43..278d9a492 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -788,11 +788,11 @@ g_local_file_monitor_start (GLocalFileMonitor *local_monitor,
 #endif
     }
 
+  g_source_attach ((GSource *) source, context);
+
   G_LOCAL_FILE_MONITOR_GET_CLASS (local_monitor)->start (local_monitor,
                                                          source->dirname, source->basename, source->filename,
                                                          source);
-
-  g_source_attach ((GSource *) source, context);
 }
 
 static void


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