[folks] telepathy: Improve error handling on connection failure of a CM



commit 366b5ed1094d070ab9dbcd01965e4f5bfab70694
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Aug 19 16:03:48 2015 +0100

    telepathy: Improve error handling on connection failure of a CM
    
    If a CM is initially offline when the Tpf.PersonaStore is created,
    calling this.account.connection.prepare_async() will start trying to
    connect it. If the host is unreachable, this will result in waiting for
    a network timeout before Telepathy can declare failure.
    
    There are two problems here:
     • This network timeout may be longer than the quiescence timeout built
    in to the IndividualAggregator. There’s not much we can do about that.
     • The GError was not previously handled properly, so the PersonaStore
    would never reach quiescence anyway.
    
    Fix this by falling back to loading the cache if connecting fails.

 backends/telepathy/lib/tpf-persona-store.vala |   33 ++++++++++++++++++-------
 1 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index b8b8854..499f48e 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -744,7 +744,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
       this._notify_connection_cb_async.begin ();
     }
 
-  private async void _notify_connection_cb_async () throws GLib.Error
+  private async void _notify_connection_cb_async ()
     {
       debug ("_notify_connection_cb_async() for Tpf.PersonaStore %p ('%s').",
           this, this.id);
@@ -753,14 +753,29 @@ public class Tpf.PersonaStore : Folks.PersonaStore
           "(ID: %s)", this.id);
 
       /* Ensure the connection is prepared as necessary. */
-      yield this.account.connection.prepare_async ({
-          TelepathyGLib.Connection.get_feature_quark_contact_list (),
-          TelepathyGLib.Connection.get_feature_quark_contact_groups (),
-          TelepathyGLib.Connection.get_feature_quark_contact_info (),
-          TelepathyGLib.Connection.get_feature_quark_connected (),
-          TelepathyGLib.Connection.get_feature_quark_aliasing (),
-          0
-      });
+      try
+        {
+          yield this.account.connection.prepare_async ({
+              TelepathyGLib.Connection.get_feature_quark_contact_list (),
+              TelepathyGLib.Connection.get_feature_quark_contact_groups (),
+              TelepathyGLib.Connection.get_feature_quark_contact_info (),
+              TelepathyGLib.Connection.get_feature_quark_connected (),
+              TelepathyGLib.Connection.get_feature_quark_aliasing (),
+              0
+          });
+        }
+      catch (GLib.Error e)
+        {
+          debug ("Failed to connect CM for Tpf.PersonaStore %p ('%s'): %s",
+              this, this.id, e.message);
+
+          /* If we're disconnected, advertise personas from the cache
+           * instead. */
+          yield this._load_cache (null);
+          this._force_quiescent ();
+
+          return;
+        }
 
       if (!this.account.connection.has_interface_by_id (
           iface_quark_connection_interface_contact_list ()))


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