[tracker/tracker-1.10] libtracker-miner: Shuffle refcount handling when queueing back a file



commit ce55f8f8f96a091d1fb535994d47af9ec04f26ef
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Apr 16 11:58:00 2017 -0300

    libtracker-miner: Shuffle refcount handling when queueing back a file
    
    The file might or might not be inserted to the queue, which meant that
    the extra ref created outside the call might never dropped if the file
    didn't end up inserted again. Fix this by doing the refcount increase
    when actually inserting the file back in the queue.
    
    Reported by Jose M. Arroyo <jose m arroyo se gmail com>.

 src/libtracker-miner/tracker-miner-fs.c |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 65d7650..b71e82b 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2109,11 +2109,10 @@ should_wait (TrackerMinerFS *fs,
 }
 
 static gboolean
-item_reenqueue_full (TrackerMinerFS       *fs,
-                     TrackerPriorityQueue *item_queue,
-                     GFile                *queue_file,
-                     gpointer              queue_data,
-                     gint                  priority)
+item_enqueue_again (TrackerMinerFS       *fs,
+                    TrackerPriorityQueue *item_queue,
+                    GFile                *queue_file,
+                    gint                  priority)
 {
        gint reentry_counter;
        gchar *uri;
@@ -2126,7 +2125,7 @@ item_reenqueue_full (TrackerMinerFS       *fs,
                g_object_set_qdata (G_OBJECT (queue_file),
                                    fs->priv->quark_reentry_counter,
                                    GINT_TO_POINTER (reentry_counter + 1));
-               tracker_priority_queue_add (item_queue, queue_data, priority);
+               tracker_priority_queue_add (item_queue, g_object_ref (queue_file), priority);
 
                should_wait = TRUE;
        } else {
@@ -2147,15 +2146,6 @@ item_reenqueue_full (TrackerMinerFS       *fs,
        return should_wait;
 }
 
-static gboolean
-item_reenqueue (TrackerMinerFS       *fs,
-                TrackerPriorityQueue *item_queue,
-                GFile                *queue_file,
-                gint                  priority)
-{
-       return item_reenqueue_full (fs, item_queue, queue_file, queue_file, priority);
-}
-
 static QueueState
 item_queue_get_next_file (TrackerMinerFS  *fs,
                           GFile          **file,
@@ -2601,8 +2591,8 @@ item_queue_handlers_cb (gpointer user_data)
                         * ensured, tasks are inserted at a higher priority so they
                         * are processed promptly anyway.
                         */
-                       item_reenqueue (fs, item_queue, g_object_ref (parent), priority - 1);
-                       item_reenqueue (fs, item_queue, g_object_ref (file), priority);
+                       item_enqueue_again (fs, item_queue, parent, priority - 1);
+                       item_enqueue_again (fs, item_queue, file, priority);
 
                        keep_processing = TRUE;
                }


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