[tracker] libtracker-data: Use internal mutex for TrackerDBManager (de)init
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Use internal mutex for TrackerDBManager (de)init
- Date: Sun, 20 Nov 2016 16:07:31 +0000 (UTC)
commit b7c138a08c578061f99db2c1fc712a6c2db78180
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Nov 5 19:46:53 2016 +0100
libtracker-data: Use internal mutex for TrackerDBManager (de)init
There's no reason to handle locking externally, and this is not a frequent
enough operation to care about thread contention times in eg.
tracker-store, so just add an internal mutex protecting initialization.
src/libtracker-data/tracker-db-manager.c | 64 ++++++++++++++++++++++++------
1 files changed, 51 insertions(+), 13 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 44c2321..be0f2d4 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -168,6 +168,9 @@ static GMutex global_mutex;
static TrackerDBInterface *global_iface;
+/* mutex protecting DB manager initialization/shutdown */
+static GMutex init_mutex;
+
static const gchar *
location_to_directory (TrackerDBLocation location)
{
@@ -847,17 +850,17 @@ perform_recreate (gboolean *first_time, GError **error)
}
}
-gboolean
-tracker_db_manager_init (TrackerDBManagerFlags flags,
- gboolean *first_time,
- gboolean restoring_backup,
- gboolean shared_cache,
- guint select_cache_size,
- guint update_cache_size,
- TrackerBusyCallback busy_callback,
- gpointer busy_user_data,
- const gchar *busy_operation,
- GError **error)
+static gboolean
+db_manager_init_unlocked (TrackerDBManagerFlags flags,
+ gboolean *first_time,
+ gboolean restoring_backup,
+ gboolean shared_cache,
+ guint select_cache_size,
+ guint update_cache_size,
+ TrackerBusyCallback busy_callback,
+ gpointer busy_user_data,
+ const gchar *busy_operation,
+ GError **error)
{
GType etype;
TrackerDBVersion version;
@@ -1245,8 +1248,35 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
return TRUE;
}
-void
-tracker_db_manager_shutdown (void)
+gboolean
+tracker_db_manager_init (TrackerDBManagerFlags flags,
+ gboolean *first_time,
+ gboolean restoring_backup,
+ gboolean shared_cache,
+ guint select_cache_size,
+ guint update_cache_size,
+ TrackerBusyCallback busy_callback,
+ gpointer busy_user_data,
+ const gchar *busy_operation,
+ GError **error)
+{
+ gboolean retval;
+
+ g_mutex_lock (&init_mutex);
+
+ retval = db_manager_init_unlocked (flags, first_time, restoring_backup,
+ shared_cache,
+ select_cache_size, update_cache_size,
+ busy_callback, busy_user_data,
+ busy_operation, error);
+
+ g_mutex_unlock (&init_mutex);
+
+ return retval;
+}
+
+static void
+db_manager_shutdown_unlocked (void)
{
guint i;
@@ -1305,6 +1335,14 @@ tracker_db_manager_shutdown (void)
}
void
+tracker_db_manager_shutdown (void)
+{
+ g_mutex_lock (&init_mutex);
+ db_manager_shutdown_unlocked ();
+ g_mutex_unlock (&init_mutex);
+}
+
+void
tracker_db_manager_remove_all (gboolean rm_journal)
{
g_return_if_fail (initialized != FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]