[folks] Fix Tracker structure locking for user-initiated Persona adds.



commit 67f8e41bcc56fe1c38f7e6eb4b60ef5dc971549a
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Tue Jul 5 14:36:49 2011 -0700

    Fix Tracker structure locking for user-initiated Persona adds.
    
    Helps: bgo#652637 - Don't hold locks across async calls

 backends/tracker/lib/trf-persona-store.vala |   52 ++++++++++++++-------------
 1 files changed, 27 insertions(+), 25 deletions(-)
---
diff --git a/backends/tracker/lib/trf-persona-store.vala b/backends/tracker/lib/trf-persona-store.vala
index 17c949d..f442e8d 100644
--- a/backends/tracker/lib/trf-persona-store.vala
+++ b/backends/tracker/lib/trf-persona-store.vala
@@ -746,28 +746,25 @@ public class Trf.PersonaStore : Folks.PersonaStore
       builder.insert_close ();
 
       Trf.Persona ret = null;
-      lock (this._personas)
+      string? contact_urn = yield this._insert_persona (builder.result,
+          "p");
+      if (contact_urn != null)
         {
-          string? contact_urn = yield this._insert_persona (builder.result,
-              "p");
-          if (contact_urn != null)
-            {
-              string filter = " FILTER(?_contact = <%s>) ".printf (contact_urn);
-              string query = this._INITIAL_QUERY.printf (filter);
-              var ret_personas = yield this._do_add_contacts (query);
+          string filter = " FILTER(?_contact = <%s>) ".printf (contact_urn);
+          string query = this._INITIAL_QUERY.printf (filter);
+          var ret_personas = yield this._do_add_contacts (query);
 
-              /* Return the first persona we find in the set */
-              foreach (var p in ret_personas)
-                {
-                  ret = p;
-                  break;
-                }
-            }
-          else
+          /* Return the first persona we find in the set */
+          foreach (var p in ret_personas)
             {
-              debug ("Failed to inserting the new persona  into Tracker.");
+              ret = p;
+              break;
             }
         }
+      else
+        {
+          debug ("Failed to inserting the new persona  into Tracker.");
+        }
 
       // Set the avatar on the persona now that we know the persona's UID
       if (ret != null && avatar != null)
@@ -1391,16 +1388,21 @@ public class Trf.PersonaStore : Folks.PersonaStore
       try {
         Sparql.Cursor cursor = yield this._connection.query_async (query);
 
-        while (cursor.next ())
+        lock (this._personas)
           {
-            int tracker_id = (int) cursor.get_integer (Trf.Fields.TRACKER_ID);
-            var p_id = Trf.Persona.build_iid (this.id, tracker_id.to_string ());
-            if (this._personas.get (p_id) == null)
+            while (cursor.next ())
               {
-                var persona = new Trf.Persona (this,
-                    tracker_id.to_string (), cursor);
-                this._personas.set (persona.iid, persona);
-                added_personas.add (persona);
+                int tracker_id =
+                    (int) cursor.get_integer (Trf.Fields.TRACKER_ID);
+                var p_id =
+                    Trf.Persona.build_iid (this.id, tracker_id.to_string ());
+                if (this._personas.get (p_id) == null)
+                  {
+                    var persona = new Trf.Persona (this,
+                        tracker_id.to_string (), cursor);
+                    this._personas.set (persona.iid, persona);
+                    added_personas.add (persona);
+                  }
               }
           }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]