[Bug 37844] Don't try to reconnect an account over and over for certain errors

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Jun 15 14:07:38 CEST 2011


https://bugs.freedesktop.org/show_bug.cgi?id=37844

--- Comment #5 from Simon McVittie <simon.mcvittie at collabora.co.uk> 2011-06-15 05:07:38 PDT ---
Review of attachment 47990:
 --> (https://bugs.freedesktop.org/review?bug=37844&attachment=47990)

::: src/mcd-connection.c
@@ +1222,2 @@
     if ((priv->abort_reason == TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED ||
+         code == TP_ERROR_NETWORK_ERROR) &&

ConnectionLost (for instance) is also a NETWORK_ERROR, so this change would
make MC not reconnect when a connection was lost (if CMs used ConnectionLost
correctly, which in practice they probably don't).

If you're going to switch away from using abort_reason (which I would
encourage!), I'd suggest not using abort_reason in this conditional at all.

Perhaps factor out a function:

gboolean
connection_should_reconnect (TpConnection *tp_conn,
    guint domain,
    gint code)
{
  TpConnectionStatusReason reason;

  if (domain == TP_ERROR)
    {
      switch (code)
        {
        case TP_ERROR_CONNECTION_FAILED:
        case TP_ERROR_CONNECTION_LOST:
        case TP_ERROR_DISCONNECTED:
        case TP_ERROR_NETWORK_ERROR:
          return TRUE;

        case TP_ERROR_SOFTWARE_UPGRADE_REQUIRED:
        case TP_ERROR_SERVICE_BUSY:
        case TP_ERROR_CONNECTION_REPLACED:
        case TP_ERROR_ALREADY_CONNECTED:
        case TP_ERROR_CONNECTION_REFUSED:
          /* possibly a few others (notably, all the encryption
           * things), but the others are hopefully not
           * generically mapped to NETWORK_ERROR anyway */
          return FALSE;
        }
    }
  else if (domain == TP_DBUS_ERROR)
    {
      switch (code)
        {
          TP_DBUS_ERROR_NAME_OWNER_LOST:
            /* CM crashed */
            return TRUE;
        }
    }

  /* not sure what the GError meant, so check the generic
   * status code */
  tp_connection_get_status (tp_conn, &reason);

  switch (reason)
    {
      case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
        return TRUE;
    }

  return FALSE;
}

Bonus points if you add some vaguely useful DEBUG().

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.



More information about the telepathy-bugs mailing list