tracker r1894 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1894 - in branches/indexer-split: . src/trackerd
- Date: Mon, 21 Jul 2008 13:00:58 +0000 (UTC)
Author: mr
Date: Mon Jul 21 13:00:58 2008
New Revision: 1894
URL: http://svn.gnome.org/viewvc/tracker?rev=1894&view=rev
Log:
* src/trackerd/tracker-crawler.c:
* src/trackerd/tracker-main.c:
* src/trackerd/tracker-monitor.[ch]:
* src/trackerd/tracker-processor.c: Make tracker-monitor a GObject
with signalling when there are items created/updated/deleted and
move all the code which sends file notifications to the indexer
into the processor.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/tracker-crawler.c
branches/indexer-split/src/trackerd/tracker-main.c
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-crawler.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-crawler.c (original)
+++ branches/indexer-split/src/trackerd/tracker-crawler.c Mon Jul 21 13:00:58 2008
@@ -1013,8 +1013,10 @@
priv->directories_ignored = 0;
priv->files_found = 0;
priv->files_ignored = 0;
+#if 0
priv->monitors_added = tracker_monitor_get_count (module_name);
priv->monitors_ignored = tracker_monitor_get_ignored ();
+#endif
for (sl = paths; sl; sl = sl->next) {
file = g_file_new_for_path (sl->data);
@@ -1048,9 +1050,11 @@
g_message (" Found %d files, ignored %d files",
priv->files_found,
priv->files_ignored);
+#if 0
g_message (" Added %d monitors, ignored %d monitors",
tracker_monitor_get_count (priv->current_module_name),
tracker_monitor_get_ignored () - priv->monitors_ignored);
+#endif
priv->running = FALSE;
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Mon Jul 21 13:00:58 2008
@@ -702,10 +702,6 @@
tracker_module_config_init ();
- if (!tracker_monitor_init (config)) {
- return EXIT_FAILURE;
- }
-
flags = TRACKER_DB_MANAGER_REMOVE_CACHE;
if (force_reindex) {
@@ -820,7 +816,6 @@
tracker_dbus_shutdown ();
tracker_db_manager_shutdown ();
tracker_db_shutdown ();
- tracker_monitor_shutdown ();
tracker_module_config_shutdown ();
tracker_nfs_lock_shutdown ();
tracker_log_shutdown ();
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 Mon Jul 21 13:00:58 2008
@@ -28,141 +28,98 @@
#include "tracker-monitor.h"
#include "tracker-dbus.h"
#include "tracker-indexer-client.h"
+#include "tracker-marshal.h"
-#define FILES_QUEUE_PROCESS_INTERVAL 2000
-#define FILES_QUEUE_PROCESS_MAX 5000
+#define TRACKER_MONITOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_MONITOR, TrackerMonitorPrivate))
-typedef enum {
- SENT_DATA_TYPE_CREATED,
- SENT_DATA_TYPE_UPDATED,
- SENT_DATA_TYPE_DELETED
-} SentDataType;
+struct _TrackerMonitorPrivate {
+ TrackerConfig *config;
-typedef struct {
- SentDataType type;
- GQueue *queue;
- GStrv files;
- const gchar *module_name;
-} SentData;
-
-static gboolean initialized;
-
-static TrackerConfig *config;
-
-static GHashTable *modules;
-static GHashTable *files_created_queues;
-static GHashTable *files_updated_queues;
-static GHashTable *files_deleted_queues;
-
-static gboolean sent_data[3];
-
-static guint files_queue_handlers_id;
-
-static GType monitor_backend;
-
-static guint monitor_limit;
-static gboolean monitor_limit_warned;
-static guint monitors_ignored;
-
-static guint
-get_inotify_limit (void)
-{
- GError *error = NULL;
- const gchar *filename;
- gchar *contents = NULL;
- guint limit;
+ GHashTable *modules;
- filename = "/proc/sys/fs/inotify/max_user_watches";
+ GType monitor_backend;
- if (!g_file_get_contents (filename,
- &contents,
- NULL,
- &error)) {
- g_warning ("Couldn't get INotify monitor limit from:'%s', %s",
- filename,
- error ? error->message : "no error given");
- g_clear_error (&error);
-
- /* Setting limit to an arbitary limit */
- limit = 8192;
- } else {
- limit = atoi (contents);
- g_free (contents);
- }
-
- return limit;
-}
+ guint monitor_limit;
+ gboolean monitor_limit_warned;
+ guint monitors_ignored;
+};
-static const gchar *
-get_queue_from_gfile (GFile *file)
-{
- GHashTable *hash_table;
- GList *all_modules, *l;
- const gchar *module_name = NULL;
+enum {
+ ITEM_CREATED,
+ ITEM_UPDATED,
+ ITEM_DELETED,
+ LAST_SIGNAL
+};
- all_modules = g_hash_table_get_keys (modules);
-
- for (l = all_modules; l && !module_name; l = l->next) {
- hash_table = g_hash_table_lookup (modules, l->data);
- if (g_hash_table_lookup (hash_table, file)) {
- module_name = l->data;
- }
- }
+static void monitor_finalize (GObject *object);
+static guint get_inotify_limit (void);
- g_list_free (all_modules);
+static guint signals[LAST_SIGNAL] = { 0, };
- return module_name;
-}
+G_DEFINE_TYPE(TrackerMonitor, tracker_monitor, G_TYPE_OBJECT)
static void
-files_queue_destroy_notify (gpointer data)
+tracker_monitor_class_init (TrackerMonitorClass *klass)
{
- GQueue *queue;
+ GObjectClass *object_class;
- queue = (GQueue *) data;
+ object_class = G_OBJECT_CLASS (klass);
- g_queue_foreach (queue, (GFunc) g_free, NULL);
- g_queue_free (queue);
+ object_class->finalize = monitor_finalize;
+
+ signals[ITEM_CREATED] =
+ g_signal_new ("item-created",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__STRING_OBJECT,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_OBJECT);
+ signals[ITEM_UPDATED] =
+ g_signal_new ("item-updated",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__STRING_OBJECT,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_OBJECT);
+ signals[ITEM_DELETED] =
+ g_signal_new ("item-deleted",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ tracker_marshal_VOID__STRING_OBJECT,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_OBJECT);
+
+ g_type_class_add_private (object_class, sizeof (TrackerMonitorPrivate));
}
-gboolean
-tracker_monitor_init (TrackerConfig *this_config)
+static void
+tracker_monitor_init (TrackerMonitor *object)
{
- GFile *file;
- GFileMonitor *monitor;
- GList *all_modules, *l;
- const gchar *name;
+ TrackerMonitorPrivate *priv;
+ GFile *file;
+ GFileMonitor *monitor;
+ GList *all_modules, *l;
+ const gchar *name;
- g_return_val_if_fail (TRACKER_IS_CONFIG (this_config), FALSE);
-
- if (initialized) {
- return TRUE;
- }
+ priv = TRACKER_MONITOR_GET_PRIVATE (object);
- config = g_object_ref (this_config);
-
/* For each module we create a hash table for monitors */
- modules =
- g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- (GDestroyNotify) g_hash_table_unref);
-
- files_created_queues =
- g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- files_queue_destroy_notify);
- files_updated_queues =
- g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- files_queue_destroy_notify);
- files_deleted_queues =
- g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- files_queue_destroy_notify);
+ priv->modules = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) g_hash_table_unref);
all_modules = tracker_module_config_get_modules ();
@@ -175,18 +132,7 @@
(GDestroyNotify) g_object_unref,
(GDestroyNotify) g_file_monitor_cancel);
- g_hash_table_insert (modules, g_strdup (l->data), monitors);
-
- /* Create queues for this module */
- g_hash_table_insert (files_created_queues,
- g_strdup (l->data),
- g_queue_new ());
- g_hash_table_insert (files_updated_queues,
- g_strdup (l->data),
- g_queue_new ());
- g_hash_table_insert (files_deleted_queues,
- g_strdup (l->data),
- g_queue_new ());
+ g_hash_table_insert (priv->modules, g_strdup (l->data), monitors);
}
g_list_free (all_modules);
@@ -200,13 +146,13 @@
NULL,
NULL);
- monitor_backend = G_OBJECT_TYPE (monitor);
+ priv->monitor_backend = G_OBJECT_TYPE (monitor);
/* We use the name because the type itself is actually
* private and not available publically. Note this is
* subject to change, but unlikely of course.
*/
- name = g_type_name (monitor_backend);
+ name = g_type_name (priv->monitor_backend);
if (name) {
/* Set limits based on backend... */
if (strcmp (name, "GInotifyDirectoryMonitor") == 0) {
@@ -216,7 +162,7 @@
/* Setting limit based on kernel
* settings in /proc...
*/
- monitor_limit = get_inotify_limit ();
+ priv->monitor_limit = get_inotify_limit ();
/* We don't use 100% of the monitors, we allow other
* applications to have at least 500 or so to use
@@ -224,12 +170,12 @@
* applies to inotify because it is a
* user shared resource.
*/
- monitor_limit -= 500;
+ priv->monitor_limit -= 500;
/* Make sure we don't end up with a
* negative maximum.
*/
- monitor_limit = MAX (monitor_limit, 0);
+ priv->monitor_limit = MAX (priv->monitor_limit, 0);
}
else if (strcmp (name, "GFamDirectoryMonitor") == 0) {
/* Using Fam */
@@ -238,21 +184,21 @@
/* Setting limit to an arbitary limit
* based on testing
*/
- monitor_limit = 400;
+ priv->monitor_limit = 400;
}
else if (strcmp (name, "GFenDirectoryMonitor") == 0) {
/* Using Fen, what is this? */
g_message ("Monitor backend is Fen");
/* Guessing limit... */
- monitor_limit = 8192;
+ priv->monitor_limit = 8192;
}
else if (strcmp (name, "GWin32DirectoryMonitor") == 0) {
/* Using Windows */
g_message ("Monitor backend is Windows");
/* Guessing limit... */
- monitor_limit = 8192;
+ priv->monitor_limit = 8192;
}
else {
/* Unknown */
@@ -261,272 +207,96 @@
name);
/* Guessing limit... */
- monitor_limit = 100;
+ priv->monitor_limit = 100;
}
}
- g_message ("Monitor limit is %d", monitor_limit);
+ g_message ("Monitor limit is %d", priv->monitor_limit);
g_file_monitor_cancel (monitor);
g_object_unref (file);
-
- initialized = TRUE;
-
- return TRUE;
}
-void
-tracker_monitor_shutdown (void)
+static void
+monitor_finalize (GObject *object)
{
- if (!initialized) {
- return;
- }
-
- monitors_ignored = 0;
- monitor_limit_warned = FALSE;
- monitor_limit = 0;
- monitor_backend = 0;
-
- if (files_queue_handlers_id) {
- g_source_remove (files_queue_handlers_id);
- files_queue_handlers_id = 0;
- }
+ TrackerMonitorPrivate *priv;
- if (files_deleted_queues) {
- g_hash_table_unref (files_deleted_queues);
- files_deleted_queues = NULL;
- }
-
- if (files_updated_queues) {
- g_hash_table_unref (files_updated_queues);
- files_updated_queues = NULL;
- }
-
- if (files_created_queues) {
- g_hash_table_unref (files_created_queues);
- files_created_queues = NULL;
- }
-
- if (modules) {
- g_hash_table_unref (modules);
- modules = NULL;
- }
-
- if (config) {
- g_object_unref (config);
- config = NULL;
- }
-
- initialized = FALSE;
-}
+ priv = TRACKER_MONITOR_GET_PRIVATE (object);
-static SentData *
-sent_data_new (SentDataType type,
- GQueue *queue,
- GStrv files,
- const gchar *module_name)
-{
- SentData *sd;
+ g_hash_table_unref (priv->modules);
- sd = g_slice_new0 (SentData);
- sd->type = type;
- sd->queue = queue;
- sd->files = files;
- sd->module_name = module_name;
+ g_object_unref (priv->config);
- return sd;
+ G_OBJECT_CLASS (tracker_monitor_parent_class)->finalize (object);
}
-static void
-sent_data_free (SentData *sd)
+TrackerMonitor *
+tracker_monitor_new (TrackerConfig *config)
{
- g_strfreev (sd->files);
- g_slice_free (SentData, sd);
-}
+ TrackerMonitor *monitor;
+ TrackerMonitorPrivate *priv;
-static GQueue *
-get_next_queue_with_data (GHashTable *hash_table,
- gchar **module_name_p)
-{
- GQueue *queue;
- GList *all_modules, *l;
- gchar *module_name;
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), NULL);
- if (module_name_p) {
- *module_name_p = NULL;
- }
+ monitor = g_object_new (TRACKER_TYPE_MONITOR, NULL);
- all_modules = g_hash_table_get_keys (hash_table);
-
- for (l = all_modules, queue = NULL; l && !queue; l = l->next) {
- module_name = l->data;
- queue = g_hash_table_lookup (hash_table, module_name);
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
- if (g_queue_get_length (queue) > 0) {
- if (module_name_p) {
- *module_name_p = module_name;
- }
+ priv->config = g_object_ref (config);
- continue;
- }
-
- queue = NULL;
- }
-
- g_list_free (all_modules);
-
- return queue;
+ return monitor;
}
-static void
-file_queue_readd_items (GQueue *queue,
- GStrv strv)
-{
- if (queue) {
- GStrv p;
- gint i;
-
- for (p = strv, i = 0; *p; p++, i++) {
- g_queue_push_nth (queue, g_strdup (*p), i);
- }
- }
-}
-
-static void
-file_queue_processed_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
+static guint
+get_inotify_limit (void)
{
- SentData *sd;
+ GError *error = NULL;
+ const gchar *filename;
+ gchar *contents = NULL;
+ guint limit;
- sd = (SentData*) user_data;
-
- if (error) {
- g_message ("Monitor events could not be processed by the indexer, %s",
- error->message);
- g_error_free (error);
-
- /* Put files back into queue */
- file_queue_readd_items (sd->queue, sd->files);
- } else {
- g_debug ("Sent!");
- }
-
- /* Set status so we know we can send more files */
- sent_data[sd->type] = FALSE;
-
- sent_data_free (sd);
-}
-
-static gboolean
-file_queue_handlers_cb (gpointer user_data)
-{
- DBusGProxy *proxy;
- GQueue *queue;
- GStrv files;
- gchar *module_name;
- SentData *sd;
- SentDataType type;
-
- /* This is here so we don't try to send something if we are
- * still waiting for a response from the last send.
- */
- if (sent_data[SENT_DATA_TYPE_CREATED] ||
- sent_data[SENT_DATA_TYPE_DELETED] ||
- sent_data[SENT_DATA_TYPE_UPDATED]) {
- g_message ("Still waiting for response from indexer, "
- "not sending more files yet");
- return TRUE;
- }
-
- /* Check we can actually talk to the indexer */
- proxy = tracker_dbus_indexer_get_proxy ();
+ filename = "/proc/sys/fs/inotify/max_user_watches";
- /* Process the deleted items first */
- queue = get_next_queue_with_data (files_deleted_queues, &module_name);
-
- if (queue && g_queue_get_length (queue) > 0) {
- /* First do the deleted queue */
- files = tracker_dbus_queue_str_to_strv (queue, FILES_QUEUE_PROCESS_MAX);
-
- g_message ("Monitor events queue for deleted items processed, sending first %d to the indexer",
- g_strv_length (files));
-
- type = SENT_DATA_TYPE_DELETED;
- sent_data[type] = TRUE;
- sd = sent_data_new (type, queue, files, module_name);
-
- org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
- module_name,
- (const gchar **) files,
- file_queue_processed_cb,
- sd);
+ if (!g_file_get_contents (filename,
+ &contents,
+ NULL,
+ &error)) {
+ g_warning ("Couldn't get INotify monitor limit from:'%s', %s",
+ filename,
+ error ? error->message : "no error given");
+ g_clear_error (&error);
- return TRUE;
+ /* Setting limit to an arbitary limit */
+ limit = 8192;
+ } else {
+ limit = atoi (contents);
+ g_free (contents);
}
- /* Process the deleted items first */
- queue = get_next_queue_with_data (files_created_queues, &module_name);
-
- if (queue && g_queue_get_length (queue) > 0) {
- /* First do the deleted queue */
- files = tracker_dbus_queue_str_to_strv (queue, FILES_QUEUE_PROCESS_MAX);
-
- g_message ("Monitor events queue for created items processed, sending first %d to the indexer",
- g_strv_length (files));
-
- type = SENT_DATA_TYPE_CREATED;
- sent_data[type] = TRUE;
- sd = sent_data_new (type, queue, files, module_name);
-
- org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
- module_name,
- (const gchar **) files,
- file_queue_processed_cb,
- sd);
-
- return TRUE;
- }
+ return limit;
+}
- /* Process the deleted items first */
- queue = get_next_queue_with_data (files_updated_queues, &module_name);
+static const gchar *
+get_queue_from_gfile (GHashTable *modules,
+ GFile *file)
+{
+ GHashTable *hash_table;
+ GList *all_modules, *l;
+ const gchar *module_name = NULL;
- if (queue && g_queue_get_length (queue) > 0) {
- /* First do the deleted queue */
- files = tracker_dbus_queue_str_to_strv (queue, FILES_QUEUE_PROCESS_MAX);
-
- g_message ("Monitor events queue for updated items processed, sending first %d to the indexer",
- g_strv_length (files));
+ all_modules = g_hash_table_get_keys (modules);
- type = SENT_DATA_TYPE_UPDATED;
- sent_data[type] = TRUE;
- sd = sent_data_new (type, queue, files, module_name);
-
- org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
- module_name,
- (const gchar **) files,
- file_queue_processed_cb,
- sd);
-
- return TRUE;
+ for (l = all_modules; l && !module_name; l = l->next) {
+ hash_table = g_hash_table_lookup (modules, l->data);
+ if (g_hash_table_lookup (hash_table, file)) {
+ module_name = l->data;
+ }
}
- g_message ("No monitor events to process, doing nothing");
- files_queue_handlers_id = 0;
-
- return FALSE;
-}
-
-static void
-file_queue_handlers_set_up (void)
-{
- if (files_queue_handlers_id) {
- return;
- }
+ g_list_free (all_modules);
- files_queue_handlers_id = g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL,
- file_queue_handlers_cb,
- NULL);
+ return module_name;
}
static const gchar *
@@ -553,23 +323,27 @@
}
static void
-monitor_event_cb (GFileMonitor *monitor,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type,
- gpointer user_data)
-{
- GQueue *queue;
- const gchar *module_name;
- gchar *str1;
- gchar *str2;
+monitor_event_cb (GFileMonitor *file_monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
+{
+ TrackerMonitor *monitor;
+ TrackerMonitorPrivate *priv;
+ const gchar *module_name;
+ gchar *str1;
+ gchar *str2;
+
+ monitor = TRACKER_MONITOR (user_data);
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
str1 = g_file_get_path (file);
/* First try to get the module name from the file, this will
* only work if the event we received is for a directory.
*/
- module_name = get_queue_from_gfile (file);
+ module_name = get_queue_from_gfile (priv->modules, file);
if (!module_name) {
GFile *parent;
@@ -577,7 +351,7 @@
* name of the file.
*/
parent = g_file_get_parent (file);
- module_name = get_queue_from_gfile (parent);
+ module_name = get_queue_from_gfile (priv->modules, parent);
if (!module_name) {
gchar *path;
@@ -608,52 +382,51 @@
case G_FILE_MONITOR_EVENT_CHANGED:
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
- queue = g_hash_table_lookup (files_updated_queues, module_name);
- g_queue_push_tail (queue, str1);
- file_queue_handlers_set_up ();
+ g_signal_emit (monitor, signals[ITEM_UPDATED], 0, module_name, file);
break;
case G_FILE_MONITOR_EVENT_DELETED:
- queue = g_hash_table_lookup (files_deleted_queues, module_name);
- g_queue_push_tail (queue, str1);
- file_queue_handlers_set_up ();
+ g_signal_emit (monitor, signals[ITEM_DELETED], 0, module_name, file);
break;
case G_FILE_MONITOR_EVENT_CREATED:
- queue = g_hash_table_lookup (files_created_queues, module_name);
- g_queue_push_tail (queue, str1);
- file_queue_handlers_set_up ();
+ g_signal_emit (monitor, signals[ITEM_CREATED], 0, module_name, file);
break;
case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
case G_FILE_MONITOR_EVENT_UNMOUNTED:
/* Do nothing */
- g_free (str1);
break;
}
+ g_free (str1);
g_free (str2);
}
gboolean
-tracker_monitor_add (GFile *file,
- const gchar *module_name)
-{
- GFileMonitor *monitor;
- GHashTable *monitors;
- GSList *ignored_roots;
- GSList *l;
- GError *error = NULL;
- gchar *path;
+tracker_monitor_add (TrackerMonitor *monitor,
+ GFile *file,
+ const gchar *module_name)
+{
+ TrackerMonitorPrivate *priv;
+ GFileMonitor *file_monitor;
+ GHashTable *monitors;
+ GSList *ignored_roots;
+ GSList *l;
+ GError *error = NULL;
+ gchar *path;
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (module_name != NULL, FALSE);
+
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
- if (!tracker_config_get_enable_watches (config)) {
+ if (!tracker_config_get_enable_watches (priv->config)) {
return TRUE;
}
- monitors = g_hash_table_lookup (modules, module_name);
+ monitors = g_hash_table_lookup (priv->modules, module_name);
if (!monitors) {
g_warning ("No monitor hash table for module:'%s'",
module_name);
@@ -665,14 +438,14 @@
}
/* Cap the number of monitors */
- if (g_hash_table_size (monitors) >= monitor_limit) {
- monitors_ignored++;
+ if (g_hash_table_size (monitors) >= priv->monitor_limit) {
+ priv->monitors_ignored++;
- if (!monitor_limit_warned) {
+ if (!priv->monitor_limit_warned) {
g_warning ("The maximum number of monitors to set (%d) "
"has been reached, not adding any new ones",
- monitor_limit);
- monitor_limit_warned = TRUE;
+ priv->monitor_limit);
+ priv->monitor_limit_warned = TRUE;
}
return FALSE;
@@ -680,7 +453,7 @@
path = g_file_get_path (file);
- ignored_roots = tracker_config_get_no_watch_directory_roots (config);
+ ignored_roots = tracker_config_get_no_watch_directory_roots (priv->config);
/* Check this location isn't excluded in the config */
for (l = ignored_roots; l; l = l->next) {
@@ -697,10 +470,10 @@
*
* Also, we assume ALL paths passed are directories.
*/
- monitor = g_file_monitor_directory (file,
- G_FILE_MONITOR_WATCH_MOUNTS,
- NULL,
- &error);
+ file_monitor = g_file_monitor_directory (file,
+ G_FILE_MONITOR_WATCH_MOUNTS,
+ NULL,
+ &error);
if (error) {
@@ -712,13 +485,13 @@
return FALSE;
}
- g_signal_connect (monitor, "changed",
+ g_signal_connect (file_monitor, "changed",
G_CALLBACK (monitor_event_cb),
- monitors);
+ monitor);
g_hash_table_insert (monitors,
g_object_ref (file),
- monitor);
+ file_monitor);
g_debug ("Added monitor for module:'%s', path:'%s', total monitors:%d",
module_name,
@@ -731,34 +504,39 @@
}
gboolean
-tracker_monitor_remove (GFile *file,
- const gchar *module_name)
-{
- GFileMonitor *monitor;
- GHashTable *monitors;
- gchar *path;
+tracker_monitor_remove (TrackerMonitor *monitor,
+ GFile *file,
+ const gchar *module_name)
+{
+ TrackerMonitorPrivate *priv;
+ GFileMonitor *file_monitor;
+ GHashTable *monitors;
+ gchar *path;
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (module_name != NULL, FALSE);
- if (!tracker_config_get_enable_watches (config)) {
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
+
+ if (!tracker_config_get_enable_watches (priv->config)) {
return TRUE;
}
- monitors = g_hash_table_lookup (modules, module_name);
+ monitors = g_hash_table_lookup (priv->modules, module_name);
if (!monitors) {
g_warning ("No monitor hash table for module:'%s'",
module_name);
return FALSE;
}
- monitor = g_hash_table_lookup (monitors, file);
- if (!monitor) {
+ file_monitor = g_hash_table_lookup (monitors, file);
+ if (!file_monitor) {
return TRUE;
}
/* We reset this because now it is possible we have limit - 1 */
- monitor_limit_warned = FALSE;
+ priv->monitor_limit_warned = FALSE;
g_hash_table_remove (monitors, file);
@@ -775,15 +553,20 @@
}
gboolean
-tracker_monitor_is_watched (GFile *file,
- const gchar *module_name)
+tracker_monitor_is_watched (TrackerMonitor *monitor,
+ GFile *file,
+ const gchar *module_name)
{
- GHashTable *monitors;
+ TrackerMonitorPrivate *priv;
+ GHashTable *monitors;
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (module_name != NULL, FALSE);
- monitors = g_hash_table_lookup (modules, module_name);
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
+
+ monitors = g_hash_table_lookup (priv->modules, module_name);
if (!monitors) {
g_warning ("No monitor hash table for module:'%s'",
module_name);
@@ -794,17 +577,22 @@
}
gboolean
-tracker_monitor_is_watched_by_string (const gchar *path,
- const gchar *module_name)
-{
- GFile *file;
- GHashTable *monitors;
- gboolean watched;
+tracker_monitor_is_watched_by_string (TrackerMonitor *monitor,
+ const gchar *path,
+ const gchar *module_name)
+{
+ TrackerMonitorPrivate *priv;
+ GFile *file;
+ GHashTable *monitors;
+ gboolean watched;
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
g_return_val_if_fail (module_name != NULL, FALSE);
- monitors = g_hash_table_lookup (modules, module_name);
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
+
+ monitors = g_hash_table_lookup (priv->modules, module_name);
if (!monitors) {
g_warning ("No monitor hash table for module:'%s'",
module_name);
@@ -819,14 +607,20 @@
}
guint
-tracker_monitor_get_count (const gchar *module_name)
+tracker_monitor_get_count (TrackerMonitor *monitor,
+ const gchar *module_name)
{
- guint count;
+ TrackerMonitorPrivate *priv;
+ guint count;
+
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), 0);
+
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
if (module_name) {
GHashTable *monitors;
- monitors = g_hash_table_lookup (modules, module_name);
+ monitors = g_hash_table_lookup (priv->modules, module_name);
if (!monitors) {
g_warning ("No monitor hash table for module:'%s'",
module_name);
@@ -837,7 +631,7 @@
} else {
GList *all_modules, *l;
- all_modules = g_hash_table_get_values (modules);
+ all_modules = g_hash_table_get_values (priv->modules);
for (l = all_modules, count = 0; l; l = l->next) {
count += g_hash_table_size (l->data);
@@ -850,7 +644,13 @@
}
guint
-tracker_monitor_get_ignored (void)
+tracker_monitor_get_ignored (TrackerMonitor *monitor)
{
- return monitors_ignored;
+ TrackerMonitorPrivate *priv;
+
+ g_return_val_if_fail (TRACKER_IS_MONITOR (monitor), 0);
+
+ priv = TRACKER_MONITOR_GET_PRIVATE (monitor);
+
+ return priv->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 Mon Jul 21 13:00:58 2008
@@ -22,24 +22,50 @@
#ifndef __TRACKERD_MONITOR_H__
#define __TRACKERD_MONITOR_H__
+#include <glib-object.h>
#include <gio/gio.h>
#include <libtracker-common/tracker-config.h>
G_BEGIN_DECLS
-gboolean tracker_monitor_init (TrackerConfig *config);
-void tracker_monitor_shutdown (void);
-gboolean tracker_monitor_add (GFile *file,
- const gchar *module_name);
-gboolean tracker_monitor_remove (GFile *file,
- const gchar *module_name);
-gboolean tracker_monitor_is_watched (GFile *file,
- const gchar *module_name);
-gboolean tracker_monitor_is_watched_by_string (const gchar *path,
- const gchar *module_name);
-guint tracker_monitor_get_count (const gchar *module_name);
-guint tracker_monitor_get_ignored (void);
+#define TRACKER_TYPE_MONITOR (tracker_monitor_get_type ())
+#define TRACKER_MONITOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TRACKER_TYPE_MONITOR, TrackerMonitor))
+#define TRACKER_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_MONITOR, TrackerMonitorClass))
+#define TRACKER_IS_MONITOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TRACKER_TYPE_MONITOR))
+#define TRACKER_IS_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_MONITOR))
+#define TRACKER_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_MONITOR, TrackerMonitorClass))
+
+typedef struct _TrackerMonitor TrackerMonitor;
+typedef struct _TrackerMonitorClass TrackerMonitorClass;
+typedef struct _TrackerMonitorPrivate TrackerMonitorPrivate;
+
+struct _TrackerMonitor {
+ GObject parent;
+ TrackerMonitorPrivate *private;
+};
+
+struct _TrackerMonitorClass {
+ GObjectClass parent;
+};
+
+GType tracker_monitor_get_type (void);
+TrackerMonitor *tracker_monitor_new (TrackerConfig *config);
+gboolean tracker_monitor_add (TrackerMonitor *monitor,
+ GFile *file,
+ const gchar *module_name);
+gboolean tracker_monitor_remove (TrackerMonitor *monitor,
+ GFile *file,
+ const gchar *module_name);
+gboolean tracker_monitor_is_watched (TrackerMonitor *monitor,
+ GFile *file,
+ const gchar *module_name);
+gboolean tracker_monitor_is_watched_by_string (TrackerMonitor *monitor,
+ const gchar *path,
+ const gchar *module_name);
+guint tracker_monitor_get_count (TrackerMonitor *monitor,
+ const gchar *module_name);
+guint tracker_monitor_get_ignored (TrackerMonitor *monitor);
G_END_DECLS
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 Mon Jul 21 13:00:58 2008
@@ -25,28 +25,53 @@
#include <glib.h>
#include <gio/gio.h>
-#include <libtracker-common/tracker-module-config.h>
+#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-file-utils.h>
#include <libtracker-common/tracker-hal.h>
+#include <libtracker-common/tracker-module-config.h>
#include <libtracker-common/tracker-utils.h>
#include "tracker-processor.h"
#include "tracker-crawler.h"
#include "tracker-dbus.h"
+#include "tracker-indexer-client.h"
#include "tracker-monitor.h"
#include "tracker-status.h"
#define TRACKER_PROCESSOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_PROCESSOR, TrackerProcessorPrivate))
+#define FILES_QUEUE_PROCESS_INTERVAL 2000
+#define FILES_QUEUE_PROCESS_MAX 5000
+
+typedef enum {
+ SENT_TYPE_NONE,
+ SENT_TYPE_CREATED,
+ SENT_TYPE_UPDATED,
+ SENT_TYPE_DELETED
+} SentType;
+
typedef struct TrackerProcessorPrivate TrackerProcessorPrivate;
struct TrackerProcessorPrivate {
TrackerConfig *config;
TrackerHal *hal;
+ TrackerMonitor *monitor;
TrackerCrawler *crawler;
DBusGProxy *indexer_proxy;
+ /* File queues for indexer */
+ guint files_queue_handlers_id;
+
+ GHashTable *files_created_queues;
+ GHashTable *files_updated_queues;
+ GHashTable *files_deleted_queues;
+
+ SentType sent_type;
+ GStrv sent_items;
+ const gchar *sent_module_name;
+
+ /* Status */
GList *modules;
GList *current_module;
@@ -67,6 +92,7 @@
};
static void tracker_processor_finalize (GObject *object);
+static void files_queue_destroy_notify (gpointer data);
static void process_next_module (TrackerProcessor *processor);
static void indexer_status_cb (DBusGProxy *proxy,
gdouble seconds_elapsed,
@@ -78,6 +104,18 @@
gdouble seconds_elapsed,
guint items_done,
gpointer user_data);
+static void monitor_item_created_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gpointer user_data);
+static void monitor_item_updated_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gpointer user_data);
+static void monitor_item_deleted_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gpointer user_data);
static void crawler_processing_directory_cb (TrackerCrawler *crawler,
const gchar *module_name,
GFile *file,
@@ -89,13 +127,13 @@
guint files_ignored,
gpointer user_data);
-#ifdef HAVE_HAL
-static void mount_point_added_cb (TrackerHal *hal,
- const gchar *mount_point,
- gpointer user_data);
-static void mount_point_removed_cb (TrackerHal *hal,
- const gchar *mount_point,
- gpointer user_data);
+#ifdef HAVE_HAL
+static void mount_point_added_cb (TrackerHal *hal,
+ const gchar *mount_point,
+ gpointer user_data);
+static void mount_point_removed_cb (TrackerHal *hal,
+ const gchar *mount_point,
+ gpointer user_data);
#endif /* HAVE_HAL */
static guint signals[LAST_SIGNAL] = { 0, };
@@ -125,10 +163,44 @@
tracker_processor_init (TrackerProcessor *processor)
{
TrackerProcessorPrivate *priv;
+ GList *l;
priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
priv->modules = tracker_module_config_get_modules ();
+
+ /* For each module we create a hash table for queues for items
+ * to update/create/delete in the indexer. This is sent on
+ * when the queue is processed.
+ */
+ priv->files_created_queues =
+ g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ files_queue_destroy_notify);
+ priv->files_updated_queues =
+ g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ files_queue_destroy_notify);
+ priv->files_deleted_queues =
+ g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ files_queue_destroy_notify);
+
+ for (l = priv->modules; l; l = l->next) {
+ /* Create queues for this module */
+ g_hash_table_insert (priv->files_created_queues,
+ g_strdup (l->data),
+ g_queue_new ());
+ g_hash_table_insert (priv->files_updated_queues,
+ g_strdup (l->data),
+ g_queue_new ());
+ g_hash_table_insert (priv->files_deleted_queues,
+ g_strdup (l->data),
+ g_queue_new ());
+ }
}
static void
@@ -144,6 +216,23 @@
g_timer_destroy (priv->timer);
}
+ if (priv->files_queue_handlers_id) {
+ g_source_remove (priv->files_queue_handlers_id);
+ priv->files_queue_handlers_id = 0;
+ }
+
+ if (priv->files_deleted_queues) {
+ g_hash_table_unref (priv->files_deleted_queues);
+ }
+
+ if (priv->files_updated_queues) {
+ g_hash_table_unref (priv->files_updated_queues);
+ }
+
+ if (priv->files_created_queues) {
+ g_hash_table_unref (priv->files_created_queues);
+ }
+
g_list_free (priv->modules);
dbus_g_proxy_disconnect_signal (priv->indexer_proxy, "Finished",
@@ -162,6 +251,17 @@
object);
g_object_unref (priv->crawler);
+ g_signal_handlers_disconnect_by_func (priv->monitor,
+ G_CALLBACK (monitor_item_deleted_cb),
+ object);
+ g_signal_handlers_disconnect_by_func (priv->monitor,
+ G_CALLBACK (monitor_item_updated_cb),
+ object);
+ g_signal_handlers_disconnect_by_func (priv->monitor,
+ G_CALLBACK (monitor_item_created_cb),
+ object);
+ g_object_unref (priv->monitor);
+
#ifdef HAVE_HAL
if (priv->hal) {
g_signal_handlers_disconnect_by_func (priv->hal,
@@ -180,6 +280,225 @@
G_OBJECT_CLASS (tracker_processor_parent_class)->finalize (object);
}
+static GQueue *
+get_next_queue_with_data (GHashTable *hash_table,
+ gchar **module_name_p)
+{
+ GQueue *queue;
+ GList *all_modules, *l;
+ gchar *module_name;
+
+ if (module_name_p) {
+ *module_name_p = NULL;
+ }
+
+ all_modules = g_hash_table_get_keys (hash_table);
+
+ for (l = all_modules, queue = NULL; l && !queue; l = l->next) {
+ module_name = l->data;
+ queue = g_hash_table_lookup (hash_table, module_name);
+
+ if (g_queue_get_length (queue) > 0) {
+ if (module_name_p) {
+ *module_name_p = module_name;
+ }
+
+ continue;
+ }
+
+ queue = NULL;
+ }
+
+ g_list_free (all_modules);
+
+ return queue;
+}
+
+static void
+files_queue_destroy_notify (gpointer data)
+{
+ GQueue *queue;
+
+ queue = (GQueue *) data;
+
+ g_queue_foreach (queue, (GFunc) g_free, NULL);
+ g_queue_free (queue);
+}
+
+static void
+file_queue_readd_items (GQueue *queue,
+ GStrv strv)
+{
+ if (queue) {
+ GStrv p;
+ gint i;
+
+ for (p = strv, i = 0; *p; p++, i++) {
+ g_queue_push_nth (queue, g_strdup (*p), i);
+ }
+ }
+}
+
+static void
+file_queue_processed_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
+{
+ TrackerProcessorPrivate *priv;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (user_data);
+
+ if (error) {
+ GQueue *queue;
+
+ g_message ("Monitor events could not be processed by the indexer, %s",
+ error->message);
+ g_error_free (error);
+
+ /* Put files back into queue */
+ switch (priv->sent_type) {
+ case SENT_TYPE_NONE:
+ queue = NULL;
+ break;
+ case SENT_TYPE_CREATED:
+ queue = g_hash_table_lookup (priv->files_created_queues,
+ priv->sent_module_name);
+ break;
+ case SENT_TYPE_UPDATED:
+ queue = g_hash_table_lookup (priv->files_updated_queues,
+ priv->sent_module_name);
+ break;
+ case SENT_TYPE_DELETED:
+ queue = g_hash_table_lookup (priv->files_deleted_queues,
+ priv->sent_module_name);
+ break;
+ }
+
+ file_queue_readd_items (queue, priv->sent_items);
+ } else {
+ g_debug ("Sent!");
+ }
+
+ g_strfreev (priv->sent_items);
+
+ /* Reset for next batch to be sent */
+ priv->sent_items = NULL;
+ priv->sent_module_name = NULL;
+ priv->sent_type = SENT_TYPE_NONE;
+}
+
+static gboolean
+file_queue_handlers_cb (gpointer user_data)
+{
+ TrackerProcessor *processor;
+ TrackerProcessorPrivate *priv;
+ GQueue *queue;
+ GStrv files;
+ gchar *module_name;
+
+ processor = TRACKER_PROCESSOR (user_data);
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ /* This is here so we don't try to send something if we are
+ * still waiting for a response from the last send.
+ */
+ if (priv->sent_type != SENT_TYPE_NONE) {
+ g_message ("Still waiting for response from indexer, "
+ "not sending more files yet");
+ return TRUE;
+ }
+
+ /* Process the deleted items first */
+ queue = get_next_queue_with_data (priv->files_deleted_queues, &module_name);
+
+ if (queue && g_queue_get_length (queue) > 0) {
+ /* First do the deleted queue */
+ files = tracker_dbus_queue_str_to_strv (queue, FILES_QUEUE_PROCESS_MAX);
+
+ g_message ("Monitor events queue for deleted items processed, sending first %d to the indexer",
+ g_strv_length (files));
+
+ priv->sent_type = SENT_TYPE_DELETED;
+ priv->sent_module_name = module_name;
+ priv->sent_items = files;
+
+ org_freedesktop_Tracker_Indexer_files_delete_async (priv->indexer_proxy,
+ module_name,
+ (const gchar **) files,
+ file_queue_processed_cb,
+ processor);
+
+ return TRUE;
+ }
+
+ /* Process the deleted items first */
+ queue = get_next_queue_with_data (priv->files_created_queues, &module_name);
+
+ if (queue && g_queue_get_length (queue) > 0) {
+ /* First do the deleted queue */
+ files = tracker_dbus_queue_str_to_strv (queue, FILES_QUEUE_PROCESS_MAX);
+
+ g_message ("Monitor events queue for created items processed, sending first %d to the indexer",
+ g_strv_length (files));
+
+ priv->sent_type = SENT_TYPE_CREATED;
+ priv->sent_module_name = module_name;
+ priv->sent_items = files;
+
+ org_freedesktop_Tracker_Indexer_files_delete_async (priv->indexer_proxy,
+ module_name,
+ (const gchar **) files,
+ file_queue_processed_cb,
+ processor);
+
+ return TRUE;
+ }
+
+ /* Process the deleted items first */
+ queue = get_next_queue_with_data (priv->files_updated_queues, &module_name);
+
+ if (queue && g_queue_get_length (queue) > 0) {
+ /* First do the deleted queue */
+ files = tracker_dbus_queue_str_to_strv (queue, FILES_QUEUE_PROCESS_MAX);
+
+ g_message ("Monitor events queue for updated items processed, sending first %d to the indexer",
+ g_strv_length (files));
+
+ priv->sent_type = SENT_TYPE_UPDATED;
+ priv->sent_module_name = module_name;
+ priv->sent_items = files;
+
+ org_freedesktop_Tracker_Indexer_files_delete_async (priv->indexer_proxy,
+ module_name,
+ (const gchar **) files,
+ file_queue_processed_cb,
+ processor);
+
+ return TRUE;
+ }
+
+ g_message ("No monitor events to process, doing nothing");
+ priv->files_queue_handlers_id = 0;
+
+ return FALSE;
+}
+
+static void
+file_queue_handlers_set_up (TrackerProcessor *processor)
+{
+ TrackerProcessorPrivate *priv;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (processor);
+
+ if (priv->files_queue_handlers_id != 0) {
+ return;
+ }
+
+ priv->files_queue_handlers_id = g_timeout_add (FILES_QUEUE_PROCESS_INTERVAL,
+ file_queue_handlers_cb,
+ processor);
+}
+
static void
process_module (TrackerProcessor *processor,
const gchar *module_name)
@@ -296,14 +615,75 @@
}
static void
+monitor_item_created_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gpointer user_data)
+{
+ TrackerProcessorPrivate *priv;
+ GQueue *queue;
+ gchar *path;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (user_data);
+
+ queue = g_hash_table_lookup (priv->files_created_queues, module_name);
+ path = g_file_get_path (file);
+ g_queue_push_tail (queue, path);
+
+ file_queue_handlers_set_up (user_data);
+}
+
+static void
+monitor_item_updated_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gpointer user_data)
+{
+ TrackerProcessorPrivate *priv;
+ GQueue *queue;
+ gchar *path;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (user_data);
+
+ queue = g_hash_table_lookup (priv->files_updated_queues, module_name);
+ path = g_file_get_path (file);
+ g_queue_push_tail (queue, path);
+
+ file_queue_handlers_set_up (user_data);
+}
+
+static void
+monitor_item_deleted_cb (TrackerMonitor *monitor,
+ const gchar *module_name,
+ GFile *file,
+ gpointer user_data)
+{
+ TrackerProcessorPrivate *priv;
+ GQueue *queue;
+ gchar *path;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (user_data);
+
+ queue = g_hash_table_lookup (priv->files_deleted_queues, module_name);
+ path = g_file_get_path (file);
+ g_queue_push_tail (queue, path);
+
+ file_queue_handlers_set_up (user_data);
+}
+
+static void
crawler_processing_directory_cb (TrackerCrawler *crawler,
const gchar *module_name,
GFile *file,
gpointer user_data)
{
-#if 1
+ TrackerProcessorPrivate *priv;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (user_data);
+
+#if 0
/* FIXME: We are doing this for now because the code is really inefficient */
- tracker_monitor_add (file, module_name);
+ tracker_monitor_add (priv->monitor, file, module_name);
#else
GList *directories, *l;
gchar *path;
@@ -339,7 +719,7 @@
/* Should we add? */
if (add_monitor) {
- tracker_monitor_add (file, module_name);
+ tracker_monitor_add (priv->monitor, file, module_name);
}
g_free (path);
@@ -427,6 +807,18 @@
processor);
#endif /* HAVE_HAL */
+ priv->monitor = tracker_monitor_new (config);
+
+ g_signal_connect (priv->monitor, "item-created",
+ G_CALLBACK (monitor_item_created_cb),
+ processor);
+ g_signal_connect (priv->monitor, "item-updated",
+ G_CALLBACK (monitor_item_updated_cb),
+ processor);
+ g_signal_connect (priv->monitor, "item-deleted",
+ G_CALLBACK (monitor_item_deleted_cb),
+ processor);
+
priv->crawler = tracker_crawler_new (config, hal);
g_signal_connect (priv->crawler, "processing-directory",
@@ -504,7 +896,7 @@
priv->files_found,
priv->files_ignored);
g_message ("Total monitors : %d\n",
- tracker_monitor_get_count (NULL));
+ tracker_monitor_get_count (priv->monitor, NULL));
/* Here we set to IDLE when we were stopped, otherwise, we
* we are currently in the process of sending files to the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]