[tracker/libtracker-sparql: 2/5] libtracker-sparql-backend: Protect singleton weak pointer with mutex
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-sparql: 2/5] libtracker-sparql-backend: Protect singleton weak pointer with mutex
- Date: Thu, 19 May 2011 08:24:31 +0000 (UTC)
commit 68301891f9b4350befc0ca6daad94f8dbe5456d1
Author: Jürg Billeter <j bitron ch>
Date: Thu May 19 09:18:48 2011 +0200
libtracker-sparql-backend: Protect singleton weak pointer with mutex
src/libtracker-sparql-backend/tracker-backend.vala | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala b/src/libtracker-sparql-backend/tracker-backend.vala
index b1190a8..2a1ac1a 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -52,6 +52,24 @@ class Tracker.Sparql.Backend : Connection {
}
}
+ public override void dispose () {
+ door.lock ();
+
+ try {
+ // Ensure this instance is not used for any new calls to Tracker.Sparql.Connection.get.
+ // However, a call to Tracker.Sparql.Connection.get between g_object_unref and the
+ // above lock might have increased the reference count of this instance to 2 (or more).
+ // Therefore, we must not clean up direct/bus connection in dispose.
+ if (singleton == this) {
+ singleton = null;
+ }
+ } finally {
+ door.unlock ();
+ }
+
+ base.dispose ();
+ }
+
public override Cursor query (string sparql, Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError
requires (bus != null || direct != null) {
debug ("%s(): '%s'", Log.METHOD, sparql);
@@ -211,7 +229,6 @@ class Tracker.Sparql.Backend : Connection {
}
singleton = result;
- result.add_weak_pointer ((void**) (&singleton));
}
assert (direct_only == is_direct_only);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]