tracker r1946 - in branches/indexer-split: . src/tracker-indexer



Author: pvanhoof
Date: Mon Jul 28 08:01:58 2008
New Revision: 1946
URL: http://svn.gnome.org/viewvc/tracker?rev=1946&view=rev

Log:
2008-07-28  Philip Van Hoof  <pvanhoof gnome org>

        src/tracker-indexer/tracker-index.c:
        src/tracker-indexer/tracker-index.h:
        src/tracker-indexer/tracker-indexer.c:

        Open and close the QDBM file during pause and continue



Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/tracker-indexer/tracker-index.c
   branches/indexer-split/src/tracker-indexer/tracker-index.h
   branches/indexer-split/src/tracker-indexer/tracker-indexer.c

Modified: branches/indexer-split/src/tracker-indexer/tracker-index.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-index.c	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-index.c	Mon Jul 28 08:01:58 2008
@@ -32,6 +32,8 @@
 struct TrackerIndex {
 	GHashTable *cache;
 	DEPOT *index;
+	gchar *file;
+	gint bucket_count;
 };
 
 static void
@@ -40,6 +42,28 @@
 	g_array_free (array, TRUE);
 }
 
+void 
+tracker_index_open (TrackerIndex *index)
+{
+	if (index->index)
+		tracker_index_close (index);
+
+	index->index = dpopen (index->file, 
+			       DP_OWRITER | DP_OCREAT | DP_ONOLCK, 
+			       index->bucket_count);
+}
+
+void 
+tracker_index_close (TrackerIndex *index)
+{
+	if (index->index) {
+		if (!dpclose (index->index)) {
+			g_warning ("Could not close index: %s", dperrmsg (dpecode));
+		}
+		index->index = NULL;
+	}
+}
+
 
 TrackerIndex *
 tracker_index_new (const gchar *file,
@@ -53,7 +77,11 @@
 					      (GDestroyNotify) g_free,
 					      (GDestroyNotify) free_cache_values);
 
-	index->index = dpopen (file, DP_OWRITER | DP_OCREAT | DP_ONOLCK, bucket_count);
+	index->index = NULL;
+	index->file = g_strdup (file);
+	index->bucket_count = bucket_count;
+
+	tracker_index_open (index);
 
 	return index;
 }
@@ -70,10 +98,9 @@
 
 	g_debug ("Closing index");
 
-	if (!dpclose (index->index)) {
-		g_warning ("Could not close index: %s", dperrmsg (dpecode));
-	}
+	tracker_index_close (index);
 
+	g_free (index->file);
 	g_free (index);
 }
 
@@ -265,6 +292,11 @@
 {
 	guint size;
 
+	if (!index->index) {
+		g_warning ("Flushing index while closed, this indicates a problem in the software");
+		tracker_index_open (index);
+	}
+
 	size = g_hash_table_size (index->cache);
 	g_debug ("Flushing index with %d items in cache", size);
 

Modified: branches/indexer-split/src/tracker-indexer/tracker-index.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-index.h	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-index.h	Mon Jul 28 08:01:58 2008
@@ -40,6 +40,8 @@
 
 guint          tracker_index_flush    (TrackerIndex *index);
 
+void           tracker_index_open     (TrackerIndex *index);
+void           tracker_index_close    (TrackerIndex *index);
 
 G_END_DECLS
 

Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c	Mon Jul 28 08:01:58 2008
@@ -1017,7 +1017,8 @@
 		g_source_remove (indexer->private->idle_id);
 		indexer->private->idle_id = 0;
 		indexer->private->is_paused = TRUE;
-		
+
+		tracker_index_close (indexer->private->index);
 		g_signal_emit (indexer, signals[PAUSED], 0);
 	}
 
@@ -1038,7 +1039,8 @@
 
 		indexer->private->is_paused = FALSE;
 		indexer->private->idle_id = g_idle_add (process_func, indexer);
-		
+
+		tracker_index_open (indexer->private->index);
 		g_signal_emit (indexer, signals[CONTINUED], 0);
 	}
 	
@@ -1082,6 +1084,7 @@
 					       pause_for_duration_cb, 
 					       indexer);
 
+		tracker_index_close (indexer->private->index);
 		g_signal_emit (indexer, signals[PAUSED], 0);
 	}
 
@@ -1110,7 +1113,8 @@
 		
 		indexer->private->is_paused = FALSE;
 		indexer->private->idle_id = g_idle_add (process_func, indexer);
-		
+
+		tracker_index_open (indexer->private->index);
 		g_signal_emit (indexer, signals[CONTINUED], 0);
 	}
 



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