From: Travis Reitter Date: Thu, 7 Jul 2011 00:21:56 +0000 (-0700) Subject: Cut unnecessary Trf.PersonaStore._is_prepared locking. X-Git-Tag: FOLKS_0_7_3~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7753697900fdb7943ac48e620676409f46f40c4d;p=platform%2Fupstream%2Ffolks.git Cut unnecessary Trf.PersonaStore._is_prepared locking. 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 c53202f..437d033 100644 --- a/backends/tracker/lib/trf-persona-store.vala +++ b/backends/tracker/lib/trf-persona-store.vala @@ -1066,94 +1066,91 @@ public class Trf.PersonaStore : Folks.PersonaStore { Internal.profiling_start ("preparing Trf.PersonaStore (ID: %s)", this.id); - lock (this._is_prepared) + if (this._is_prepared || this._prepare_pending) { - if (this._is_prepared || this._prepare_pending) - { - return; - } + return; + } + + try + { + this._prepare_pending = true; try { - this._prepare_pending = true; - - try - { - this._connection = - yield Tracker.Sparql.Connection.get_async (); - - Internal.profiling_point ("got connection in " + - "Trf.PersonaStore (ID: %s)", this.id); - - yield this._build_predicates_table (); - - Internal.profiling_point ("build predicates table in " + - "Trf.PersonaStore (ID: %s)", this.id); - - yield this._do_add_contacts (this._INITIAL_QUERY.printf ("")); - - Internal.profiling_point ("added contacts in " + - "Trf.PersonaStore (ID: %s)", this.id); - - /* Don't add a match rule for all signals from Tracker but - * only for GraphUpdated with the specific class we need. We - * don't want to be woken up for irrelevent updates on the - * graph. - */ - this._resources_object = yield GLib.Bus.get_proxy ( - BusType.SESSION, - this._OBJECT_NAME, - this._OBJECT_PATH, - DBusProxyFlags.DO_NOT_CONNECT_SIGNALS | - DBusProxyFlags.DO_NOT_LOAD_PROPERTIES); - this._resources_object.g_connection.signal_subscribe - (this._OBJECT_NAME, this._OBJECT_IFACE, - "GraphUpdated", this._OBJECT_PATH, - Trf.OntologyDefs.PERSON_CLASS, GLib.DBusSignalFlags.NONE, - this._graph_updated_cb); - - Internal.profiling_point ("got resources proxy in " + - "Trf.PersonaStore (ID: %s)", this.id); - - this._is_prepared = true; - this.notify_property ("is-prepared"); - - /* By this time (due to having done the INITIAL_QUERY above) - * we have already reached a quiescent state. */ - this._is_quiescent = true; - this.notify_property ("is-quiescent"); - } - catch (GLib.IOError e1) - { - warning ("Could not connect to D-Bus service: %s", - e1.message); - this.removed (); - throw new PersonaStoreError.INVALID_ARGUMENT (e1.message); - } - catch (Tracker.Sparql.Error e2) - { - warning ("Error fetching SPARQL connection handler: %s", - e2.message); - this.removed (); - throw new PersonaStoreError.INVALID_ARGUMENT (e2.message); - } - catch (GLib.DBusError e3) - { - warning ("Could not connect to D-Bus service: %s", - e3.message); - this.removed (); - throw new PersonaStoreError.INVALID_ARGUMENT (e3.message); - } - finally - { - this._prepare_pending = false; - } + this._connection = + yield Tracker.Sparql.Connection.get_async (); + + Internal.profiling_point ("got connection in " + + "Trf.PersonaStore (ID: %s)", this.id); + + yield this._build_predicates_table (); + + Internal.profiling_point ("build predicates table in " + + "Trf.PersonaStore (ID: %s)", this.id); + + yield this._do_add_contacts (this._INITIAL_QUERY.printf ("")); + + Internal.profiling_point ("added contacts in " + + "Trf.PersonaStore (ID: %s)", this.id); + + /* Don't add a match rule for all signals from Tracker but + * only for GraphUpdated with the specific class we need. We + * don't want to be woken up for irrelevent updates on the + * graph. + */ + this._resources_object = yield GLib.Bus.get_proxy ( + BusType.SESSION, + this._OBJECT_NAME, + this._OBJECT_PATH, + DBusProxyFlags.DO_NOT_CONNECT_SIGNALS | + DBusProxyFlags.DO_NOT_LOAD_PROPERTIES); + this._resources_object.g_connection.signal_subscribe + (this._OBJECT_NAME, this._OBJECT_IFACE, + "GraphUpdated", this._OBJECT_PATH, + Trf.OntologyDefs.PERSON_CLASS, GLib.DBusSignalFlags.NONE, + this._graph_updated_cb); + + Internal.profiling_point ("got resources proxy in " + + "Trf.PersonaStore (ID: %s)", this.id); + + this._is_prepared = true; + this.notify_property ("is-prepared"); + + /* By this time (due to having done the INITIAL_QUERY above) + * we have already reached a quiescent state. */ + this._is_quiescent = true; + this.notify_property ("is-quiescent"); + } + catch (GLib.IOError e1) + { + warning ("Could not connect to D-Bus service: %s", + e1.message); + this.removed (); + throw new PersonaStoreError.INVALID_ARGUMENT (e1.message); + } + catch (Tracker.Sparql.Error e2) + { + warning ("Error fetching SPARQL connection handler: %s", + e2.message); + this.removed (); + throw new PersonaStoreError.INVALID_ARGUMENT (e2.message); + } + catch (GLib.DBusError e3) + { + warning ("Could not connect to D-Bus service: %s", + e3.message); + this.removed (); + throw new PersonaStoreError.INVALID_ARGUMENT (e3.message); } finally { this._prepare_pending = false; } } + finally + { + this._prepare_pending = false; + } Internal.profiling_end ("preparing Trf.PersonaStore (ID: %s)", this.id); }