[tracker] libtracker-sparql: Fix deadlock when tracker is not available
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-sparql: Fix deadlock when tracker is not available
- Date: Wed, 13 Apr 2011 08:42:34 +0000 (UTC)
commit dff0e6f4f006ce11a20fb9e8550232c8d59f5581
Author: Jürg Billeter <j bitron ch>
Date: Wed Apr 13 10:39:02 2011 +0200
libtracker-sparql: Fix deadlock when tracker is not available
If a connection attempt failed, subsequent connection attempts
deadlocked.
src/libtracker-sparql-backend/tracker-backend.vala | 38 ++++++++++----------
1 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala b/src/libtracker-sparql-backend/tracker-backend.vala
index 110a203..76eb956 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -195,31 +195,31 @@ class Tracker.Sparql.Backend : Connection {
static new Connection get (bool is_direct_only = false, Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError, SpawnError {
door.lock ();
- // assign to owned variable to ensure it doesn't get freed between unlock and return
- var result = singleton;
- if (result != null) {
- assert (direct_only == is_direct_only);
- door.unlock ();
- return result;
- }
-
- log_init ();
+ try {
+ // assign to owned variable to ensure it doesn't get freed between check and return
+ var result = singleton;
+ if (result != null) {
+ assert (direct_only == is_direct_only);
+ return result;
+ }
- direct_only = is_direct_only;
+ log_init ();
- result = new Tracker.Sparql.Backend ();
+ direct_only = is_direct_only;
- if (cancellable != null && cancellable.is_cancelled ()) {
- door.unlock ();
- throw new IOError.CANCELLED ("Operation was cancelled");
- }
+ result = new Tracker.Sparql.Backend ();
- singleton = result;
- result.add_weak_pointer ((void**) (&singleton));
+ if (cancellable != null && cancellable.is_cancelled ()) {
+ throw new IOError.CANCELLED ("Operation was cancelled");
+ }
- door.unlock ();
+ singleton = result;
+ result.add_weak_pointer ((void**) (&singleton));
- return singleton;
+ return singleton;
+ } finally {
+ door.unlock ();
+ }
}
public static new Connection get_internal (bool is_direct_only = false, Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError, SpawnError {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]