tracker r3015 - in trunk: . src/libtracker-db src/tracker-indexer



Author: carlosg
Date: Wed Mar  4 11:47:42 2009
New Revision: 3015
URL: http://svn.gnome.org/viewvc/tracker?rev=3015&view=rev

Log:
2009-03-04  Carlos Garnacho  <carlos imendio com>

        * src/libtracker-db/tracker-db-index.c (index_flush_item)
        (tracker_db_index_flush): Prevent against cur_cache being possibly
        NULL.
        * src/tracker-indexer/tracker-indexer.c (check_finished)
        (check_stopped): Call check_finished() in any case, not just after the
        cache has been flushed.

Modified:
   trunk/ChangeLog
   trunk/src/libtracker-db/tracker-db-index.c
   trunk/src/tracker-indexer/tracker-indexer.c

Modified: trunk/src/libtracker-db/tracker-db-index.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-index.c	(original)
+++ trunk/src/libtracker-db/tracker-db-index.c	Wed Mar  4 11:47:42 2009
@@ -784,7 +784,7 @@
 		return FALSE;
 	}
 
-	if (g_hash_table_size (priv->cache_layers->data) > 0) {
+	if (priv->cache_layers && g_hash_table_size (priv->cache_layers->data) > 0) {
 		GTimer *timer;
 
 		timer = g_timer_new ();
@@ -807,13 +807,15 @@
 	} else {
 		GList *link;
 
-		/* Current cache being flushed is already empty, proceed with the next one */
-		link = priv->cache_layers;
-		priv->cache_layers = g_list_remove_link (priv->cache_layers, link);
-		g_hash_table_destroy (link->data);
-		g_list_free_1 (link);
+		if (priv->cache_layers) {
+			/* Current cache being flushed is already empty, proceed with the next one */
+			link = priv->cache_layers;
+			priv->cache_layers = g_list_remove_link (priv->cache_layers, link);
+			g_hash_table_destroy (link->data);
+			g_list_free_1 (link);
 
-		update_overloaded_status (indez);
+			update_overloaded_status (indez);
+		}
 
 		if (priv->cache_layers) {
 			g_debug ("Flushing next batch (%d words) to index...",
@@ -984,28 +986,24 @@
 
 	priv = TRACKER_DB_INDEX_GET_PRIVATE (indez);
 
-#if 0
-	if (!priv->cur_cache || g_hash_table_size (priv->cur_cache) == 0) {
-		/* Nothing to flush */
-		return;
-	}
-#endif
-
 	if (!priv->in_flush) {
 		set_in_flush (indez, TRUE);
 	}
 
-	g_debug ("Pushing a new batch (%d words) to be flushed to index...",
-		 g_hash_table_size (priv->cur_cache));
+	if (priv->cur_cache && g_hash_table_size (priv->cur_cache) > 0) {
+		g_debug ("Pushing a new batch (%d words) to be flushed to index...",
+			 g_hash_table_size (priv->cur_cache));
+
+		/* Put current cache into the queue and create a
+		 * new one for keeping appending words
+		 */
+		priv->cache_layers = g_list_append (priv->cache_layers, priv->cur_cache);
+		priv->cur_cache = index_cache_new ();
 
-	/* Put current cache into the queue and create a
-	 * new one for keeping appending words
-	 */
-	priv->cache_layers = g_list_append (priv->cache_layers, priv->cur_cache);
-	priv->cur_cache = index_cache_new ();
+		update_overloaded_status (indez);
+	}
 
 	init_flush (indez);
-	update_overloaded_status (indez);
 }
 
 void

Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c	(original)
+++ trunk/src/tracker-indexer/tracker-indexer.c	Wed Mar  4 11:47:42 2009
@@ -207,7 +207,8 @@
 					PathInfo	    *info,
 					const gchar         *dirname,
 					const gchar         *basename);
-static void     check_finished         (TrackerIndexer      *indexer);
+static void     check_finished         (TrackerIndexer      *indexer,
+					gboolean             interrupted);
 
 
 static guint signals[LAST_SIGNAL] = { 0, };
@@ -492,7 +493,7 @@
 	    !tracker_db_index_get_flushing (indexer->private->file_index) &&
 	    !tracker_db_index_get_flushing (indexer->private->email_index)) {
 		/* The indexer has been already stopped and all indices are flushed */
-		check_finished (indexer);
+		check_finished (indexer, indexer->private->interrupted);
 	}
 }
 
@@ -727,7 +728,8 @@
 }
 
 static void
-check_finished (TrackerIndexer *indexer)
+check_finished (TrackerIndexer *indexer,
+		gboolean        interrupted)
 {
 	TrackerIndexerState state;
 	gdouble seconds_elapsed = 0;
@@ -761,7 +763,7 @@
 		       seconds_elapsed,
 		       indexer->private->items_processed,
 		       indexer->private->items_indexed,
-		       indexer->private->interrupted);
+		       interrupted);
 
 	/* Reset stats */
 	indexer->private->items_processed = 0;
@@ -774,9 +776,19 @@
 check_stopped (TrackerIndexer *indexer,
 	       gboolean        interrupted)
 {
-	schedule_flush (indexer, TRUE);
-	state_set_flags (indexer, TRACKER_INDEXER_STATE_STOPPED);
-	indexer->private->interrupted = (interrupted != FALSE);
+	if ((indexer->private->state & TRACKER_INDEXER_STATE_STOPPED) == 0) {
+		schedule_flush (indexer, TRUE);
+		state_set_flags (indexer, TRACKER_INDEXER_STATE_STOPPED);
+		indexer->private->interrupted = (interrupted != FALSE);
+	} else {
+		/* If the indexer is stopped and the indices aren't
+		 * being flushed, then it's ready for finishing right away
+		 */
+		if (!tracker_db_index_get_flushing (indexer->private->file_index) &&
+		    !tracker_db_index_get_flushing (indexer->private->email_index)) {
+			check_finished (indexer, interrupted);
+		}
+	}
 }
 
 static gboolean



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