Bug 665728 — prepare() isn't mutually exclusive inside a single thread
authorPhilip Withnall <philip@tecnocode.co.uk>
Thu, 8 Dec 2011 14:54:29 +0000 (14:54 +0000)
committerPhilip Withnall <philip@tecnocode.co.uk>
Fri, 9 Dec 2011 08:53:28 +0000 (08:53 +0000)
Fix Tpf.PersonaStore.prepare() to only run once, even if it's called multiple
times from the same thread (e.g. if the caller wasn't yielding on the async
call returning).

Closes: bgo#665728

NEWS
backends/telepathy/lib/tpf-persona-store.vala

diff --git a/NEWS b/NEWS
index f1b6778..879c982 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Bugs fixed:
 * Bug 663889 — crash due to NameDetails which fail to guarantee
   non-null full-name/nickname
 * Bug 665039 — Crash in folks_backends_sw_backend_add_service
+* Bug 665728 — TpfPersonaStore: prepare() isn't mutually exclusive inside a
+  single thread
 
 Overview of changes from libfolks 0.6.4.1 to libfolks 0.6.5
 =============================================================
index e3a49a1..567ec17 100644 (file)
@@ -99,6 +99,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
   private MaybeBool _can_group_personas = MaybeBool.UNSET;
   private MaybeBool _can_remove_personas = MaybeBool.UNSET;
   private bool _is_prepared = false;
+  private bool _prepare_pending = false;
   private bool _is_quiescent = false;
   private bool _got_stored_channel_members = false;
   private bool _got_self_handle = false;
@@ -561,8 +562,10 @@ public class Tpf.PersonaStore : Folks.PersonaStore
     {
       lock (this._is_prepared)
         {
-          if (!this._is_prepared)
+          if (!this._is_prepared && !this._prepare_pending)
             {
+              this._prepare_pending = true;
+
               this._account_manager = AccountManager.dup ();
 
               this._account_manager.account_removed.connect ((a) =>
@@ -626,6 +629,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
                 }
 
               this._is_prepared = true;
+              this._prepare_pending = false;
               this.notify_property ("is-prepared");
             }
         }