[tracker] libtracker-miner: Fix crash when USB removed during crawl



commit 69692ec9fc05b8c27f583c5d946f95141260e031
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Wed May 16 19:35:15 2012 +0900

    libtracker-miner: Fix crash when USB removed during crawl
    
    In tracker-file-notifier.c:indexing_tree_directory_removed() we don't
    remove the directory from priv->pending_index_roots, unless it's the
    current indexing root.
    
    If it's a USB mountpoint, the GFile gets freed before we get around to
    crawling it, so all hell breaks loose.
    
    Fixes GB#676153.

 src/libtracker-miner/tracker-crawler.c       |    3 +++
 src/libtracker-miner/tracker-file-notifier.c |   25 ++++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-crawler.c b/src/libtracker-miner/tracker-crawler.c
index ff3ac51..c034204 100644
--- a/src/libtracker-miner/tracker-crawler.c
+++ b/src/libtracker-miner/tracker-crawler.c
@@ -851,6 +851,9 @@ tracker_crawler_start (TrackerCrawler *crawler,
 	priv = crawler->priv;
 
 	if (!g_file_query_exists (file, NULL)) {
+		/* This shouldn't happen, unless the removal/unmount notification
+		 * didn't yet reach the TrackerFileNotifier.
+		 */
 		return FALSE;
 	}
 
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 5d416a6..510f64b 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -565,6 +565,7 @@ crawl_directories_start (TrackerFileNotifier *notifier)
 
 	while (priv->pending_index_roots) {
 		directory = priv->pending_index_roots->data;
+
 		tracker_indexing_tree_get_root (priv->indexing_tree,
 		                                directory,
 		                                &flags);
@@ -1065,16 +1066,22 @@ indexing_tree_directory_removed (TrackerIndexingTree *indexing_tree,
 		g_signal_emit (notifier, signals[FILE_DELETED], 0, directory);
 	}
 
-	if (priv->pending_index_roots &&
-	    directory == priv->pending_index_roots->data) {
-		/* Directory being currently processed */
-		tracker_crawler_stop (priv->crawler);
-		g_cancellable_cancel (priv->cancellable);
+	if (priv->pending_index_roots) {
+		gboolean start_crawler = FALSE;
 
-		/* Remove index root and try the next one */
-		priv->pending_index_roots = g_list_delete_link (priv->pending_index_roots,
-		                                                priv->pending_index_roots);
-		crawl_directories_start (notifier);
+		if (directory == priv->pending_index_roots->data) {
+			/* Directory being currently processed */
+			tracker_crawler_stop (priv->crawler);
+			g_cancellable_cancel (priv->cancellable);
+			start_crawler = TRUE;
+		}
+
+		priv->pending_index_roots = g_list_remove_all (priv->pending_index_roots,
+		                                               directory);
+
+		if (start_crawler && priv->pending_index_roots != NULL) {
+			crawl_directories_start (notifier);
+		}
 	}
 
 	/* Remove monitors if any */



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