From f1a75073db939ca88ddaba2e7b16280ea68bbf21 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 14 Jun 2012 17:52:15 +0100 Subject: libtracker-miner: Avoid processing item queue while it is blocked item_add_or_update_cb() had a call to item_queue_handlers_set_up(). This was unneccessary as the queue will already be running, except in one the following cases: - the extraction or SPARQL task pools are full - the queue is blocked waiting for a specific file to process - the queue is empty Previously, while waiting for a file to process we might pop and reenqueue the next file in the queue several times, which is a waste of effort and makes it difficult to detect if the miner is stuck in an infinite loop. --- src/libtracker-miner/tracker-miner-fs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c index 45e1d0624..8cbf160d7 100644 --- a/src/libtracker-miner/tracker-miner-fs.c +++ b/src/libtracker-miner/tracker-miner-fs.c @@ -165,6 +165,7 @@ struct _TrackerMinerFSPrivate { GTimer *extraction_timer; guint item_queues_handler_id; + gboolean item_queue_blocked; gdouble throttle; @@ -1194,9 +1195,15 @@ item_add_or_update_cb (TrackerMinerFS *fs, ctxt->priority, sparql_buffer_task_finished_cb, fs); + + if (fs->priv->item_queue_blocked == TRUE) { + tracker_sparql_buffer_flush (fs->priv->sparql_buffer, "Queue handlers WAIT"); + } } - if (!tracker_task_pool_limit_reached (TRACKER_TASK_POOL (fs->priv->sparql_buffer))) { + if (tracker_miner_fs_has_items_to_process (fs) == FALSE && + tracker_task_pool_get_size (TRACKER_TASK_POOL (fs->priv->task_pool)) == 0) { + /* We need to run this one more time to trigger process_stop() */ item_queue_handlers_set_up (fs); } @@ -2028,9 +2035,12 @@ item_queue_handlers_cb (gpointer user_data) * on with the queues... */ tracker_sparql_buffer_flush (fs->priv->sparql_buffer, "Queue handlers WAIT"); + fs->priv->item_queue_blocked = TRUE; return FALSE; } + fs->priv->item_queue_blocked = FALSE; + if (file && queue != QUEUE_DELETED && tracker_file_is_locked (file)) { gchar *uri; -- cgit v1.2.1