[glib] inotify: Fix handling of paired events for atomic replace



commit ac78d14125a39f1677a5a5d77bb8ab4cb5f2d3c9
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Aug 19 07:10:01 2015 -0400

    inotify: Fix handling of paired events for atomic replace
    
    After the big file monitoring rewrite, we only put the IN_MOVED_FROM event
    in the queue for such pairs. It matches INOTIFY_DIR_MASK and thus we call
    ip_dispatch_event on it, but that function was filtering it out because
    the filename in the 'from' event is the one of the temp file, not the
    one we are monitoring. That name is in the 'to' event, so compare it as
    well, and let the event passin that case.
    
    There is another instance of this check in glocalfilemonitor.c, which is
    corrected here as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751358

 gio/glocalfilemonitor.c    |    4 ++--
 gio/inotify/inotify-path.c |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index dcd39cf..62d269c 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -344,7 +344,8 @@ g_file_monitor_source_handle_event (GFileMonitorSource *fms,
   g_assert (!child || is_basename (child));
   g_assert (!rename_to || is_basename (rename_to));
 
-  if (fms->basename && (!child || !g_str_equal (child, fms->basename)))
+  if (fms->basename && (!child || !g_str_equal (child, fms->basename))
+                    && (!rename_to || !g_str_equal (rename_to, fms->basename)))
     return TRUE;
 
   g_mutex_lock (&fms->lock);
@@ -408,7 +409,6 @@ g_file_monitor_source_handle_event (GFileMonitorSource *fms,
 
           other = g_local_file_new_from_dirname_and_basename (fms->dirname, rename_to);
           g_file_monitor_source_file_changes_done (fms, rename_to);
-          g_print ("send %s %s\n", child, g_file_get_path (other));
           g_file_monitor_source_send_event (fms, G_FILE_MONITOR_EVENT_MOVED, child, other);
           g_object_unref (other);
         }
diff --git a/gio/inotify/inotify-path.c b/gio/inotify/inotify-path.c
index c27ed4a..ec1d486 100644
--- a/gio/inotify/inotify-path.c
+++ b/gio/inotify/inotify-path.c
@@ -463,7 +463,8 @@ ip_event_dispatch (GList      *dir_list,
           */
          if (sub->filename &&
              event->name &&
-             strcmp (sub->filename, event->name))
+             strcmp (sub->filename, event->name) &&
+              (!event->pair || !event->pair->name || strcmp (sub->filename, event->pair->name)))
            continue;
          
          /* If the subscription has a filename


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