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



commit 32300874b724e237e63ca509a2176be9d654bd62
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 |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 1d57621..e948906 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2714,6 +2714,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_sparql_buffer_tasks_pending (fs->priv->sparql_buffer)) {
+		/* There are still pending items to crawl,
+		 * or extract pool limit is reached
+		 */
+		return QUEUE_WAIT;
+	}
+
 	return QUEUE_NONE;
 }
 
@@ -2899,17 +2911,18 @@ item_queue_handlers_cb (gpointer user_data)
 	/* Handle queues */
 	switch (queue) {
 	case QUEUE_NONE:
+		/* Flush any possible pending update here */
+		tracker_sparql_buffer_flush (fs->priv->sparql_buffer,
+		                             "Queue handlers NONE");
+
 		/* Print stats and signal finished */
 		if (!fs->priv->is_crawling &&
+		    !tracker_miner_fs_has_items_to_process (fs) &&
 		    tracker_task_pool_get_size (fs->priv->task_pool) == 0 &&
-		    tracker_task_pool_get_size (TRACKER_TASK_POOL (fs->priv->sparql_buffer)) == 0) {
+		    !tracker_sparql_buffer_tasks_pending (fs->priv->sparql_buffer)) {
 			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)));
 		/* No more files left to process */
@@ -5066,7 +5079,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]