[telepathy-mission-control/telepathy-mission-control-5.2] McdAccount: don't allow transition from one transport to another

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Aug 13 08:41:38 PDT 2009


A Telepathy Connection "almost always" represents a TCP socket or
something similar, which has a source address that is fixed at the time
the socket is created. TCP sockets cannot migrate between source
addresses, so we would be wrong to suggest that Telepathy Connections can.

Accordingly, allow the transitions none -> anything and anything -> none,
but silently suppress attempts to go t1 -> t2 for t1, t2 different
transports.

The bug that this fixes:

* we have a transport T1 with source address 1.1.1.1
* a transport T2 comes up with source address 2.2.2.2
* a Connection C1 to an account A whose server is 9.9.9.9
  (its TCP socket is 1.1.1.1:11111 <-> 9.9.9.9:9999) is still CONNECTING
* as a result of T2 coming up while C1 is not yet CONNECTED, McdMaster
  tells C1 (again) to connect [1]
* transport T1 drops

Desired result:
* because C1 is bound to T1, it is disconnected
* McdMaster looks for another transport usable by A, finds T2, and
  creates a new connection C2; C2's underlying TCP stream is now
  something like 2.2.2.2:22222 <-> 9.9.9.9:9999

Buggy result:
* at [1], McdMaster re-binds C1 to T2
* because C1 is not bound to T1, it is not disconnected
* the TCP stream (1.1.1.1:11111 <-> 9.9.9.9:9999) still exists, even
  though it cannot possibly work, until keepalives (or similar)
  cause the CM to notice that the connection has gone down
---
 src/mcd-account.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/mcd-account.c b/src/mcd-account.c
index 8dac309..c688dd5 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -3099,7 +3099,30 @@ mcd_account_connection_bind_transport (McdAccount *account,
 {
     g_return_if_fail (MCD_IS_ACCOUNT (account));
 
-    account->priv->transport = transport;
+    if (transport == account->priv->transport)
+    {
+        DEBUG ("account %s transport remains %p",
+               account->priv->unique_name, transport);
+    }
+    else if (transport == NULL)
+    {
+        DEBUG ("unbinding account %s from transport %p",
+               account->priv->unique_name, account->priv->transport);
+        account->priv->transport = NULL;
+    }
+    else if (account->priv->transport == NULL)
+    {
+        DEBUG ("binding account %s to transport %p",
+               account->priv->unique_name, transport);
+
+        account->priv->transport = transport;
+    }
+    else
+    {
+        DEBUG ("disallowing migration of account %s from transport %p to %p",
+               account->priv->unique_name, account->priv->transport,
+               transport);
+    }
 }
 
 McdTransport *
-- 
1.5.6.5




More information about the telepathy-commits mailing list