[tracker/tracker-0.16] libtracker-sparql-backend: Fix connection singleton mutex issue
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.16] libtracker-sparql-backend: Fix connection singleton mutex issue
- Date: Wed, 1 May 2013 12:02:08 +0000 (UTC)
commit e31610da069ca9468b467cf42698248c65c3927c
Author: Martyn Russell <martyn lanedo com>
Date: Tue Apr 30 20:38:39 2013 +0100
libtracker-sparql-backend: Fix connection singleton mutex issue
Since moving from GStaticMutex to GMutex (due to deprecations in GLib), there
has been an issue noticed with the way the mutex is created. Before, the
GStaticMutex was created in the first instance from any API call and used
there on after. This meant the chance of it not being initialised when we used
it was almost 0.
Now with GMutex, because we've initialised it differently (in the class
constructor) with Mutex() this means that g_mutex_init(&_tmp0_) is the
generated source from that. Sadly, the first instance of g_mutex_lock() will
create the mutex for us if it is NULL or {0} anyway and this happens _BEFORE_
the g_mutex_init() call. So we were locking, initing and the unlocking. This
is the cause of the problem.
Now we don't initialise the mutex at all and let that initialise upon first
lock. Note, atomic operations in GLib should protect race conditions affecting
creation of the singleton here.
https://bugzilla.gnome.org/show_bug.cgi?id=697316
src/libtracker-sparql-backend/tracker-backend.vala | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala
b/src/libtracker-sparql-backend/tracker-backend.vala
index 61ab2eb..e9a187d 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -209,7 +209,7 @@ class Tracker.Sparql.Backend : Connection {
static weak Connection? singleton;
static bool log_initialized;
- static Mutex door = Mutex ();
+ static Mutex door;
static new Connection get (Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError,
SpawnError {
door.lock ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]