[telepathy-gabble/master] When Disconnect is called while connect, handle it async

Sjoerd Simons sjoerd.simons at collabora.co.uk
Thu Sep 3 10:01:19 PDT 2009


---
 src/connection.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 3425a21..556eb8a 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -1449,6 +1449,19 @@ connector_connected (GabbleConnection *self,
   TpHandleRepoIface *contact_handles = tp_base_connection_get_handles (base,
       TP_HANDLE_TYPE_CONTACT);
 
+  /* We went to closing while we were connecting... drop the connection and
+   * finish the shutdown */
+  if (priv->closing)
+    {
+      if (conn != NULL)
+        g_object_unref (conn);
+      else
+        g_error_free (error);
+
+      tp_base_connection_finish_shutdown (base);
+      return;
+    }
+
   /* We don't need the connector any more */
   g_object_unref (priv->connector);
   priv->connector = NULL;
@@ -1810,20 +1823,27 @@ connection_shut_down (TpBaseConnection *base)
   if (priv->closing)
     return;
 
+  priv->closing = TRUE;
+
   if (self->porter != NULL)
     {
       DEBUG ("connection still open; closing it");
-      priv->closing = TRUE;
 
+      /* We were connected and setup, disconnect now.. */
       g_assert (priv->disconnect_timer == 0);
       priv->disconnect_timer = g_timeout_add_seconds (DISCONNECT_TIMEOUT,
           disconnect_timeout_cb, self);
 
       wocky_porter_close_async (self->porter, NULL, closed_cb, self);
     }
+  else if (priv->connector != NULL)
+    {
+      /* FIXME: cancel connecting if we are connecting, for now we wait until
+       * the connection is finished and then drop it directly */
+      DEBUG ("connecting waiting for it to finish before closing");
+    }
   else
     {
-      /* FIXME: cancel connecting if we are connecting */
       tp_base_connection_finish_shutdown (base);
     }
 }
-- 
1.5.6.5




More information about the telepathy-commits mailing list