tracker r1886 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1886 - in branches/indexer-split: . src/trackerd
- Date: Thu, 17 Jul 2008 16:13:37 +0000 (UTC)
Author: mr
Date: Thu Jul 17 16:13:37 2008
New Revision: 1886
URL: http://svn.gnome.org/viewvc/tracker?rev=1886&view=rev
Log:
* src/trackerd/tracker-crawler.c:
* src/trackerd/tracker-processor.c:
* src/trackerd/tracker-main.c: Initialize module config before
initializing the monitor module. The monitor module uses the
module config to set up queues and hash tables.
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 Thu Jul 17 16:13:37 2008
@@ -652,9 +652,10 @@
static void
process_directory (TrackerCrawler *crawler,
- GFile *file)
+ GFile *file,
+ const gchar *module_name)
{
- tracker_monitor_add (file);
+ tracker_monitor_add (file, module_name);
file_enumerate_children (crawler, file);
}
@@ -665,6 +666,7 @@
TrackerCrawler *crawler;
GQueue *queue = NULL;
GFile *file;
+ gchar *module_name;
crawler = TRACKER_CRAWLER (data);
@@ -685,14 +687,14 @@
}
/* Get the first files queue with data and process it. */
- queue = queue_get_next_for_directories_with_data (crawler, NULL);
+ queue = queue_get_next_for_directories_with_data (crawler, &module_name);
if (queue) {
/* Crawler directory contents */
file = g_queue_pop_head (queue);
if (file) {
- process_directory (crawler, file);
+ process_directory (crawler, file, module_name);
g_object_unref (file);
return TRUE;
@@ -1007,7 +1009,7 @@
priv->directories_ignored = 0;
priv->files_found = 0;
priv->files_ignored = 0;
- priv->monitors_added = tracker_monitor_get_count ();
+ priv->monitors_added = tracker_monitor_get_count (module_name);
priv->monitors_ignored = tracker_monitor_get_ignored ();
for (sl = paths; sl; sl = sl->next) {
@@ -1033,6 +1035,19 @@
priv = crawler->private;
+ g_message (" %s crawling files in %4.4f seconds",
+ priv->finished ? "Finished" : "Stopped",
+ g_timer_elapsed (priv->timer, NULL));
+ g_message (" Found %d directories, ignored %d directories",
+ priv->directories_found,
+ priv->directories_ignored);
+ g_message (" Found %d files, ignored %d files",
+ priv->files_found,
+ priv->files_ignored);
+ g_message (" Added %d monitors, ignored %d monitors",
+ tracker_monitor_get_count (priv->current_module_name),
+ tracker_monitor_get_ignored () - priv->monitors_ignored);
+
priv->running = FALSE;
if (priv->idle_id) {
@@ -1057,21 +1072,6 @@
priv->ignored_directory_patterns = NULL;
}
- g_timer_stop (priv->timer);
-
- g_message (" %s crawling files in %4.4f seconds",
- priv->finished ? "Finished" : "Stopped",
- g_timer_elapsed (priv->timer, NULL));
- g_message (" Found %d directories, ignored %d directories",
- priv->directories_found,
- priv->directories_ignored);
- g_message (" Found %d files, ignored %d files",
- priv->files_found,
- priv->files_ignored);
- g_message (" Added %d monitors, ignored %d monitors",
- tracker_monitor_get_count () - priv->monitors_added,
- tracker_monitor_get_ignored () - priv->monitors_ignored);
-
g_timer_destroy (priv->timer);
priv->timer = NULL;
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 Thu Jul 17 16:13:37 2008
@@ -700,6 +700,8 @@
return EXIT_FAILURE;
}
+ tracker_module_config_init ();
+
if (!tracker_monitor_init (config)) {
return EXIT_FAILURE;
}
@@ -755,7 +757,6 @@
tracker_db_init (config, language, file_index);
tracker_xesam_manager_init ();
- tracker_module_config_init ();
processor = tracker_processor_new (config, hal);
@@ -815,12 +816,12 @@
shutdown_directories ();
/* Shutdown major subsystems */
- tracker_module_config_shutdown ();
tracker_xesam_manager_shutdown ();
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 Thu Jul 17 16:13:37 2008
@@ -23,6 +23,7 @@
#include <libtracker-common/tracker-dbus.h>
#include <libtracker-common/tracker-file-utils.h>
+#include <libtracker-common/tracker-module-config.h>
#include "tracker-monitor.h"
#include "tracker-dbus.h"
@@ -31,16 +32,29 @@
#define FILES_QUEUE_PROCESS_INTERVAL 2000
#define FILES_QUEUE_PROCESS_MAX 5000
+typedef enum {
+ SENT_DATA_TYPE_CREATED,
+ SENT_DATA_TYPE_UPDATED,
+ SENT_DATA_TYPE_DELETED
+} SentDataType;
+
+typedef struct {
+ SentDataType type;
+ GQueue *queue;
+ GStrv files;
+ const gchar *module_name;
+} SentData;
+
+static gboolean initialized;
+
static TrackerConfig *config;
-static GHashTable *monitors;
-static GQueue *files_created;
-static GQueue *files_updated;
-static GQueue *files_deleted;
-
-static gboolean files_created_sent;
-static gboolean files_updated_sent;
-static gboolean files_deleted_sent;
+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;
@@ -51,7 +65,7 @@
static guint monitors_ignored;
static guint
-monitor_get_inotify_limit (void)
+get_inotify_limit (void)
{
GError *error = NULL;
const gchar *filename;
@@ -79,118 +93,184 @@
return limit;
}
+static const gchar *
+get_queue_from_gfile (GFile *file)
+{
+ GHashTable *hash_table;
+ GList *all_modules, *l;
+ const gchar *module_name = NULL;
+
+ 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;
+ }
+ }
+
+ g_list_free (all_modules);
+
+ return module_name;
+}
+
+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);
+}
+
gboolean
-tracker_monitor_init (TrackerConfig *_config)
+tracker_monitor_init (TrackerConfig *this_config)
{
- g_return_val_if_fail (TRACKER_IS_CONFIG (_config), FALSE);
+ GFile *file;
+ GFileMonitor *monitor;
+ GList *all_modules, *l;
+ const gchar *name;
+
+ g_return_val_if_fail (TRACKER_IS_CONFIG (this_config), FALSE);
- if (!config) {
- config = g_object_ref (_config);
+ if (initialized) {
+ return TRUE;
}
+
+ config = g_object_ref (this_config);
- if (!monitors) {
+ /* 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);
+
+ all_modules = tracker_module_config_get_modules ();
+
+ for (l = all_modules; l; l = l->next) {
+ GHashTable *monitors;
+
+ /* Create monitors table for this module */
monitors = g_hash_table_new_full (g_file_hash,
(GEqualFunc) g_file_equal,
(GDestroyNotify) g_object_unref,
(GDestroyNotify) g_file_monitor_cancel);
- }
+
+ g_hash_table_insert (modules, g_strdup (l->data), monitors);
- if (!files_created) {
- files_created = g_queue_new ();
+ /* 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 ());
}
- if (!files_updated) {
- files_updated = g_queue_new ();
- }
-
- if (!files_deleted) {
- files_deleted = g_queue_new ();
- }
+ g_list_free (all_modules);
/* For the first monitor we get the type and find out if we
* are using inotify, FAM, polling, etc.
*/
- if (monitor_backend == 0) {
- GFile *file;
- GFileMonitor *monitor;
- const gchar *name;
-
- file = g_file_new_for_path (g_get_home_dir ());
- monitor = g_file_monitor_directory (file,
- G_FILE_MONITOR_WATCH_MOUNTS,
- NULL,
- NULL);
-
- 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);
- if (name) {
- /* Set limits based on backend... */
- if (strcmp (name, "GInotifyDirectoryMonitor") == 0) {
- /* Using inotify */
- g_message ("Monitor backend is INotify");
-
- /* Setting limit based on kernel
- * settings in /proc...
- */
- monitor_limit = monitor_get_inotify_limit ();
-
- /* We don't use 100% of the monitors, we allow other
- * applications to have at least 500 or so to use
- * between them selves. This only
- * applies to inotify because it is a
- * user shared resource.
- */
- monitor_limit -= 500;
-
- /* Make sure we don't end up with a
- * negative maximum.
- */
- monitor_limit = MAX (monitor_limit, 0);
- }
- else if (strcmp (name, "GFamDirectoryMonitor") == 0) {
- /* Using Fam */
- g_message ("Monitor backend is Fam");
-
- /* Setting limit to an arbitary limit
- * based on testing
- */
- 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;
- }
- else if (strcmp (name, "GWin32DirectoryMonitor") == 0) {
- /* Using Windows */
- g_message ("Monitor backend is Windows");
-
- /* Guessing limit... */
- monitor_limit = 8192;
- }
- else {
- /* Unknown */
- g_warning ("Monitor backend:'%s' is unknown, we have no limits "
- "in place because we don't know what we are dealing with!",
- name);
-
- /* Guessing limit... */
- monitor_limit = 100;
- }
+ file = g_file_new_for_path (g_get_home_dir ());
+ monitor = g_file_monitor_directory (file,
+ G_FILE_MONITOR_WATCH_MOUNTS,
+ NULL,
+ NULL);
+
+ 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);
+ if (name) {
+ /* Set limits based on backend... */
+ if (strcmp (name, "GInotifyDirectoryMonitor") == 0) {
+ /* Using inotify */
+ g_message ("Monitor backend is INotify");
+
+ /* Setting limit based on kernel
+ * settings in /proc...
+ */
+ 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
+ * between them selves. This only
+ * applies to inotify because it is a
+ * user shared resource.
+ */
+ monitor_limit -= 500;
+
+ /* Make sure we don't end up with a
+ * negative maximum.
+ */
+ monitor_limit = MAX (monitor_limit, 0);
+ }
+ else if (strcmp (name, "GFamDirectoryMonitor") == 0) {
+ /* Using Fam */
+ g_message ("Monitor backend is Fam");
+
+ /* Setting limit to an arbitary limit
+ * based on testing
+ */
+ 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;
+ }
+ else if (strcmp (name, "GWin32DirectoryMonitor") == 0) {
+ /* Using Windows */
+ g_message ("Monitor backend is Windows");
+
+ /* Guessing limit... */
+ monitor_limit = 8192;
+ }
+ else {
+ /* Unknown */
+ g_warning ("Monitor backend:'%s' is unknown, we have no limits "
+ "in place because we don't know what we are dealing with!",
+ name);
+
+ /* Guessing limit... */
+ monitor_limit = 100;
}
-
- g_message ("Monitor limit is %d", monitor_limit);
-
- g_file_monitor_cancel (monitor);
- g_object_unref (file);
}
+
+ g_message ("Monitor limit is %d", monitor_limit);
+
+ g_file_monitor_cancel (monitor);
+ g_object_unref (file);
+
+ initialized = TRUE;
return TRUE;
}
@@ -198,6 +278,10 @@
void
tracker_monitor_shutdown (void)
{
+ if (!initialized) {
+ return;
+ }
+
monitors_ignored = 0;
monitor_limit_warned = FALSE;
monitor_limit = 0;
@@ -208,194 +292,229 @@
files_queue_handlers_id = 0;
}
- g_queue_foreach (files_deleted, (GFunc) g_free, NULL);
- g_queue_free (files_deleted);
+ if (files_deleted_queues) {
+ g_hash_table_unref (files_deleted_queues);
+ files_deleted_queues = NULL;
+ }
- g_queue_foreach (files_updated, (GFunc) g_free, NULL);
- g_queue_free (files_updated);
+ if (files_updated_queues) {
+ g_hash_table_unref (files_updated_queues);
+ files_updated_queues = NULL;
+ }
- g_queue_foreach (files_created, (GFunc) g_free, NULL);
- g_queue_free (files_created);
+ if (files_created_queues) {
+ g_hash_table_unref (files_created_queues);
+ files_created_queues = NULL;
+ }
- if (monitors) {
- g_hash_table_unref (monitors);
- monitors = NULL;
+ if (modules) {
+ g_hash_table_unref (modules);
+ modules = NULL;
}
if (config) {
g_object_unref (config);
config = NULL;
}
+
+ initialized = FALSE;
}
-static void
-file_queue_readd_items (GQueue *queue,
- GStrv strv)
+static SentData *
+sent_data_new (SentDataType type,
+ GQueue *queue,
+ GStrv files,
+ const gchar *module_name)
{
- if (queue) {
- GStrv p;
- gint i;
-
- for (p = strv, i = 0; *p; p++, i++) {
- g_queue_push_nth (queue, g_strdup (*p), i);
- }
- }
+ SentData *sd;
+
+ sd = g_slice_new0 (SentData);
+ sd->type = type;
+ sd->queue = queue;
+ sd->files = files;
+ sd->module_name = module_name;
+
+ return sd;
}
static void
-file_queue_processed_deleted_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
+sent_data_free (SentData *sd)
+{
+ g_strfreev (sd->files);
+ g_slice_free (SentData, sd);
+}
+
+static GQueue *
+get_next_queue_with_data (GHashTable *hash_table,
+ gchar **module_name_p)
{
- GStrv files;
+ 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);
- files = (GStrv) user_data;
+ 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 (error) {
- g_message ("Files could not be deleted by the indexer, %s",
- error->message);
- g_error_free (error);
+ if (g_queue_get_length (queue) > 0) {
+ if (module_name_p) {
+ *module_name_p = module_name;
+ }
- /* Put files back into queue */
- file_queue_readd_items (files_deleted, files);
- } else {
- g_debug ("Sent!");
+ continue;
+ }
+
+ queue = NULL;
}
+
+ g_list_free (all_modules);
- g_strfreev (files);
- files_deleted_sent = FALSE;
+ return queue;
}
static void
-file_queue_processed_created_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
+file_queue_readd_items (GQueue *queue,
+ GStrv strv)
{
- GStrv files;
-
- files = (GStrv) user_data;
-
- if (error) {
- g_message ("Files could not be created by the indexer, %s",
- error->message);
- g_error_free (error);
-
- /* Put files back into queue */
- file_queue_readd_items (files_created, files);
- } else {
- g_debug ("Sent!");
+ if (queue) {
+ GStrv p;
+ gint i;
+
+ for (p = strv, i = 0; *p; p++, i++) {
+ g_queue_push_nth (queue, g_strdup (*p), i);
+ }
}
-
- g_strfreev (files);
- files_created_sent = FALSE;
}
static void
-file_queue_processed_updated_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
+file_queue_processed_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
{
- GStrv files;
+ SentData *sd;
- files = (GStrv) user_data;
+ sd = (SentData*) user_data;
if (error) {
- g_message ("Files could not be updated by the indexer, %s",
+ 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 (files_updated, files);
+ file_queue_readd_items (sd->queue, sd->files);
} else {
g_debug ("Sent!");
}
- g_strfreev (files);
- files_updated_sent = FALSE;
+ /* 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;
- GStrv files;
- gint items_to_process = 0;
-
- /* FIXME: We need to know what service these files belong to... */
+ 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 (files_created_sent ||
- files_updated_sent ||
- files_deleted_sent) {
+ */
+ 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;
}
- items_to_process += g_queue_get_length (files_created);
- items_to_process += g_queue_get_length (files_updated);
- items_to_process += g_queue_get_length (files_deleted);
-
- if (items_to_process < 1) {
- g_debug ("All queues are empty... nothing to do");
- files_queue_handlers_id = 0;
- return FALSE;
- }
-
/* Check we can actually talk to the indexer */
proxy = tracker_dbus_indexer_get_proxy ();
+
+ /* Process the deleted items first */
+ queue = get_next_queue_with_data (files_deleted_queues, &module_name);
- /* First do the deleted queue */
- g_debug ("Files deleted queue being processed...");
- files = tracker_dbus_queue_str_to_strv (files_deleted, FILES_QUEUE_PROCESS_MAX);
-
- if (g_strv_length (files) > 0) {
- g_debug ("Files deleted queue processed, sending first %d to the indexer",
- g_strv_length (files));
+ 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);
- files_deleted_sent = TRUE;
org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
- "files",
+ module_name,
(const gchar **) files,
- file_queue_processed_deleted_cb,
- files);
+ file_queue_processed_cb,
+ sd);
+
+ return TRUE;
}
- /* Second do the created queue */
- g_debug ("Files created queue being processed...");
- files = tracker_dbus_queue_str_to_strv (files_created, FILES_QUEUE_PROCESS_MAX);
+ /* 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));
- if (g_strv_length (files) > 0) {
- g_debug ("Files created queue 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);
- files_created_sent = TRUE;
- org_freedesktop_Tracker_Indexer_files_check_async (proxy,
- "files",
- (const gchar **) files,
- file_queue_processed_created_cb,
- files);
+ org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
+ module_name,
+ (const gchar **) files,
+ file_queue_processed_cb,
+ sd);
+
+ return TRUE;
}
- /* Second do the updated queue */
- g_debug ("Files updated queue being processed...");
- files = tracker_dbus_queue_str_to_strv (files_updated, FILES_QUEUE_PROCESS_MAX);
-
- if (g_strv_length (files) > 0) {
- g_debug ("Files updated queue processed, sending first %d to the indexer",
- g_strv_length (files));
+ /* Process the deleted items first */
+ queue = get_next_queue_with_data (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));
+
+ type = SENT_DATA_TYPE_UPDATED;
+ sent_data[type] = TRUE;
+ sd = sent_data_new (type, queue, files, module_name);
- files_updated_sent = TRUE;
- org_freedesktop_Tracker_Indexer_files_update_async (proxy,
- "files",
+ org_freedesktop_Tracker_Indexer_files_delete_async (proxy,
+ module_name,
(const gchar **) files,
- file_queue_processed_updated_cb,
- files);
+ file_queue_processed_cb,
+ sd);
+
+ return TRUE;
}
- return TRUE;
+ g_message ("No monitor events to process, doing nothing");
+ files_queue_handlers_id = 0;
+
+ return FALSE;
}
static void
@@ -440,11 +559,39 @@
GFileMonitorEvent event_type,
gpointer user_data)
{
- gchar *str1;
- gchar *str2;
+ GQueue *queue;
+ const gchar *module_name;
+ gchar *str1;
+ gchar *str2;
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);
+ if (!module_name) {
+ GFile *parent;
+
+ /* Second we try to get the module name from the base
+ * name of the file.
+ */
+ parent = g_file_get_parent (file);
+ module_name = get_queue_from_gfile (parent);
+
+ if (!module_name) {
+ gchar *path;
+
+ path = g_file_get_path (parent);
+ g_warning ("Could not get module name from GFile (path:'%s' or parent:'%s')",
+ str1, path);
+ g_free (path);
+ g_free (str1);
+
+ return;
+ }
+ }
+
if (other_file) {
str2 = g_file_get_path (other_file);
} else {
@@ -459,19 +606,22 @@
switch (event_type) {
case G_FILE_MONITOR_EVENT_CHANGED:
- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
- g_queue_push_tail (files_updated, str1);
+ queue = g_hash_table_lookup (files_updated_queues, module_name);
+ g_queue_push_tail (queue, str1);
file_queue_handlers_set_up ();
break;
case G_FILE_MONITOR_EVENT_DELETED:
- g_queue_push_tail (files_deleted, str1);
+ queue = g_hash_table_lookup (files_deleted_queues, module_name);
+ g_queue_push_tail (queue, str1);
file_queue_handlers_set_up ();
break;
case G_FILE_MONITOR_EVENT_CREATED:
- g_queue_push_tail (files_created, str1);
+ queue = g_hash_table_lookup (files_created_queues, module_name);
+ g_queue_push_tail (queue, str1);
file_queue_handlers_set_up ();
break;
@@ -486,20 +636,30 @@
}
gboolean
-tracker_monitor_add (GFile *file)
+tracker_monitor_add (GFile *file,
+ const gchar *module_name)
{
GFileMonitor *monitor;
+ GHashTable *monitors;
GSList *ignored_roots;
GSList *l;
GError *error = NULL;
gchar *path;
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)) {
return TRUE;
}
+ monitors = g_hash_table_lookup (modules, module_name);
+ if (!monitors) {
+ g_warning ("No monitor hash table for module:'%s'",
+ module_name);
+ return FALSE;
+ }
+
if (g_hash_table_lookup (monitors, file)) {
return TRUE;
}
@@ -554,13 +714,14 @@
g_signal_connect (monitor, "changed",
G_CALLBACK (monitor_event_cb),
- NULL);
+ monitors);
- g_hash_table_insert (monitors,
+ g_hash_table_insert (monitors,
g_object_ref (file),
monitor);
- g_debug ("Added monitor for:'%s', total monitors:%d",
+ g_debug ("Added monitor for module:'%s', path:'%s', total monitors:%d",
+ module_name,
path,
g_hash_table_size (monitors));
@@ -570,18 +731,27 @@
}
gboolean
-tracker_monitor_remove (GFile *file,
- gboolean delete_subdirs)
+tracker_monitor_remove (GFile *file,
+ const gchar *module_name)
{
GFileMonitor *monitor;
+ GHashTable *monitors;
gchar *path;
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)) {
return TRUE;
}
+ monitors = g_hash_table_lookup (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) {
return TRUE;
@@ -594,7 +764,8 @@
path = g_file_get_path (file);
- g_debug ("Removed monitor for:'%s', total monitors:%d",
+ g_debug ("Removed monitor for module:'%s', path:'%s', total monitors:%d",
+ module_name,
path,
g_hash_table_size (monitors));
@@ -604,20 +775,41 @@
}
gboolean
-tracker_monitor_is_watched (GFile *file)
+tracker_monitor_is_watched (GFile *file,
+ const gchar *module_name)
{
+ GHashTable *monitors;
+
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);
+ if (!monitors) {
+ g_warning ("No monitor hash table for module:'%s'",
+ module_name);
+ return FALSE;
+ }
return g_hash_table_lookup (monitors, file) != NULL;
}
gboolean
-tracker_monitor_is_watched_by_string (const gchar *path)
+tracker_monitor_is_watched_by_string (const gchar *path,
+ const gchar *module_name)
{
- GFile *file;
- gboolean watched;
+ GFile *file;
+ GHashTable *monitors;
+ gboolean watched;
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);
+ if (!monitors) {
+ g_warning ("No monitor hash table for module:'%s'",
+ module_name);
+ return FALSE;
+ }
file = g_file_new_for_path (path);
watched = g_hash_table_lookup (monitors, file) != NULL;
@@ -627,9 +819,34 @@
}
guint
-tracker_monitor_get_count (void)
+tracker_monitor_get_count (const gchar *module_name)
{
- return g_hash_table_size (monitors);
+ guint count;
+
+ if (module_name) {
+ GHashTable *monitors;
+
+ monitors = g_hash_table_lookup (modules, module_name);
+ if (!monitors) {
+ g_warning ("No monitor hash table for module:'%s'",
+ module_name);
+ return 0;
+ }
+
+ count = g_hash_table_size (monitors);
+ } else {
+ GList *all_modules, *l;
+
+ all_modules = g_hash_table_get_values (modules);
+
+ for (l = all_modules, count = 0; l; l = l->next) {
+ count += g_hash_table_size (l->data);
+ }
+
+ g_list_free (all_modules);
+ }
+
+ return count;
}
guint
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 Thu Jul 17 16:13:37 2008
@@ -30,12 +30,15 @@
gboolean tracker_monitor_init (TrackerConfig *config);
void tracker_monitor_shutdown (void);
-gboolean tracker_monitor_add (GFile *file);
+gboolean tracker_monitor_add (GFile *file,
+ const gchar *module_name);
gboolean tracker_monitor_remove (GFile *file,
- gboolean delete_subdirs);
-gboolean tracker_monitor_is_watched (GFile *file);
-gboolean tracker_monitor_is_watched_by_string (const gchar *path);
-guint tracker_monitor_get_count (void);
+ 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);
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 Thu Jul 17 16:13:37 2008
@@ -179,12 +179,12 @@
}
static void
-add_monitors (const gchar *name)
+add_monitors (const gchar *module_name)
{
GList *monitors;
GList *l;
- monitors = tracker_module_config_get_monitor_directories (name);
+ monitors = tracker_module_config_get_monitor_directories (module_name);
for (l = monitors; l; l = l->next) {
GFile *file;
@@ -195,7 +195,7 @@
g_message (" Adding specific directory monitor:'%s'", path);
file = g_file_new_for_path (path);
- tracker_monitor_add (file);
+ tracker_monitor_add (file, module_name);
g_object_unref (file);
}
@@ -207,12 +207,12 @@
}
static void
-add_recurse_monitors (const gchar *name)
+add_recurse_monitors (const gchar *module_name)
{
GList *monitors;
GList *l;
- monitors = tracker_module_config_get_monitor_recurse_directories (name);
+ monitors = tracker_module_config_get_monitor_recurse_directories (module_name);
for (l = monitors; l; l = l->next) {
GFile *file;
@@ -223,7 +223,7 @@
g_message (" Adding recurse directory monitor:'%s' (FIXME: Not finished)", path);
file = g_file_new_for_path (path);
- tracker_monitor_add (file);
+ tracker_monitor_add (file, module_name);
g_object_unref (file);
}
@@ -515,7 +515,7 @@
priv->files_found,
priv->files_ignored);
g_message ("Total monitors : %d\n",
- tracker_monitor_get_count ());
+ tracker_monitor_get_count (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]