tracker r2001 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2001 - in branches/indexer-split: . src/trackerd
- Date: Tue, 5 Aug 2008 12:33:05 +0000 (UTC)
Author: mr
Date: Tue Aug 5 12:33:05 2008
New Revision: 2001
URL: http://svn.gnome.org/viewvc/tracker?rev=2001&view=rev
Log:
* src/trackerd/tracker-processor.c: Make sure we disable monitor
events while crawling the file system and enable then once done.
This way we can't get monitor events causing the daemon to signal
"indexing" state up before we have finished processing each module
for crawling. Also, when we start processing new files from
monitor events, put us into "indexing" state instead of staying
"idle".
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/tracker-monitor.c
branches/indexer-split/src/trackerd/tracker-monitor.h
branches/indexer-split/src/trackerd/tracker-processor.c
Modified: branches/indexer-split/src/trackerd/tracker-monitor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-monitor.c (original)
+++ branches/indexer-split/src/trackerd/tracker-monitor.c Tue Aug 5 12:33:05 2008
@@ -54,6 +54,8 @@
GHashTable *modules;
+ gboolean enabled;
+
guint black_list_timeout_id;
GHashTable *black_list_count;
GHashTable *black_list_timestamps;
@@ -72,10 +74,23 @@
LAST_SIGNAL
};
-static void tracker_monitor_finalize (GObject *object);
-static gboolean black_list_check_items_cb (gpointer data);
-static void black_list_print_all (TrackerMonitor *monitor);
-static guint get_inotify_limit (void);
+enum {
+ PROP_0,
+ PROP_ENABLED
+};
+
+static void tracker_monitor_finalize (GObject *object);
+static void tracker_monitor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void tracker_monitor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static gboolean black_list_check_items_cb (gpointer data);
+static void black_list_print_all (TrackerMonitor *monitor);
+static guint get_inotify_limit (void);
static guint signals[LAST_SIGNAL] = { 0, };
@@ -89,6 +104,8 @@
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = tracker_monitor_finalize;
+ object_class->set_property = tracker_monitor_set_property;
+ object_class->get_property = tracker_monitor_get_property;
signals[ITEM_CREATED] =
g_signal_new ("item-created",
@@ -127,6 +144,14 @@
G_TYPE_OBJECT,
G_TYPE_BOOLEAN);
+ g_object_class_install_property (object_class,
+ PROP_ENABLED,
+ g_param_spec_boolean ("enabled",
+ "Enabled",
+ "Enabled",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
g_type_class_add_private (object_class, sizeof (TrackerMonitorPrivate));
}
@@ -143,6 +168,9 @@
priv = object->private;
+ /* By default we enable monitoring */
+ priv->enabled = TRUE;
+
/* For each module we create a hash table for monitors */
priv->modules =
g_hash_table_new_full (g_str_hash,
@@ -288,21 +316,41 @@
G_OBJECT_CLASS (tracker_monitor_parent_class)->finalize (object);
}
-TrackerMonitor *
-tracker_monitor_new (TrackerConfig *config)
-{
- TrackerMonitor *monitor;
- TrackerMonitorPrivate *priv;
+static void
+tracker_monitor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id) {
+ case PROP_ENABLED:
+ tracker_monitor_set_enabled (TRACKER_MONITOR (object),
+ g_value_get_boolean (value));
+ break;
- g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
- monitor = g_object_new (TRACKER_TYPE_MONITOR, NULL);
+static void
+tracker_monitor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ TrackerMonitorPrivate *priv;
- priv = monitor->private;
+ priv = TRACKER_MONITOR_GET_PRIVATE (object);
- priv->config = g_object_ref (config);
+ switch (prop_id) {
+ case PROP_ENABLED:
+ g_value_set_boolean (value, priv->enabled);
+ break;
- return monitor;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static guint
@@ -612,6 +660,11 @@
monitor = user_data;
+ if (G_UNLIKELY (!monitor->private->enabled)) {
+ g_debug ("Silently dropping monitor event, monitor disabled for now");
+ return;
+ }
+
module_name = get_module_name_from_gfile (monitor,
file,
&is_directory);
@@ -688,6 +741,43 @@
g_free (str2);
}
+
+TrackerMonitor *
+tracker_monitor_new (TrackerConfig *config)
+{
+ TrackerMonitor *monitor;
+ TrackerMonitorPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
+
+ monitor = g_object_new (TRACKER_TYPE_MONITOR, NULL);
+
+ priv = monitor->private;
+
+ priv->config = g_object_ref (config);
+
+ return monitor;
+}
+
+gboolean
+tracker_monitor_get_enabled (TrackerMonitor *monitor)
+{
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
+
+ return monitor->private->enabled;
+}
+
+void
+tracker_monitor_set_enabled (TrackerMonitor *monitor,
+ gboolean enabled)
+{
+ g_return_if_fail (TRACKER_IS_MONITOR (monitor));
+
+ monitor->private->enabled = enabled;
+
+ g_object_notify (G_OBJECT (monitor), "enabled");
+}
+
gboolean
tracker_monitor_add (TrackerMonitor *monitor,
const gchar *module_name,
@@ -919,3 +1009,4 @@
return monitor->private->monitors_ignored;
}
+
Modified: branches/indexer-split/src/trackerd/tracker-monitor.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-monitor.h (original)
+++ branches/indexer-split/src/trackerd/tracker-monitor.h Tue Aug 5 12:33:05 2008
@@ -51,6 +51,9 @@
GType tracker_monitor_get_type (void);
TrackerMonitor *tracker_monitor_new (TrackerConfig *config);
+gboolean tracker_monitor_get_enabled (TrackerMonitor *monitor);
+void tracker_monitor_set_enabled (TrackerMonitor *monitor,
+ gboolean enabled);
gboolean tracker_monitor_add (TrackerMonitor *monitor,
const gchar *module_name,
GFile *file);
Modified: branches/indexer-split/src/trackerd/tracker-processor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.c (original)
+++ branches/indexer-split/src/trackerd/tracker-processor.c Tue Aug 5 12:33:05 2008
@@ -447,8 +447,6 @@
NULL,
G_CALLBACK (crawler_processing_file_cb),
NULL);
- g_return_if_fail (signals > 0);
-
signals = g_signal_handlers_disconnect_matched (crawler,
G_SIGNAL_MATCH_FUNC,
0,
@@ -456,8 +454,6 @@
NULL,
G_CALLBACK (crawler_processing_directory_cb),
NULL);
- g_return_if_fail (signals > 0);
-
signals = g_signal_handlers_disconnect_matched (crawler,
G_SIGNAL_MATCH_FUNC,
0,
@@ -465,7 +461,6 @@
NULL,
G_CALLBACK (crawler_finished_cb),
NULL);
- g_return_if_fail (signals > 0);
g_object_unref (crawler);
}
@@ -651,6 +646,9 @@
return;
}
+ /* Now we try to send all items to the indexer */
+ tracker_status_set_and_signal (TRACKER_STATUS_INDEXING);
+
processor->private->item_queues_handler_id =
g_timeout_add (ITEMS_QUEUE_PROCESS_INTERVAL,
item_queue_handlers_cb,
@@ -1248,6 +1246,9 @@
/* Set up the monitor */
priv->monitor = tracker_monitor_new (config);
+ g_message ("Disabling monitor events until we have crawled the file system");
+ tracker_monitor_set_enabled (priv->monitor, FALSE);
+
g_signal_connect (priv->monitor, "item-created",
G_CALLBACK (monitor_item_created_cb),
processor);
@@ -1306,8 +1307,13 @@
crawler = g_hash_table_lookup (processor->private->crawlers,
processor->private->current_module->data);
tracker_crawler_stop (crawler);
+
}
+ /* Now we have finished crawling, we enable monitor events */
+ g_message ("Enabling monitor events");
+ tracker_monitor_set_enabled (processor->private->monitor, TRUE);
+
g_message ("Process %s\n",
processor->private->finished ? "has finished" : "been stopped");
@@ -1338,9 +1344,6 @@
processor->private->finished = TRUE;
g_signal_emit (processor, signals[FINISHED], 0);
} else {
- /* Now we try to send all items to the indexer */
- tracker_status_set_and_signal (TRACKER_STATUS_INDEXING);
-
item_queue_handlers_set_up (processor);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]