[tracker/miner-priority-queues: 18/22] libtracker-miner: Ensure harder process_stop() is only called once



commit 3194a69f6bc2560c9363dde48faea4f918b23df7
Author: Carlos Garnacho <carlos lanedo com>
Date:   Wed Jul 6 16:56:38 2011 +0200

    libtracker-miner: Ensure harder process_stop() is only called once
    
    QUEUE_WAIT is now used more extensively, meaning item_queue_handlers_cb()
    onky gets QUEUE_NONE if there really is nothing left to process, be it
    items in the task pool, pending to be crawled, or in the processing queues.

 src/libtracker-miner/tracker-miner-fs.c |   37 +++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 11 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index eb778ae..2fca0e5 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2655,6 +2655,18 @@ item_queue_get_next_file (TrackerMinerFS  *fs,
 	*file = NULL;
 	*source_file = NULL;
 
+	if (fs->priv->is_crawling ||
+	    fs->priv->crawl_directories_id != 0 ||
+	    !tracker_priority_queue_is_empty (fs->priv->crawled_directories) ||
+	    !tracker_priority_queue_is_empty (fs->priv->directories) ||
+	    tracker_task_pool_limit_reached (fs->priv->task_pool) ||
+	    tracker_task_pool_limit_reached (TRACKER_TASK_POOL (fs->priv->sparql_buffer))) {
+		/* There are still pending items to crawl,
+		 * or extract pool limit is reached
+		 */
+		return QUEUE_WAIT;
+	}
+
 	return QUEUE_NONE;
 }
 
@@ -2840,19 +2852,21 @@ item_queue_handlers_cb (gpointer user_data)
 	/* Handle queues */
 	switch (queue) {
 	case QUEUE_NONE:
-		/* Print stats and signal finished */
 		if (!fs->priv->is_crawling &&
-		    tracker_task_pool_get_size (fs->priv->task_pool) == 0 &&
-		    tracker_task_pool_get_size (TRACKER_TASK_POOL (fs->priv->sparql_buffer)) == 0) {
-			process_stop (fs);
-		}
+		    tracker_task_pool_get_size (fs->priv->task_pool) == 0) {
+			if (tracker_task_pool_get_size (TRACKER_TASK_POOL (fs->priv->sparql_buffer)) == 0) {
+				/* Print stats and signal finished */
+				process_stop (fs);
 
-		/* Flush any possible pending update here */
-		tracker_sparql_buffer_flush (fs->priv->sparql_buffer,
-		                             "Queue handlers NONE");
+				tracker_thumbnailer_send ();
+				tracker_albumart_check_cleanup (tracker_miner_get_connection (TRACKER_MINER (fs)));
+			} else {
+				/* Flush any possible pending update here */
+				tracker_sparql_buffer_flush (fs->priv->sparql_buffer,
+				                             "Queue handlers NONE");
+			}
+		}
 
-		tracker_thumbnailer_send ();
-		tracker_albumart_check_cleanup (tracker_miner_get_connection (TRACKER_MINER (fs)));
 		/* No more files left to process */
 		keep_processing = FALSE;
 		break;
@@ -4999,7 +5013,8 @@ tracker_miner_fs_has_items_to_process (TrackerMinerFS *fs)
 {
 	g_return_val_if_fail (TRACKER_IS_MINER_FS (fs), FALSE);
 
-	if (!tracker_priority_queue_is_empty (fs->priv->items_deleted) ||
+	if (!tracker_priority_queue_is_empty (fs->priv->crawled_directories) ||
+	    !tracker_priority_queue_is_empty (fs->priv->items_deleted) ||
 	    !tracker_priority_queue_is_empty (fs->priv->items_created) ||
 	    !tracker_priority_queue_is_empty (fs->priv->items_updated) ||
 	    !tracker_priority_queue_is_empty (fs->priv->items_moved)) {



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