[tracker/busy-handling: 1/2] tracker-store, libtracker-data: Queue queries while busy
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/busy-handling: 1/2] tracker-store, libtracker-data: Queue queries while busy
- Date: Tue, 27 Jul 2010 11:01:38 +0000 (UTC)
commit 10299acca2363f945eba0917646668792c13c42d
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Jul 27 10:43:55 2010 +0200
tracker-store, libtracker-data: Queue queries while busy
src/libtracker-data/tracker-db-journal.c | 17 ++++++++++
src/tracker-store/tracker-backup.c | 4 +-
src/tracker-store/tracker-dbus.c | 52 +++++++++++++++---------------
src/tracker-store/tracker-dbus.h | 1 -
src/tracker-store/tracker-main.c | 18 ++++++----
src/tracker-store/tracker-store.c | 20 ++++++++++--
src/tracker-store/tracker-store.h | 2 +
7 files changed, 75 insertions(+), 39 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-journal.c b/src/libtracker-data/tracker-db-journal.c
index 0200dfa..0e84099 100644
--- a/src/libtracker-data/tracker-db-journal.c
+++ b/src/libtracker-data/tracker-db-journal.c
@@ -1233,6 +1233,8 @@ static gboolean
db_journal_reader_next (JournalReader *jreader, gboolean global_reader, GError **error)
{
GError *inner_error = NULL;
+ static gboolean debug_unchecked = TRUE;
+ static gboolean slow_down = FALSE;
g_return_val_if_fail (jreader->file != NULL || jreader->stream != NULL, FALSE);
@@ -1281,6 +1283,21 @@ db_journal_reader_next (JournalReader *jreader, gboolean global_reader, GError *
guint32 crc_check;
TransactionFormat t_kind;
+
+ if (G_UNLIKELY (debug_unchecked)) {
+ const gchar *test;
+
+ test = g_getenv ("TRACKER_DEBUG_MAKE_JOURNAL_READER_GO_VERY_SLOW");
+ if (g_strcmp0 (test, "yes") == 0) {
+ slow_down = TRUE;
+ }
+ debug_unchecked = FALSE;
+ }
+
+ if (G_UNLIKELY (slow_down)) {
+ sleep (1);
+ }
+
/* Check the end is not where we currently are */
if (journal_eof (jreader)) {
/* Return FALSE as there is no further entry but
diff --git a/src/tracker-store/tracker-backup.c b/src/tracker-store/tracker-backup.c
index 106caa4..d030433 100644
--- a/src/tracker-store/tracker-backup.c
+++ b/src/tracker-store/tracker-backup.c
@@ -118,7 +118,7 @@ backup_idle (gpointer user_data)
journal = g_file_new_for_uri (info->journal_uri);
- tracker_dbus_set_available (FALSE);
+ tracker_store_set_active (FALSE);
notifier = TRACKER_STATUS (tracker_dbus_get_object (TRACKER_TYPE_STATUS));
@@ -135,7 +135,7 @@ backup_idle (gpointer user_data)
busy_callback,
busy_user_data);
- tracker_dbus_set_available (TRUE);
+ tracker_store_set_active (TRUE);
g_object_unref (journal);
diff --git a/src/tracker-store/tracker-dbus.c b/src/tracker-store/tracker-dbus.c
index 3d42d4c..59377a7 100644
--- a/src/tracker-store/tracker-dbus.c
+++ b/src/tracker-store/tracker-dbus.c
@@ -162,27 +162,6 @@ tracker_dbus_init (void)
return TRUE;
}
-void
-tracker_dbus_shutdown (void)
-{
- tracker_dbus_set_available (FALSE);
-
- if (backup) {
- g_object_unref (backup);
- }
-
- if (notifier) {
- g_object_unref (notifier);
- }
-
- if (gproxy) {
- g_object_unref (gproxy);
- gproxy = NULL;
- }
-
- connection = NULL;
-}
-
static void
name_owner_changed_cb (DBusGProxy *proxy,
gchar *name,
@@ -196,8 +175,14 @@ name_owner_changed_cb (DBusGProxy *proxy,
}
}
-void
-tracker_dbus_set_available (gboolean available)
+static void
+name_owner_changed_closure (gpointer data,
+ GClosure *closure)
+{
+}
+
+static void
+dbus_set_available (gboolean available)
{
if (available) {
if (!objects) {
@@ -223,10 +208,25 @@ tracker_dbus_set_available (gboolean available)
}
}
-static void
-name_owner_changed_closure (gpointer data,
- GClosure *closure)
+void
+tracker_dbus_shutdown (void)
{
+ dbus_set_available (FALSE);
+
+ if (backup) {
+ g_object_unref (backup);
+ }
+
+ if (notifier) {
+ g_object_unref (notifier);
+ }
+
+ if (gproxy) {
+ g_object_unref (gproxy);
+ gproxy = NULL;
+ }
+
+ connection = NULL;
}
TrackerStatus*
diff --git a/src/tracker-store/tracker-dbus.h b/src/tracker-store/tracker-dbus.h
index 111ee86..15ba374 100644
--- a/src/tracker-store/tracker-dbus.h
+++ b/src/tracker-store/tracker-dbus.h
@@ -34,7 +34,6 @@ void tracker_dbus_shutdown (void);
gboolean tracker_dbus_register_objects (void);
GObject *tracker_dbus_get_object (GType type);
TrackerStatus *tracker_dbus_register_notifier (void);
-void tracker_dbus_set_available (gboolean available);
G_END_DECLS
diff --git a/src/tracker-store/tracker-main.c b/src/tracker-store/tracker-main.c
index 177b38c..68b992b 100644
--- a/src/tracker-store/tracker-main.c
+++ b/src/tracker-store/tracker-main.c
@@ -445,6 +445,15 @@ main (gint argc, gchar *argv[])
busy_callback = tracker_status_get_callback (notifier,
&busy_user_data);
+ tracker_store_init ();
+
+ tracker_store_set_active (FALSE);
+
+ /* Make Tracker available for introspection */
+ if (!tracker_dbus_register_objects ()) {
+ return EXIT_FAILURE;
+ }
+
chunk_size_mb = tracker_db_config_get_journal_chunk_size (db_config);
chunk_size = (gsize) ((gsize) chunk_size_mb * (gsize) 1024 * (gsize) 1024);
rotate_to = tracker_db_config_get_journal_rotate_destination (db_config);
@@ -479,22 +488,17 @@ main (gint argc, gchar *argv[])
g_object_unref (db_config);
g_object_unref (notifier);
- tracker_store_init ();
-
if (private->shutdown) {
goto shutdown;
}
- /* Make Tracker available for introspection */
- if (!tracker_dbus_register_objects ()) {
- return EXIT_FAILURE;
- }
-
tracker_events_init (get_notifiable_classes);
tracker_writeback_init (get_writeback_predicates);
tracker_push_init ();
+ tracker_store_set_active (TRUE);
+
g_message ("Waiting for D-Bus requests...");
/* Set our status as running, if this is FALSE, threads stop
diff --git a/src/tracker-store/tracker-store.c b/src/tracker-store/tracker-store.c
index 44ae231..889af32 100644
--- a/src/tracker-store/tracker-store.c
+++ b/src/tracker-store/tracker-store.c
@@ -57,9 +57,10 @@ typedef struct {
gboolean update_running;
GThreadPool *main_pool;
GThreadPool *global_pool;
- GSList *running_tasks;
- guint watchdog_id;
+ GSList *running_tasks;
+ guint watchdog_id;
guint max_task_time;
+ gboolean active;
} TrackerStorePrivate;
typedef enum {
@@ -283,7 +284,7 @@ task_ready (TrackerStorePrivate *private)
static void
check_handler (TrackerStorePrivate *private)
{
- if (task_ready (private)) {
+ if (private->active && task_ready (private)) {
/* handler should be running */
if (!private->have_handler) {
start_handler (private);
@@ -292,6 +293,7 @@ check_handler (TrackerStorePrivate *private)
/* handler should not be running */
if (private->have_handler) {
g_source_remove (private->handler);
+ private->have_handler = FALSE;
}
}
}
@@ -936,3 +938,15 @@ tracker_store_unreg_batches (const gchar *client_id)
check_handler (private);
}
+
+void
+tracker_store_set_active (gboolean active)
+{
+ TrackerStorePrivate *private;
+ TrackerStoreTask *task;
+
+ private = g_static_private_get (&private_key);
+ private->active = active;
+
+ check_handler (private);
+}
diff --git a/src/tracker-store/tracker-store.h b/src/tracker-store/tracker-store.h
index 7b1b5a9..6df432b 100644
--- a/src/tracker-store/tracker-store.h
+++ b/src/tracker-store/tracker-store.h
@@ -88,6 +88,8 @@ guint tracker_store_get_queue_size (void);
void tracker_store_unreg_batches (const gchar *client_id);
+void tracker_store_set_active (gboolean active);
+
G_END_DECLS
#endif /* __TRACKER_STORE_STORE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]