tracker r2136 - in branches/indexer-split: . src/libtracker-db src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2136 - in branches/indexer-split: . src/libtracker-db src/tracker-indexer
- Date: Thu, 21 Aug 2008 16:59:52 +0000 (UTC)
Author: carlosg
Date: Thu Aug 21 16:59:52 2008
New Revision: 2136
URL: http://svn.gnome.org/viewvc/tracker?rev=2136&view=rev
Log:
2008-08-21 Carlos Garnacho <carlos imendio com>
* src/libtracker-db/tracker-db-index.c (tracker_db_index_open): Do not
reopen/leak/corrupt data if there's already an index opened.
(tracker_db_index_flush): Do not open index if it was closed, there
could be good reasons for it.
* src/tracker-indexer/tracker-indexer.[ch] (schedule_flush): Do not
attempt to flush if the indexer is paused.
(stop_transaction): No point in committing if there wasn't a
transaction.
(tracker_indexer_set_running): Refactored the flush out, calling it
wherever it's needed. Also stop scheduled flushes so they aren't
called while the indexer is paused.
(check_disk_space_cb) (tracker_indexer_pause) (pause_for_duration_cb)
(tracker_indexer_pause_for_duration) (tracker_indexer_continue):
Update callers.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/libtracker-db/tracker-db-index.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.h
Modified: branches/indexer-split/src/libtracker-db/tracker-db-index.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-index.c (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-index.c Thu Aug 21 16:59:52 2008
@@ -50,8 +50,8 @@
guint min_bucket;
guint max_bucket;
- gboolean reload;
- gboolean readonly;
+ guint reload : 1;
+ guint readonly : 1;
/* From the indexer */
GHashTable *cache;
@@ -741,6 +741,7 @@
priv = TRACKER_DB_INDEX_GET_PRIVATE (index);
g_return_val_if_fail (priv->filename != NULL, FALSE);
+ g_return_val_if_fail (priv->index != NULL, FALSE);
g_mutex_lock (priv->mutex);
@@ -840,26 +841,20 @@
g_mutex_lock (priv->mutex);
+ if (!priv->index) {
+ g_debug ("Index was not open for flush, waiting...");
+ g_mutex_unlock (priv->mutex);
+ return;
+ }
+
size = g_hash_table_size (priv->cache);
if (size > 0) {
- if (!priv->index) {
- g_debug ("Index was not open for flush, opening first...");
- g_mutex_unlock (priv->mutex);
- tracker_db_index_open (index);
- g_mutex_lock (priv->mutex);
- }
+ g_debug ("Flushing index with %d items in cache", size);
- if (priv->index) {
- g_debug ("Flushing index with %d items in cache", size);
-
- g_hash_table_foreach_remove (priv->cache,
- cache_flush_foreach,
- priv->index);
- } else {
- g_warning ("Could not open index, cache was not flushed");
- size = 0;
- }
+ g_hash_table_foreach_remove (priv->cache,
+ cache_flush_foreach,
+ priv->index);
}
g_mutex_unlock (priv->mutex);
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 Thu Aug 21 16:59:52 2008
@@ -224,6 +224,10 @@
static void
stop_transaction (TrackerIndexer *indexer)
{
+ if (!indexer->private->in_transaction) {
+ return;
+ }
+
tracker_db_interface_end_transaction (indexer->private->common);
tracker_db_interface_end_transaction (indexer->private->email_metadata);
tracker_db_interface_end_transaction (indexer->private->file_metadata);
@@ -296,16 +300,25 @@
}
static void
+stop_scheduled_flush (TrackerIndexer *indexer)
+{
+ if (indexer->private->flush_id) {
+ g_source_remove (indexer->private->flush_id);
+ indexer->private->flush_id = 0;
+ }
+}
+
+static void
schedule_flush (TrackerIndexer *indexer,
gboolean immediately)
{
+ if (indexer->private->is_paused) {
+ return;
+ }
+
if (immediately) {
/* No need to wait for flush timeout */
- if (indexer->private->flush_id) {
- g_source_remove (indexer->private->flush_id);
- indexer->private->flush_id = 0;
- }
-
+ stop_scheduled_flush (indexer);
flush_data (indexer);
return;
}
@@ -382,10 +395,7 @@
/* Important! Make sure we flush if we are scheduled to do so,
* and do that first.
*/
- if (priv->flush_id) {
- g_source_remove (priv->flush_id);
- schedule_flush (TRACKER_INDEXER (object), TRUE);
- }
+ stop_scheduled_flush (TRACKER_INDEXER (object));
if (priv->pause_for_duration_id) {
g_source_remove (priv->pause_for_duration_id);
@@ -642,12 +652,12 @@
disk_space_low = check_disk_space_low (indexer);
if (disk_space_low) {
- tracker_indexer_set_running (indexer, FALSE, TRUE);
+ tracker_indexer_set_running (indexer, FALSE);
/* The function above stops the low disk check, restart it */
check_disk_space_start (indexer);
} else {
- tracker_indexer_set_running (indexer, TRUE, TRUE);
+ tracker_indexer_set_running (indexer, TRUE);
}
return TRUE;
@@ -1718,7 +1728,7 @@
indexer = TRACKER_INDEXER (data);
- if (!indexer->private->in_transaction) {
+ if (G_UNLIKELY (!indexer->private->in_transaction)) {
start_transaction (indexer);
}
@@ -1777,8 +1787,7 @@
void
tracker_indexer_set_running (TrackerIndexer *indexer,
- gboolean running,
- gboolean flush)
+ gboolean running)
{
gboolean was_running;
@@ -1791,14 +1800,10 @@
}
if (!running) {
-
- if (flush)
- schedule_flush (indexer, TRUE);
- else
- stop_transaction (indexer);
-
check_disk_space_stop (indexer);
signal_status_timeout_stop (indexer);
+ stop_scheduled_flush (indexer);
+ stop_transaction (indexer);
g_source_remove (indexer->private->idle_id);
indexer->private->idle_id = 0;
@@ -1841,15 +1846,10 @@
"DBus request to pause the indexer");
if (tracker_indexer_get_running (indexer)) {
- if (indexer->private->in_transaction) {
- tracker_dbus_request_comment (request_id,
- "Committing transactions");
- }
-
tracker_dbus_request_comment (request_id,
"Pausing indexing");
- tracker_indexer_set_running (indexer, FALSE, FALSE);
+ tracker_indexer_set_running (indexer, FALSE);
}
dbus_g_method_return (context);
@@ -1864,7 +1864,7 @@
indexer = TRACKER_INDEXER (user_data);
- tracker_indexer_set_running (indexer, TRUE, FALSE);
+ tracker_indexer_set_running (indexer, TRUE);
indexer->private->pause_for_duration_id = 0;
return FALSE;
@@ -1895,7 +1895,7 @@
tracker_dbus_request_comment (request_id,
"Pausing indexing");
- tracker_indexer_set_running (indexer, FALSE, FALSE);
+ tracker_indexer_set_running (indexer, FALSE);
indexer->private->pause_for_duration_id =
g_timeout_add_seconds (seconds,
@@ -1926,7 +1926,7 @@
tracker_dbus_request_comment (request_id,
"Continuing indexing");
- tracker_indexer_set_running (indexer, TRUE, FALSE);
+ tracker_indexer_set_running (indexer, TRUE);
}
dbus_g_method_return (context);
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.h Thu Aug 21 16:59:52 2008
@@ -75,8 +75,7 @@
TrackerIndexer *tracker_indexer_new (void);
gboolean tracker_indexer_get_running (TrackerIndexer *indexer);
void tracker_indexer_set_running (TrackerIndexer *indexer,
- gboolean running,
- gboolean flush);
+ gboolean running);
void tracker_indexer_stop (TrackerIndexer *indexer);
void tracker_indexer_process_all (TrackerIndexer *indexer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]