[tracker/tracker-0.10] libtracker-miner: Cancel TrackerMinerFS cancellables on finalize()



commit 85080d1ce23cdf4af5a7a878e9e9b1197c635bed
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 6 11:55:17 2011 +0200

    libtracker-miner: Cancel TrackerMinerFS cancellables on finalize()
    
    This also gets rid of a related comment in TrackerMinerFiles, since
    the cancellables there are those that TrackerMinerFS create.

 src/libtracker-miner/tracker-miner-fs.c |   13 +++++++++++--
 src/miners/fs/tracker-miner-files.c     |   11 -----------
 2 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 6f7c607..ebcb588 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -354,6 +354,10 @@ static void           tracker_miner_fs_directory_add_internal (TrackerMinerFS *f
 static gboolean       miner_fs_has_children_without_parent (TrackerMinerFS *fs,
                                                             GFile          *file);
 
+static void           processing_pool_cancel_foreach          (gpointer        data,
+                                                               gpointer        user_data);
+
+
 static guint signals[LAST_SIGNAL] = { 0, };
 
 G_DEFINE_ABSTRACT_TYPE (TrackerMinerFS, tracker_miner_fs, TRACKER_TYPE_MINER)
@@ -776,6 +780,10 @@ fs_finalize (GObject *object)
 	g_queue_foreach (priv->crawled_directories, (GFunc) crawled_directory_data_free, NULL);
 	g_queue_free (priv->crawled_directories);
 
+	/* Cancel every pending task */
+	tracker_processing_pool_foreach (priv->processing_pool,
+	                                 processing_pool_cancel_foreach,
+	                                 NULL);
 	tracker_processing_pool_free (priv->processing_pool);
 
 	g_queue_foreach (priv->items_moved, (GFunc) item_moved_data_free, NULL);
@@ -4018,8 +4026,9 @@ processing_pool_cancel_foreach (gpointer data,
 
 	if (ctxt &&
 	    ctxt->cancellable &&
-	    (g_file_equal (task_file, file) ||
-	     g_file_has_prefix (task_file, file))) {
+	    (!file ||
+	     (g_file_equal (task_file, file) ||
+	      g_file_has_prefix (task_file, file)))) {
 		g_cancellable_cancel (ctxt->cancellable);
 	}
 }
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 4a5db89..3c28616 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2040,17 +2040,6 @@ extractor_get_embedded_metadata_cancel (GCancellable    *cancellable,
 {
 	GError *error;
 
-	/* TODO: Cancel extractor call
-	 * We should cancel all of these on finalize()
-	 *
-	 * NOTE: We currently don't call g_cancellable_cancel() so
-	 * this is here just in the event that we may at some point.
-	 * It's likely the only time this would happen is during
-	 * finalize(). This is also why we don't close the (what
-	 * should be) currently open sparql builder like we do on
-	 * error in extractor_skip_embedded_metadata_cb().
-	 */
-
 	error = g_error_new_literal (miner_files_error_quark, 0,
 	                             "Embedded metadata extraction was cancelled");
 	tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);



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