From: Travis Reitter Date: Tue, 5 Jul 2011 21:36:49 +0000 (-0700) Subject: Fix Tracker structure locking for user-initiated Persona adds. X-Git-Tag: FOLKS_0_7_3~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67f8e41bcc56fe1c38f7e6eb4b60ef5dc971549a;p=platform%2Fupstream%2Ffolks.git Fix Tracker structure locking for user-initiated Persona adds. Helps: bgo#652637 - Don't hold locks across async calls --- 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); + } } }