Commit d94b174d authored by Travis Reitter's avatar Travis Reitter Committed by Jeremy Whiting
Browse files

Prevent extra "concurrent" PersonaStore.prepare() calls from one thread.

The lock() calls which were in place only prevent concurrent calls from
different threads; however, the critical section could still be reached
from two async calls in the same thread a la:

backend.prepare.begin ((s,r) => {...});
backend.prepare.begin ((s,r) => {...});

The bodies of the handlers would not literally execute concurrently, but
would be interleaved if each were sufficiently long. Our fix simply
ignores any calls which happen while one is still working.

(yield backend.prepare(); yield backend.prepare(); was already safe, of
course)

Helps: bgo#652637 - Don't hold locks across async calls
parent 1492a80a
......@@ -235,6 +235,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
_("The relationship key file '%s' could not be loaded: %s"),
filename, e1.message);
this.removed ();
this._prepare_pending = false;
return;
}
}
......@@ -257,6 +258,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
_("The relationship key file directory '%s' could not be created: %s"),
parent_dir.get_path (), e3.message);
this.removed ();
this._prepare_pending = false;
return;
}
}
......@@ -281,6 +283,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
_("The relationship key file '%s' could not be created: %s"),
filename, e2.message);
this.removed ();
this._prepare_pending = false;
return;
}
}
......@@ -306,6 +309,7 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
}
this._is_prepared = true;
this._prepare_pending = false;
this.notify_property ("is-prepared");
/* We've finished loading all the personas we know about */
......
......@@ -565,6 +565,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
"(ID: %s)", this.id);
this._is_prepared = true;
this._prepare_pending = false;
this.notify_property ("is-prepared");
}
finally
......
......@@ -1144,6 +1144,10 @@ public class Trf.PersonaStore : Folks.PersonaStore
this.removed ();
throw new PersonaStoreError.INVALID_ARGUMENT (e3.message);
}
finally
{
this._prepare_pending = false;
}
}
finally
{
......
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