[telepathy-glib/master] TpConnection: avoid calling GetInterfaces more than once

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Jun 25 07:20:19 PDT 2009


tp_connection_got_interfaces_cb (effectively) asserts that it hasn't been
called more than once. If we get StatusChanged(=> CONNECTED) followed
immediately by GetStatus returning CONNECTED, which is rare but possible
(we'd have to call GetStatus at the same moment that the status changed),
then we could end up scheduling two calls to GetInterfaces.

Reviewed-by: Will Thompson <will.thompson at collabora.co.uk>
---
 telepathy-glib/connection-internal.h |    1 +
 telepathy-glib/connection.c          |    4 +++-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/telepathy-glib/connection-internal.h b/telepathy-glib/connection-internal.h
index 8e248ee..8e41b2e 100644
--- a/telepathy-glib/connection-internal.h
+++ b/telepathy-glib/connection-internal.h
@@ -45,6 +45,7 @@ struct _TpConnectionPrivate {
     GHashTable *contacts;
 
     unsigned ready:1;
+    unsigned called_get_interfaces:1;
     unsigned tracking_aliases_changed:1;
     unsigned tracking_avatar_updated:1;
     unsigned tracking_presences_changed:1;
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index 658e679..4a67aae 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -383,10 +383,12 @@ tp_connection_status_changed (TpConnection *self,
   g_object_notify ((GObject *) self, "status");
   g_object_notify ((GObject *) self, "status-reason");
 
-  if (status == TP_CONNECTION_STATUS_CONNECTED)
+  if (status == TP_CONNECTION_STATUS_CONNECTED &&
+      !self->priv->called_get_interfaces)
     {
       tp_cli_connection_call_get_interfaces (self, -1,
           tp_connection_got_interfaces_cb, NULL, NULL, NULL);
+      self->priv->called_get_interfaces = TRUE;
     }
 }
 
-- 
1.5.6.5



More information about the telepathy-commits mailing list