[tracker/fixed-cursor] tracker-store: Add locks for dbus access
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/fixed-cursor] tracker-store: Add locks for dbus access
- Date: Mon, 26 Apr 2010 13:54:53 +0000 (UTC)
commit 04d0102d85f8026600590f2104dcf062f23c0257
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Apr 26 15:53:46 2010 +0200
tracker-store: Add locks for dbus access
src/tracker-store/tracker-resources.c | 61 ++++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index f32bb7d..01179bf 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -46,6 +46,8 @@
#define RDF_PREFIX TRACKER_RDF_PREFIX
#define RDF_TYPE RDF_PREFIX "type"
+static GStaticMutex tracker_dbus_mutex = G_STATIC_MUTEX_INIT;
+
/* I *know* that this is some arbitrary number that doesn't seem to
* resemble anything. In fact it's what I experimentally measured to
* be a good value on a default Debian testing which has
@@ -165,13 +167,21 @@ turtle_import_callback (GError *error, gpointer user_data)
info->context,
&error,
NULL);
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return_error (info->context, error);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
return;
}
tracker_dbus_request_success (info->request_id,
info->context);
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return (info->context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
}
void
@@ -218,14 +228,21 @@ query_callback (gpointer inthread_data, GError *error, gpointer user_data)
info->context,
&ptr->error,
NULL);
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return_error (info->context, ptr->error);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
g_error_free (ptr->error);
} else {
tracker_dbus_request_success (info->request_id,
info->context);
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_send_reply (info->context, ptr->reply);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
}
g_slice_free (InThreadPtr, ptr);
@@ -242,16 +259,14 @@ query_inthread (TrackerDBCursor *cursor, GError *error, gpointer user_data)
GError *loop_error = NULL;
guint length = 0;
gboolean cont;
- static GStaticMutex dbus_mutex = G_STATIC_MUTEX_INIT;
if (error) {
ptr->error = g_error_copy (error);
return ptr;
}
- g_static_mutex_lock (&dbus_mutex);
+ g_static_mutex_lock (&tracker_dbus_mutex);
reply = dbus_g_method_get_reply (info->context);
- g_static_mutex_unlock (&dbus_mutex);
dbus_message_iter_init_append (reply, &iter);
@@ -299,6 +314,8 @@ query_inthread (TrackerDBCursor *cursor, GError *error, gpointer user_data)
dbus_message_iter_close_container (&iter, &rows_iter);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
if (loop_error) {
ptr->error = loop_error;
ptr->reply = NULL;
@@ -337,7 +354,9 @@ tracker_resources_sparql_query (TrackerResources *self,
info->request_id = request_id;
info->context = context;
+ g_static_mutex_lock (&tracker_dbus_mutex);
sender = dbus_g_method_get_sender (context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
tracker_store_sparql_query (query, TRACKER_STORE_PRIORITY_HIGH,
query_inthread, query_callback, sender,
@@ -356,13 +375,19 @@ update_callback (GError *error, gpointer user_data)
info->context,
&error,
NULL);
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return_error (info->context, error);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
return;
}
tracker_dbus_request_success (info->request_id,
info->context);
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return (info->context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
}
void
@@ -393,7 +418,9 @@ tracker_resources_sparql_update (TrackerResources *self,
info->request_id = request_id;
info->context = context;
+ g_static_mutex_lock (&tracker_dbus_mutex);
sender = dbus_g_method_get_sender (context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
tracker_store_sparql_update (update, TRACKER_STORE_PRIORITY_HIGH, FALSE,
update_callback, sender,
@@ -412,13 +439,21 @@ update_blank_callback (GPtrArray *blank_nodes, GError *error, gpointer user_data
info->context,
&error,
NULL);
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return_error (info->context, error);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
return;
}
tracker_dbus_request_success (info->request_id,
info->context);
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return (info->context, blank_nodes);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
}
void
@@ -449,7 +484,9 @@ tracker_resources_sparql_update_blank (TrackerResources *self,
info->request_id = request_id;
info->context = context;
+ g_static_mutex_lock (&tracker_dbus_mutex);
sender = dbus_g_method_get_sender (context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
tracker_store_sparql_update_blank (update, TRACKER_STORE_PRIORITY_HIGH,
update_blank_callback, sender,
@@ -475,7 +512,11 @@ tracker_resources_sync (TrackerResources *self,
tracker_data_sync ();
tracker_dbus_request_success (request_id, context);
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return (context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
}
void
@@ -506,7 +547,9 @@ tracker_resources_batch_sparql_update (TrackerResources *self,
info->request_id = request_id;
info->context = context;
+ g_static_mutex_lock (&tracker_dbus_mutex);
sender = dbus_g_method_get_sender (context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
tracker_store_sparql_update (update, TRACKER_STORE_PRIORITY_LOW, TRUE,
update_callback, sender,
@@ -525,7 +568,10 @@ batch_commit_callback (gpointer user_data)
tracker_dbus_request_success (info->request_id,
info->context);
+ g_static_mutex_lock (&tracker_dbus_mutex);
dbus_g_method_return (info->context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
}
void
@@ -552,7 +598,9 @@ tracker_resources_batch_commit (TrackerResources *self,
info->request_id = request_id;
info->context = context;
+ g_static_mutex_lock (&tracker_dbus_mutex);
sender = dbus_g_method_get_sender (context);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
tracker_store_queue_commit (batch_commit_callback, sender, info,
destroy_method_info);
@@ -606,7 +654,11 @@ on_statements_committed (gpointer user_data)
while (g_hash_table_iter_next (&iter, &key, &value)) {
TrackerResourceClass *class_ = key;
+
+ g_static_mutex_lock (&tracker_dbus_mutex);
tracker_resource_class_emit_events (class_);
+ g_static_mutex_unlock (&tracker_dbus_mutex);
+
}
g_hash_table_destroy (to_emit);
@@ -619,8 +671,9 @@ on_statements_committed (gpointer user_data)
writebacks = tracker_writeback_get_pending ();
if (writebacks) {
+ g_static_mutex_lock (&tracker_dbus_mutex);
g_signal_emit (resources, signals[WRITEBACK], 0, writebacks);
-
+ g_static_mutex_unlock (&tracker_dbus_mutex);
}
tracker_writeback_reset ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]