[tracker-miners/wip/carlosg/writeback-race-condition: 30/30] tracker-miner-fs: Do not handle writeback file updates specially



commit be5f80dc0388255069fad3d7256fcdcca82f34fb
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Feb 18 16:03:23 2020 +0100

    tracker-miner-fs: Do not handle writeback file updates specially
    
    Currently, tracker-miner-fs expects an "updated" inotify event after
    returning from a PerformWriteback call, this typically meaning that
    tracker-writeback did it's job.
    
    This however may fail in 2 ways:
    - The related inotify event arrives before the PerformWriteback
      callback is called. If this happens, tracker-miner-fs will ignore
      it and await for an extra one that might never arrive. This was
      probably made much more likely to happen after commit 3bc295d2410,
      as all inotify events had a pretty high timeout.
    - The directory is not monitored at all, this may happen due to
      various reasons, like settings, or inotify handle/client limits.
    
    The outcome then is that the miner is left paused waiting for inotify
    events that may never arrive.
    
    Since it's not possible to ignore "writeback updates" in a non-racy
    manner, give it up and handle the file update as every other.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-music/issues/346

 src/miners/fs/tracker-miner-files.c | 25 -------------------------
 1 file changed, 25 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 52dbf25ce..ef4373f43 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -286,31 +286,10 @@ miner_files_filter_event (TrackerMinerFS          *fs,
                           GFile                   *source_file)
 {
        TrackerMinerFiles *mf = TRACKER_MINER_FILES (fs);
-       GCancellable *cancellable;
 
        switch (type) {
        case TRACKER_MINER_FS_EVENT_CREATED:
-               break;
        case TRACKER_MINER_FS_EVENT_UPDATED:
-               /* If the file is in the writeback task pool, this is the
-                * file update applying it, so the event should be filtered
-                * out.
-                */
-               if (g_hash_table_lookup_extended (mf->private->writeback_tasks, file,
-                                                 NULL, (gpointer*) &cancellable)) {
-                       if (!cancellable) {
-                               /* The task was already notified, we can remove
-                                * it now, so later updates will be processed.
-                                */
-                               g_hash_table_remove (mf->private->writeback_tasks, file);
-                               sync_writeback_pause_state (mf);
-                       }
-
-                       /* There is a writeback task, pending or satisfied.
-                        * Either way, this update should be ignored.
-                        */
-                       return TRUE;
-               }
                break;
        case TRACKER_MINER_FS_EVENT_DELETED:
                writeback_remove_recursively (mf, file);
@@ -3597,10 +3576,6 @@ tracker_miner_files_writeback_notify (TrackerMinerFiles *mf,
                g_free (uri);
        }
 
-       /* Drop the cancellable, it will be detected on the next file
-        * update in miner_files_filter_event().
-        */
        g_hash_table_steal (mf->private->writeback_tasks, file);
-       g_hash_table_insert (mf->private->writeback_tasks, file, NULL);
        g_object_unref (cancellable);
 }


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