tracker r1916 - in branches/indexer-split: . data/dbus src/libtracker-common src/tracker-indexer src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1916 - in branches/indexer-split: . data/dbus src/libtracker-common src/tracker-indexer src/trackerd
- Date: Wed, 23 Jul 2008 14:15:37 +0000 (UTC)
Author: mr
Date: Wed Jul 23 14:15:37 2008
New Revision: 1916
URL: http://svn.gnome.org/viewvc/tracker?rev=1916&view=rev
Log:
* data/dbus/tracker-indexer.xml:
* src/tracker-indexer/tracker-indexer.[ch]: Changed _set_paused()
API to have _pause(), _continue() and _pause_for_duration().
* src/libtracker-common/tracker-dbus.[ch]:
* src/trackerd/tracker-daemon.c:
* src/trackerd/tracker-dbus.[ch]:
* src/trackerd/tracker-files.c:
* src/trackerd/tracker-keywords.c:
* src/trackerd/tracker-metadata.c:
* src/trackerd/tracker-search.c:
* src/trackerd/tracker-xesam.c: Completely rework Phillip's patch
to pause the indexer when daemon requests come in. Instead of
littering the DBus code with pause/continue calls, we add a
hook to the DBus request_new() and request_{success|failed)()
functions so we know when a request starts and ends. We then
simply pause the indexer and wait for at least 10 seconds of
DBus request inactivity before allowing the indexer to continue as
normal.
* src/trackerd/tracker-main.c: Used the new _pause_for_duration()
API when shutting down because sometimes the daemon has to wait
because the indexer has the lock on the database.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/dbus/tracker-indexer.xml
branches/indexer-split/src/libtracker-common/tracker-dbus.c
branches/indexer-split/src/libtracker-common/tracker-dbus.h
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.h
branches/indexer-split/src/trackerd/tracker-daemon.c
branches/indexer-split/src/trackerd/tracker-dbus.c
branches/indexer-split/src/trackerd/tracker-dbus.h
branches/indexer-split/src/trackerd/tracker-files.c
branches/indexer-split/src/trackerd/tracker-keywords.c
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-metadata.c
branches/indexer-split/src/trackerd/tracker-search.c
branches/indexer-split/src/trackerd/tracker-xesam.c
Modified: branches/indexer-split/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-indexer.xml (original)
+++ branches/indexer-split/data/dbus/tracker-indexer.xml Wed Jul 23 14:15:37 2008
@@ -26,9 +26,15 @@
<arg type="s" name="module" direction="in" />
<arg type="as" name="files" direction="in" />
</method>
- <method name="SetPaused">
+ <method name="Pause">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ </method>
+ <method name="PauseForDuration">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="u" name="seconds" direction="in" />
+ </method>
+ <method name="Continue">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg type="b" name="paused" direction="in" />
</method>
<!-- Signals -->
Modified: branches/indexer-split/src/libtracker-common/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-dbus.c (original)
+++ branches/indexer-split/src/libtracker-common/tracker-dbus.c Wed Jul 23 14:15:37 2008
@@ -23,6 +23,46 @@
#include <gio/gio.h>
+struct TrackerDBusRequestHandler {
+ TrackerDBusRequestFunc new;
+ TrackerDBusRequestFunc done;
+ gpointer user_data;
+};
+
+static GSList *hooks;
+
+static void
+request_handler_call_for_new (guint request_id)
+{
+ GSList *l;
+
+ for (l = hooks; l; l = l->next) {
+ TrackerDBusRequestHandler *handler;
+
+ handler = l->data;
+
+ if (handler->new) {
+ (handler->new)(request_id, handler->user_data);
+ }
+ }
+}
+
+static void
+request_handler_call_for_done (guint request_id)
+{
+ GSList *l;
+
+ for (l = hooks; l; l = l->next) {
+ TrackerDBusRequestHandler *handler;
+
+ handler = l->data;
+
+ if (handler->done) {
+ (handler->done)(request_id, handler->user_data);
+ }
+ }
+}
+
GValue *
tracker_dbus_gvalue_slice_new (GType type)
{
@@ -179,7 +219,6 @@
*ptr_array = NULL;
}
-
guint
tracker_dbus_get_next_request_id (void)
{
@@ -188,6 +227,32 @@
return request_id++;
}
+TrackerDBusRequestHandler *
+tracker_dbus_request_add_hook (TrackerDBusRequestFunc new,
+ TrackerDBusRequestFunc done,
+ gpointer user_data)
+{
+ TrackerDBusRequestHandler *handler;
+
+ handler = g_slice_new0 (TrackerDBusRequestHandler);
+ handler->new = new;
+ handler->done = done;
+ handler->user_data = user_data;
+
+ hooks = g_slist_append (hooks, handler);
+
+ return handler;
+}
+
+void
+tracker_dbus_request_remove_hook (TrackerDBusRequestHandler *handler)
+{
+ g_return_if_fail (handler != NULL);
+
+ hooks = g_slist_remove (hooks, handler);
+ g_slice_free (TrackerDBusRequestHandler, handler);
+}
+
void
tracker_dbus_request_new (gint request_id,
const gchar *format,
@@ -205,11 +270,15 @@
str);
g_free (str);
+
+ request_handler_call_for_new (request_id);
}
void
tracker_dbus_request_success (gint request_id)
{
+ request_handler_call_for_done (request_id);
+
g_message ("---> [%d] Success, no error given",
request_id);
}
@@ -223,6 +292,8 @@
gchar *str;
va_list args;
+ request_handler_call_for_done (request_id);
+
va_start (args, format);
str = g_strdup_vprintf (format, args);
va_end (args);
Modified: branches/indexer-split/src/libtracker-common/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-dbus.h (original)
+++ branches/indexer-split/src/libtracker-common/tracker-dbus.h Wed Jul 23 14:15:37 2008
@@ -68,6 +68,11 @@
}; \
} G_STMT_END
+typedef struct TrackerDBusRequestHandler TrackerDBusRequestHandler;
+
+typedef void (*TrackerDBusRequestFunc) (guint request_id,
+ gpointer user_data);
+
typedef struct {
guint id;
gpointer data1;
@@ -75,33 +80,38 @@
} TrackerDBusData;
GQuark tracker_dbus_error_quark (void);
-TrackerDBusData *tracker_dbus_data_new (const gpointer arg1,
- const gpointer arg2);
-
+TrackerDBusData *tracker_dbus_data_new (const gpointer arg1,
+ const gpointer arg2);
/* Utils */
-GValue * tracker_dbus_gvalue_slice_new (GType type);
-void tracker_dbus_gvalue_slice_free (GValue *value);
-gchar ** tracker_dbus_slist_to_strv (GSList *list);
-gchar ** tracker_dbus_queue_str_to_strv (GQueue *queue,
- gint max);
-gchar ** tracker_dbus_queue_gfile_to_strv (GQueue *queue,
- gint max);
-void tracker_dbus_results_ptr_array_free (GPtrArray **ptr_array);
-
+GValue * tracker_dbus_gvalue_slice_new (GType type);
+void tracker_dbus_gvalue_slice_free (GValue *value);
+gchar ** tracker_dbus_slist_to_strv (GSList *list);
+gchar ** tracker_dbus_queue_str_to_strv (GQueue *queue,
+ gint max);
+gchar ** tracker_dbus_queue_gfile_to_strv (GQueue *queue,
+ gint max);
+void tracker_dbus_results_ptr_array_free (GPtrArray **ptr_array);
/* Requests */
guint tracker_dbus_get_next_request_id (void);
-void tracker_dbus_request_new (gint request_id,
- const gchar *format,
+
+TrackerDBusRequestHandler *
+ tracker_dbus_request_add_hook (TrackerDBusRequestFunc new,
+ TrackerDBusRequestFunc done,
+ gpointer user_data);
+void tracker_dbus_request_remove_hook (TrackerDBusRequestHandler *handler);
+
+void tracker_dbus_request_new (gint request_id,
+ const gchar *format,
...);
-void tracker_dbus_request_success (gint request_id);
-void tracker_dbus_request_failed (gint request_id,
- GError **error,
- const gchar *format,
+void tracker_dbus_request_success (gint request_id);
+void tracker_dbus_request_failed (gint request_id,
+ GError **error,
+ const gchar *format,
...);
-void tracker_dbus_request_comment (gint request_id,
- const gchar *format,
+void tracker_dbus_request_comment (gint request_id,
+ const gchar *format,
...);
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 Wed Jul 23 14:15:37 2008
@@ -115,6 +115,7 @@
GTimer *timer;
guint idle_id;
+ guint pause_for_duration_id;
guint flush_id;
guint items_processed;
@@ -357,6 +358,10 @@
schedule_flush (TRACKER_INDEXER (object), TRUE);
}
+ if (priv->pause_for_duration_id) {
+ g_source_remove (priv->pause_for_duration_id);
+ }
+
if (priv->idle_id) {
g_source_remove (priv->idle_id);
}
@@ -968,17 +973,10 @@
return indexer->private->idle_id != 0;
}
-/**
- * This one is not being used yet, but might be used in near future. Therefore
- * it would be useful if Garnacho could review this for consistency and
- * correctness. Ps. it got written by that pvanhoof dude, just ping him if you
- * have questions.
- **/
void
-tracker_indexer_set_paused (TrackerIndexer *indexer,
- gboolean paused,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_indexer_pause (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error)
{
guint request_id;
@@ -986,37 +984,117 @@
tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
- tracker_dbus_request_new (request_id,
- "DBus request to %s the indexer",
- paused ? "pause" : "resume");
+ tracker_dbus_request_new (request_id,
+ "DBus request to pause the indexer");
if (tracker_indexer_get_is_running (indexer)) {
- if (paused) {
- if (indexer->private->in_transaction) {
- tracker_dbus_request_comment (request_id,
- "Committing transactions");
- stop_transaction (indexer);
- }
-
+ if (indexer->private->in_transaction) {
tracker_dbus_request_comment (request_id,
- "Pausing indexing");
-
- g_source_remove (indexer->private->idle_id);
- indexer->private->idle_id = 0;
- indexer->private->is_paused = TRUE;
-
- g_signal_emit (indexer, signals[PAUSED], 0);
+ "Committing transactions");
+ stop_transaction (indexer);
}
- } else {
- if (!paused) {
- tracker_dbus_request_comment (request_id,
- "Resuming indexing");
+
+ tracker_dbus_request_comment (request_id,
+ "Pausing indexing");
+
+ g_source_remove (indexer->private->idle_id);
+ indexer->private->idle_id = 0;
+ indexer->private->is_paused = TRUE;
+
+ g_signal_emit (indexer, signals[PAUSED], 0);
+ }
+
+ dbus_g_method_return (context);
+
+ tracker_dbus_request_success (request_id);
+}
+
+static gboolean
+pause_for_duration_cb (gpointer user_data)
+{
+ TrackerIndexer *indexer;
+
+ indexer = TRACKER_INDEXER (user_data);
+
+ if (tracker_indexer_get_is_running (indexer) == FALSE) {
+ g_message ("Continuing indexing");
- indexer->private->is_paused = FALSE;
- indexer->private->idle_id = g_idle_add (process_func, indexer);
+ indexer->private->is_paused = FALSE;
+ indexer->private->idle_id = g_idle_add (process_func, indexer);
+
+ g_signal_emit (indexer, signals[CONTINUED], 0);
+ }
+
+ indexer->private->pause_for_duration_id = 0;
+
+ return FALSE;
+}
- g_signal_emit (indexer, signals[CONTINUED], 0);
+void
+tracker_indexer_pause_for_duration (TrackerIndexer *indexer,
+ guint seconds,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ guint request_id;
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to pause the indexer for %d seconds",
+ seconds);
+
+ if (tracker_indexer_get_is_running (indexer)) {
+ if (indexer->private->in_transaction) {
+ tracker_dbus_request_comment (request_id,
+ "Committing transactions");
+ stop_transaction (indexer);
}
+
+ tracker_dbus_request_comment (request_id,
+ "Pausing indexing");
+
+ g_source_remove (indexer->private->idle_id);
+ indexer->private->idle_id = 0;
+ indexer->private->is_paused = TRUE;
+
+ indexer->private->pause_for_duration_id =
+ g_timeout_add_seconds (seconds,
+ pause_for_duration_cb,
+ indexer);
+
+ g_signal_emit (indexer, signals[PAUSED], 0);
+ }
+
+ dbus_g_method_return (context);
+
+ tracker_dbus_request_success (request_id);
+}
+
+void
+tracker_indexer_continue (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ guint request_id;
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to continue the indexer");
+
+ if (tracker_indexer_get_is_running (indexer) == FALSE) {
+ tracker_dbus_request_comment (request_id,
+ "Continuing indexing");
+
+ indexer->private->is_paused = FALSE;
+ indexer->private->idle_id = g_idle_add (process_func, indexer);
+
+ g_signal_emit (indexer, signals[CONTINUED], 0);
}
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 Wed Jul 23 14:15:37 2008
@@ -69,32 +69,36 @@
const gchar *module_name);
};
-GType tracker_indexer_get_type (void) G_GNUC_CONST;
+GType tracker_indexer_get_type (void) G_GNUC_CONST;
-TrackerIndexer *tracker_indexer_new (void);
-
-gboolean tracker_indexer_get_is_running (TrackerIndexer *indexer);
-void tracker_indexer_set_paused (TrackerIndexer *indexer,
- gboolean paused,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_process_all (TrackerIndexer *indexer);
-
-void tracker_indexer_files_check (TrackerIndexer *indexer,
- const gchar *module,
- GStrv files,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_files_update (TrackerIndexer *indexer,
- const gchar *module,
- GStrv files,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_files_delete (TrackerIndexer *indexer,
- const gchar *module,
- GStrv files,
- DBusGMethodInvocation *context,
- GError **error);
+TrackerIndexer *tracker_indexer_new (void);
+gboolean tracker_indexer_get_is_running (TrackerIndexer *indexer);
+void tracker_indexer_pause (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_pause_for_duration (TrackerIndexer *indexer,
+ guint seconds,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_continue (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_process_all (TrackerIndexer *indexer);
+void tracker_indexer_files_check (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_files_update (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_files_delete (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ DBusGMethodInvocation *context,
+ GError **error);
G_END_DECLS
Modified: branches/indexer-split/src/trackerd/tracker-daemon.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-daemon.c (original)
+++ branches/indexer-split/src/trackerd/tracker-daemon.c Wed Jul 23 14:15:37 2008
@@ -57,7 +57,10 @@
};
static void daemon_finalize (GObject *object);
-static void indexer_set_paused_cb (DBusGProxy *proxy,
+static void indexer_pause_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
+static void indexer_continue_cb (DBusGProxy *proxy,
GError *error,
gpointer user_data);
static void indexer_paused_cb (DBusGProxy *proxy,
@@ -186,12 +189,23 @@
}
static void
-indexer_set_paused_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
+indexer_pause_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
{
if (error) {
- g_message ("Could not pause/resume the indexer, %s",
+ g_message ("Could not pause the indexer, %s",
+ error->message);
+ }
+}
+
+static void
+indexer_continue_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
+{
+ if (error) {
+ g_message ("Could not continue the indexer, %s",
error->message);
}
}
@@ -296,8 +310,6 @@
/* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_exec_proc (iface, "GetServices", 0);
@@ -311,7 +323,6 @@
g_hash_table_destroy (values);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -338,8 +349,6 @@
/* iface = tracker_db_manager_get_db_interfaceX (TRACKER_DB_COMMON); */
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_exec_proc (iface, "GetStats", 0);
@@ -354,7 +363,6 @@
g_ptr_array_foreach (values, (GFunc) g_strfreev, NULL);
g_ptr_array_free (values, TRUE);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -387,10 +395,15 @@
value ? "true" : "false");
if (strcasecmp (option, "Pause") == 0) {
- org_freedesktop_Tracker_Indexer_set_paused_async (priv->indexer_proxy,
- value,
- indexer_set_paused_cb,
- NULL);
+ if (value) {
+ org_freedesktop_Tracker_Indexer_pause_async (priv->indexer_proxy,
+ indexer_pause_cb,
+ NULL);
+ } else {
+ org_freedesktop_Tracker_Indexer_continue_async (priv->indexer_proxy,
+ indexer_continue_cb,
+ NULL);
+ }
} else if (strcasecmp (option, "FastMerges") == 0) {
tracker_config_set_fast_merges (priv->config, value);
g_message ("Fast merges set to %d", value);
Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c Wed Jul 23 14:15:37 2008
@@ -19,8 +19,9 @@
* Boston, MA 02110-1301, USA.
*/
-#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-config.h>
+#include <libtracker-common/tracker-dbus.h>
+#include <libtracker-common/tracker-log.h>
#include <libtracker-common/tracker-utils.h>
#include <libtracker-db/tracker-db-manager.h>
@@ -43,12 +44,15 @@
#include "tracker-utils.h"
#include "tracker-marshal.h"
#include "tracker-status.h"
+#include "tracker-main.h"
+
+#define INDEXER_PAUSE_TIME_FOR_REQUESTS 10 /* seconds */
static DBusGConnection *connection;
static DBusGProxy *proxy;
static DBusGProxy *proxy_for_indexer;
static GSList *objects;
-static guint pause_timeout = 0;
+static guint indexer_resume_timeout_id;
static gboolean
dbus_register_service (DBusGProxy *proxy,
@@ -152,6 +156,91 @@
return TRUE;
}
+static gboolean
+indexer_resume_cb (gpointer user_data)
+{
+ DBusGProxy *proxy;
+ GError *error = NULL;
+
+ proxy = user_data;
+
+ org_freedesktop_Tracker_Indexer_continue (proxy, &error);
+
+ if (error) {
+ g_message ("Couldn't resume the indexer, eeek");
+ g_error_free (error);
+ }
+
+ return FALSE;
+}
+
+static void
+indexer_resume_destroy_notify_cb (gpointer user_data)
+{
+ g_object_unref (user_data);
+ indexer_resume_timeout_id = 0;
+}
+
+static void
+dbus_request_new_cb (guint request_id,
+ gpointer user_data)
+{
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ gboolean set_paused = TRUE;
+
+ g_message ("New DBus request, checking indexer is paused...");
+
+ /* First remove the timeout */
+ if (indexer_resume_timeout_id != 0) {
+ set_paused = FALSE;
+
+ g_source_remove (indexer_resume_timeout_id);
+ indexer_resume_timeout_id = 0;
+ }
+
+ /* Second reset it so we have another 10 seconds before
+ * continuing.
+ */
+ proxy = tracker_dbus_indexer_get_proxy ();
+ indexer_resume_timeout_id =
+ g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+ INDEXER_PAUSE_TIME_FOR_REQUESTS,
+ indexer_resume_cb,
+ g_object_ref (proxy),
+ indexer_resume_destroy_notify_cb);
+
+ /* Third check if we are already paused, if we are there is
+ * no need to tell the indexer.
+ */
+ if (tracker_get_is_paused_manually ()) {
+ g_message ("Tracker is already manually paused, doing nothing");
+ return;
+ }
+
+ /* We really only do this because of the chance that we tell
+ * the indexer to pause but don't get notified until the next
+ * request. When we are notified of being paused,
+ * tracker_get_is_paused_manually() returns TRUE.
+ */
+ if (!set_paused) {
+ return;
+ }
+
+ /* We use the blocking call here because this function
+ * proceeds a call which needs the database to be available.
+ * Therefore the indexer must reply to tell us it has paused
+ * so we can actually use the database.
+ */
+ org_freedesktop_Tracker_Indexer_pause (proxy, &error);
+
+ if (error) {
+ g_message ("Couldn't pause the indexer, "
+ "we may have to wait for it to finish");
+ g_error_free (error);
+ }
+}
+
gboolean
tracker_dbus_init (TrackerConfig *config)
{
@@ -167,6 +256,11 @@
return FALSE;
}
+ /* Register request handler so we can pause the indexer */
+ tracker_dbus_request_add_hook (dbus_request_new_cb,
+ NULL,
+ NULL);
+
return TRUE;
}
@@ -394,70 +488,3 @@
return proxy_for_indexer;
}
-
-
-static void
-set_paused_reply (DBusGProxy *proxy, GError *error, gpointer userdata)
-{
- return;
-}
-
-static gboolean
-tracker_indexer_paused (gpointer user_data)
-{
- DBusGProxy *proxy = user_data;
-
- /* Here it doesn't matter, so we don't block like below */
- org_freedesktop_Tracker_Indexer_set_paused_async (proxy, FALSE,
- set_paused_reply,
- NULL);
-
- return FALSE;
-}
-
-static void
-tracker_indexer_pause_finished (gpointer user_data)
-{
- DBusGProxy *proxy = user_data;
- pause_timeout = 0;
- g_object_unref (proxy);
-}
-
-void
-tracker_indexer_pause (void)
-{
- /* If we are not indexing, there's no indexer to pauze ...
- * Q: what if during this pause an indexer gets started? */
-
- if (tracker_status_get () != TRACKER_STATUS_INDEXING)
- return;
-
- /* If another pause is already active */
- if (pause_timeout == 0) {
- DBusGProxy *proxy;
- GError *error = NULL;
-
- proxy = tracker_dbus_indexer_get_proxy ();
-
- /* We want to block until we are sure that we are pauzed */
- org_freedesktop_Tracker_Indexer_set_paused (proxy, TRUE, &error);
-
- if (!error) {
- /* Activate a pause */
- pause_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT,
- 10 * 1000 /* 10 seconds */,
- tracker_indexer_paused,
- g_object_ref (proxy),
- tracker_indexer_pause_finished);
- } else {
- /* Should we do something useful with error here? */
- g_error_free (error);
- }
- }
-}
-
-void
-tracker_indexer_continue (void)
-{
- return;
-}
Modified: branches/indexer-split/src/trackerd/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.h (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.h Wed Jul 23 14:15:37 2008
@@ -44,9 +44,6 @@
GObject *tracker_dbus_get_object (GType type);
DBusGProxy *tracker_dbus_indexer_get_proxy (void);
-void tracker_indexer_pause (void);
-void tracker_indexer_continue (void);
-
G_END_DECLS
#endif /* __TRACKERD_DBUS_H__ */
Modified: branches/indexer-split/src/trackerd/tracker-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-files.c Wed Jul 23 14:15:37 2008
@@ -149,8 +149,6 @@
size,
mtime);
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
/* Create structure */
@@ -235,8 +233,6 @@
dbus_g_method_return (context);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -270,15 +266,11 @@
"uri:'%s'",
uri);
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
file_id = tracker_db_file_get_id (iface, uri);
if (file_id == 0) {
- tracker_indexer_continue ();
-
tracker_dbus_request_comment (request_id,
"File or directory was not in database to delete, uri:'%s'",
uri);
@@ -288,8 +280,6 @@
return;
}
- tracker_indexer_continue ();
-
if (uri[0] == G_DIR_SEPARATOR) {
name = g_path_get_basename (uri);
path = g_path_get_dirname (uri);
@@ -319,8 +309,6 @@
dbus_g_method_return (context);
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -347,8 +335,6 @@
"uri:'%s'",
uri);
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
/* FIXME why dont obtain the service type directly from the DB??? */
@@ -356,8 +342,6 @@
file_id = tracker_db_file_get_id (iface, uri);
if (file_id < 1) {
- tracker_indexer_continue ();
-
tracker_dbus_request_failed (request_id,
&actual_error,
"File '%s' was not found in the database",
@@ -380,8 +364,6 @@
g_object_unref (result_set);
}
- tracker_indexer_continue ();
-
g_free (file_id_str);
if (!mime) {
@@ -453,11 +435,8 @@
offset,
max_length);
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
-
/* FIXME iface is already for "Files". Makes no sense to try Files and Emails */
service_id = tracker_db_file_get_id_as_string (iface, "Files", uri);
if (!service_id) {
@@ -465,7 +444,6 @@
service_id = tracker_db_file_get_id_as_string (iface, "Emails", uri);
if (!service_id) {
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Unable to retrieve service ID for uri '%s'",
@@ -476,8 +454,6 @@
}
}
- tracker_indexer_continue ();
-
offset_str = tracker_int_to_string (offset);
max_length_str = tracker_int_to_string (max_length);
@@ -546,8 +522,6 @@
text,
max_length);
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
if (uri[0] == G_DIR_SEPARATOR) {
@@ -589,7 +563,6 @@
__PRETTY_FUNCTION__);
dbus_g_method_return_error (context, actual_error);
g_error_free (actual_error);
- tracker_indexer_continue ();
}
void
@@ -631,7 +604,6 @@
return;
}
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_files_get_by_service (iface,
@@ -639,8 +611,6 @@
offset,
max_hits);
- tracker_indexer_continue ();
-
values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
if (result_set) {
@@ -684,7 +654,6 @@
offset,
max_hits);
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_files_get_by_mime (iface,
@@ -694,8 +663,6 @@
max_hits,
FALSE);
- tracker_indexer_continue ();
-
values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
if (result_set) {
@@ -739,7 +706,6 @@
offset,
max_hits);
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
/* NOTE: The only difference between this function and the
@@ -752,8 +718,6 @@
max_hits,
TRUE);
- tracker_indexer_continue ();
-
values = tracker_dbus_query_result_to_strv (result_set, 0, NULL);
if (result_set) {
@@ -791,7 +755,6 @@
"uri:'%s'",
uri);
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
if (uri[0] == G_DIR_SEPARATOR) {
@@ -807,8 +770,6 @@
path,
name,
NULL);
- tracker_indexer_continue ();
-
g_free (path);
g_free (name);
@@ -888,13 +849,11 @@
uri_filtered = g_strdup (uri);
}
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
/* Get file ID in database */
file_id = tracker_db_file_get_id (iface, uri_filtered);
if (file_id == 0) {
- tracker_indexer_continue ();
g_free (uri_filtered);
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -964,8 +923,6 @@
result_set = tracker_db_interface_execute_query (iface, NULL, query);
values = tracker_dbus_query_result_to_ptr_array (result_set);
- tracker_indexer_continue ();
-
if (result_set) {
g_object_unref (result_set);
}
@@ -1003,13 +960,10 @@
text,
g_strv_length (mime_types));
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_search_text_and_mime (iface, text, mime_types);
- tracker_indexer_continue ();
-
if (result_set) {
gboolean valid = TRUE;
gchar *prefix, *name;
@@ -1068,13 +1022,10 @@
text,
uri);
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_search_text_and_location (iface, text, uri);
- tracker_indexer_continue ();
-
if (result_set) {
gboolean valid = TRUE;
gchar *prefix, *name;
@@ -1137,13 +1088,10 @@
g_strv_length (mime_types),
uri);
- tracker_indexer_pause ();
iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
result_set = tracker_db_search_text_and_mime_and_location (iface, text, mime_types, uri);
- tracker_indexer_continue ();
-
if (result_set) {
gboolean valid = TRUE;
gchar *prefix, *name;
Modified: branches/indexer-split/src/trackerd/tracker-keywords.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-keywords.c (original)
+++ branches/indexer-split/src/trackerd/tracker-keywords.c Wed Jul 23 14:15:37 2008
@@ -142,8 +142,6 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
result_set = tracker_db_keywords_get_list (iface, service_type);
values = tracker_dbus_query_result_to_ptr_array (result_set);
@@ -155,7 +153,6 @@
dbus_g_method_return (context, values);
tracker_dbus_results_ptr_array_free (&values);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -203,12 +200,9 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!id) {
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Entity '%s' was not found",
@@ -235,7 +229,6 @@
g_strfreev (values);
}
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -284,12 +277,9 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!id) {
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Entity '%s' was not found",
@@ -314,7 +304,6 @@
dbus_g_method_return (context);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -363,12 +352,9 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!id) {
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Entity '%s' was not found",
@@ -389,7 +375,6 @@
dbus_g_method_return (context);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -435,12 +420,9 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!id) {
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Entity '%s' was not found",
@@ -459,7 +441,6 @@
dbus_g_method_return (context);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -510,8 +491,6 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
/* Sanity check values */
@@ -581,6 +560,5 @@
g_strfreev (values);
}
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
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 Wed Jul 23 14:15:37 2008
@@ -766,6 +766,13 @@
g_main_loop_run (main_loop);
}
+ /* We can block on this since we are likely to block on
+ * shutting down otherwise anyway.
+ */
+ org_freedesktop_Tracker_Indexer_pause_for_duration (tracker_dbus_indexer_get_proxy (),
+ 2,
+ NULL);
+
g_message ("Shutting down...\n");
/*
Modified: branches/indexer-split/src/trackerd/tracker-metadata.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-metadata.c (original)
+++ branches/indexer-split/src/trackerd/tracker-metadata.c Wed Jul 23 14:15:37 2008
@@ -101,13 +101,10 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
service_id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!service_id) {
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Service URI '%s' not found",
@@ -122,7 +119,6 @@
*/
service_result = tracker_db_service_get_by_entity (iface, service_id);
if (!service_result) {
- tracker_indexer_continue ();
g_free (service_id);
tracker_dbus_request_failed (request_id,
&actual_error,
@@ -214,7 +210,6 @@
dbus_g_method_return (context, values);
g_strfreev (values);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
}
@@ -257,13 +252,10 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service_type);
service_id = tracker_db_file_get_id_as_string (iface, service_type, uri);
if (!service_id) {
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Service URI '%s' not found",
@@ -282,7 +274,6 @@
if (!key || strlen (key) < 3 || strchr (key, ':') == NULL) {
g_free (service_id);
- tracker_indexer_continue ();
tracker_dbus_request_failed (request_id,
&actual_error,
"Metadata type name '%s' is invalid, all names must be registered",
@@ -306,12 +297,9 @@
dbus_g_method_return (context);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
-
}
-
void
tracker_metadata_get_type_details (TrackerMetadata *object,
const gchar *metadata,
Modified: branches/indexer-split/src/trackerd/tracker-search.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-search.c (original)
+++ branches/indexer-split/src/trackerd/tracker-search.c Wed Jul 23 14:15:37 2008
@@ -516,8 +516,6 @@
g_array_free (array, TRUE);
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -607,8 +605,6 @@
g_object_unref (tree);
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -663,8 +659,6 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_search_text (iface,
@@ -714,10 +708,7 @@
g_strfreev (strv);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -772,8 +763,6 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service);
result_set = tracker_db_search_text (iface,
@@ -794,10 +783,7 @@
g_object_unref (result_set);
}
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -849,13 +835,10 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service);
service_id = tracker_db_file_get_id_as_string (iface, service, id);
if (!service_id) {
- tracker_indexer_continue ();
g_set_error (&actual_error,
TRACKER_DBUS_ERROR,
0,
@@ -903,10 +886,7 @@
g_free (snippet);
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -963,8 +943,6 @@
}
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -1012,8 +990,6 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service);
/* FIXME: This function no longer exists, it was returning
@@ -1039,10 +1015,7 @@
g_object_unref (result_set);
}
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -1093,8 +1066,6 @@
return;
}
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service);
/* FIXME: This function no longer exists, it was returning
@@ -1118,10 +1089,7 @@
g_object_unref (result_set);
}
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -1179,8 +1147,6 @@
result_set = NULL;
- tracker_indexer_pause ();
-
iface = tracker_db_manager_get_db_interface_by_service (service);
if (query_condition) {
@@ -1207,7 +1173,6 @@
query_error);
if (query_error) {
- tracker_indexer_continue ();
g_set_error (&actual_error,
TRACKER_DBUS_ERROR,
0,
@@ -1217,7 +1182,6 @@
g_error_free (query_error);
return;
} else if (!query_translated) {
- tracker_indexer_continue ();
g_set_error (&actual_error,
TRACKER_DBUS_ERROR,
0,
@@ -1257,10 +1221,7 @@
g_object_unref (result_set);
}
- tracker_indexer_continue ();
tracker_dbus_request_success (request_id);
-
- return;
}
void
@@ -1307,6 +1268,4 @@
}
tracker_dbus_request_success (request_id);
-
- return;
}
Modified: branches/indexer-split/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.c Wed Jul 23 14:15:37 2008
@@ -203,8 +203,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
key = dbus_g_method_get_sender (context);
if (!sessions)
@@ -244,8 +242,6 @@
g_free (session_id);
g_free (key);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -400,8 +396,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
session = tracker_xesam_manager_get_session (session_id, &error);
if (session) {
@@ -437,8 +431,6 @@
if (session)
g_object_unref (session);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -453,8 +445,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
search = tracker_xesam_manager_get_live_search (search_id, &error);
if (search) {
@@ -476,8 +466,6 @@
if (search)
g_object_unref (search);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -492,8 +480,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
search = tracker_xesam_manager_get_live_search (search_id, &error);
if (search) {
@@ -517,8 +503,6 @@
if (search)
g_object_unref (search);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -555,8 +539,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
search = tracker_xesam_manager_get_live_search (search_id, &error);
if (search) {
@@ -586,8 +568,6 @@
if (search)
g_object_unref (search);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -604,8 +584,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
search = tracker_xesam_manager_get_live_search (search_id, &error);
if (search) {
@@ -636,8 +614,6 @@
if (search)
g_object_unref (search);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -655,8 +631,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
search = tracker_xesam_manager_get_live_search (search_id, &error);
if (search) {
@@ -687,8 +661,6 @@
if (search)
g_object_unref (search);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -706,8 +678,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
search = tracker_xesam_manager_get_live_search (search_id, &error);
if (search) {
@@ -739,8 +709,6 @@
if (search)
g_object_unref (search);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
@@ -755,8 +723,6 @@
request_id = tracker_dbus_get_next_request_id ();
- tracker_indexer_pause ();
-
search = tracker_xesam_manager_get_live_search (search_id, &error);
if (search) {
@@ -778,8 +744,6 @@
if (search)
g_object_unref (search);
- tracker_indexer_continue ();
-
tracker_dbus_request_success (request_id);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]