[tracker/miner-fs-limit-requests: 6/7] libtracker-miner: avoid new extractions if requests limit reached



commit c7498661ab4b6826c685cbf6bf59505a1cc83d8b
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Mon Mar 21 10:03:20 2011 +0100

    libtracker-miner: avoid new extractions if requests limit reached

 .../tracker-miner-fs-processing-pool.c             |    2 +-
 .../tracker-miner-fs-processing-pool.h             |   71 ++++++++++----------
 src/libtracker-miner/tracker-miner-fs.c            |   12 +++-
 3 files changed, 48 insertions(+), 37 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs-processing-pool.c b/src/libtracker-miner/tracker-miner-fs-processing-pool.c
index 5e176a3..228b654 100644
--- a/src/libtracker-miner/tracker-miner-fs-processing-pool.c
+++ b/src/libtracker-miner/tracker-miner-fs-processing-pool.c
@@ -558,7 +558,7 @@ tracker_processing_pool_ready_limit_reached (TrackerProcessingPool *pool)
 	        TRUE : FALSE);
 }
 
-static gboolean
+gboolean
 tracker_processing_pool_n_requests_limit_reached (TrackerProcessingPool *pool)
 {
 	return (pool->n_requests >= pool->limit_n_requests ? TRUE : FALSE);
diff --git a/src/libtracker-miner/tracker-miner-fs-processing-pool.h b/src/libtracker-miner/tracker-miner-fs-processing-pool.h
index 956bf2c..076c485 100644
--- a/src/libtracker-miner/tracker-miner-fs-processing-pool.h
+++ b/src/libtracker-miner/tracker-miner-fs-processing-pool.h
@@ -59,41 +59,42 @@ void                   tracker_processing_task_set_bulk_operation (TrackerProces
 
 /* Processing Pool API */
 
-TrackerProcessingPool *tracker_processing_pool_new                   (TrackerMinerFS          *miner,
-                                                                      guint                    limit_wait,
-                                                                      guint                    limit_process,
-                                                                      guint                    limit_n_requests);
-void                   tracker_processing_pool_free                  (TrackerProcessingPool   *pool);
-void                   tracker_processing_pool_set_wait_limit        (TrackerProcessingPool   *pool,
-                                                                      guint                    limit);
-void                   tracker_processing_pool_set_ready_limit       (TrackerProcessingPool   *pool,
-                                                                      guint                    limit);
-void                   tracker_processing_pool_set_n_requests_limit  (TrackerProcessingPool   *pool,
-                                                                      guint                    limit);
-guint                  tracker_processing_pool_get_wait_limit        (TrackerProcessingPool   *pool);
-guint                  tracker_processing_pool_get_ready_limit       (TrackerProcessingPool   *pool);
-guint                  tracker_processing_pool_get_n_requests_limit  (TrackerProcessingPool   *pool);
-TrackerProcessingTask *tracker_processing_pool_find_task             (TrackerProcessingPool   *pool,
-                                                                      GFile                   *file,
-                                                                      gboolean                 path_search);
-gboolean               tracker_processing_pool_wait_limit_reached    (TrackerProcessingPool   *pool);
-void                   tracker_processing_pool_remove_task           (TrackerProcessingPool   *pool,
-                                                                      TrackerProcessingTask   *task);
-void                   tracker_processing_pool_push_wait_task        (TrackerProcessingPool   *pool,
-                                                                      TrackerProcessingTask   *task);
-gboolean               tracker_processing_pool_push_ready_task       (TrackerProcessingPool   *pool,
-                                                                      TrackerProcessingTask   *task,
-                                                                      TrackerProcessingPoolTaskFinishedCallback finished_handler,
-                                                                      gpointer                 user_data);
-guint                  tracker_processing_pool_get_n_requests        (TrackerProcessingPool   *pool);
-guint                  tracker_processing_pool_get_wait_task_count   (TrackerProcessingPool   *pool);
-guint                  tracker_processing_pool_get_total_task_count  (TrackerProcessingPool   *pool);
-TrackerProcessingTask *tracker_processing_pool_get_last_wait         (TrackerProcessingPool   *pool);
-void                   tracker_processing_pool_foreach               (TrackerProcessingPool   *pool,
-                                                                      GFunc                    func,
-                                                                      gpointer                 user_data);
-void                   tracker_processing_pool_buffer_flush          (TrackerProcessingPool   *pool,
-                                                                      const gchar             *reason);
+TrackerProcessingPool *tracker_processing_pool_new                      (TrackerMinerFS          *miner,
+                                                                         guint                    limit_wait,
+                                                                         guint                    limit_process,
+                                                                         guint                    limit_n_requests);
+void                   tracker_processing_pool_free                     (TrackerProcessingPool   *pool);
+void                   tracker_processing_pool_set_wait_limit           (TrackerProcessingPool   *pool,
+                                                                         guint                    limit);
+void                   tracker_processing_pool_set_ready_limit          (TrackerProcessingPool   *pool,
+                                                                         guint                    limit);
+void                   tracker_processing_pool_set_n_requests_limit     (TrackerProcessingPool   *pool,
+                                                                         guint                    limit);
+guint                  tracker_processing_pool_get_wait_limit           (TrackerProcessingPool   *pool);
+guint                  tracker_processing_pool_get_ready_limit          (TrackerProcessingPool   *pool);
+guint                  tracker_processing_pool_get_n_requests_limit     (TrackerProcessingPool   *pool);
+TrackerProcessingTask *tracker_processing_pool_find_task                (TrackerProcessingPool   *pool,
+                                                                         GFile                   *file,
+                                                                         gboolean                 path_search);
+gboolean               tracker_processing_pool_wait_limit_reached       (TrackerProcessingPool   *pool);
+gboolean               tracker_processing_pool_n_requests_limit_reached (TrackerProcessingPool   *pool);
+void                   tracker_processing_pool_remove_task              (TrackerProcessingPool   *pool,
+                                                                         TrackerProcessingTask   *task);
+void                   tracker_processing_pool_push_wait_task           (TrackerProcessingPool   *pool,
+                                                                         TrackerProcessingTask   *task);
+gboolean               tracker_processing_pool_push_ready_task          (TrackerProcessingPool   *pool,
+                                                                         TrackerProcessingTask   *task,
+                                                                         TrackerProcessingPoolTaskFinishedCallback finished_handler,
+                                                                         gpointer                 user_data);
+guint                  tracker_processing_pool_get_n_requests           (TrackerProcessingPool   *pool);
+guint                  tracker_processing_pool_get_wait_task_count      (TrackerProcessingPool   *pool);
+guint                  tracker_processing_pool_get_total_task_count     (TrackerProcessingPool   *pool);
+TrackerProcessingTask *tracker_processing_pool_get_last_wait            (TrackerProcessingPool   *pool);
+void                   tracker_processing_pool_foreach                  (TrackerProcessingPool   *pool,
+                                                                         GFunc                    func,
+                                                                         gpointer                 user_data);
+void                   tracker_processing_pool_buffer_flush             (TrackerProcessingPool   *pool,
+                                                                         const gchar             *reason);
 
 G_END_DECLS
 
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 972be0c..e0dff01 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2840,8 +2840,18 @@ item_queue_handlers_set_up (TrackerMinerFS *fs)
 		return;
 	}
 
+	/* Already sent max number of tasks to tracker-extract? */
 	if (tracker_processing_pool_wait_limit_reached (fs->private->processing_pool)) {
-		/* There is no room in the pool for more files */
+		return;
+	}
+
+	/* Already sent max number of requests to tracker-store?
+	 * In this case, we also slow down the processing of items, as we don't
+	 * want to keep on extracting if the communication with tracker-store is
+	 * very busy. Note that this is not very likely to happen, as the bottleneck
+	 * during extraction is not the communication with tracker-store.
+	 */
+	if (tracker_processing_pool_n_requests_limit_reached (fs->private->processing_pool)) {
 		return;
 	}
 



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