Commit dff0e6f4 authored by Jürg Billeter's avatar Jürg Billeter

libtracker-sparql: Fix deadlock when tracker is not available

If a connection attempt failed, subsequent connection attempts
deadlocked.
parent dd81271c
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment