[telepathy-mission-control/master] _mcd_dispatch_operation_set_handler_failed: if all possible handlers have failed, finish the CDO and terminate the channels

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Oct 28 15:03:00 PDT 2009


_mcd_dispatch_operation_close_as_undispatchable will try and fail to
call _mcd_dispatch_operation_finish again, which isn't entirely elegant,
but works.
---
 src/mcd-dispatch-operation.c                     |   18 ++++++++++++++++++
 test/twisted/dispatcher/handle-channels-fails.py |    5 ++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index 0feb6fd..34c9065 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -1525,6 +1525,7 @@ _mcd_dispatch_operation_set_handler_failed (McdDispatchOperation *self,
                                             const GError *error)
 {
     GList *iter, *next;
+    gchar **handler;
 
     if (self->priv->failed_handlers == NULL)
     {
@@ -1558,6 +1559,23 @@ _mcd_dispatch_operation_set_handler_failed (McdDispatchOperation *self,
             g_queue_delete_link (self->priv->approvals, iter);
         }
     }
+
+    for (handler = self->priv->possible_handlers;
+         handler != NULL && *handler != NULL;
+         handler++)
+    {
+        if (g_hash_table_lookup (self->priv->failed_handlers, *handler)
+            == NULL)
+        {
+            /* we'll try this one soon */
+            return;
+        }
+    }
+
+    DEBUG ("All possible handlers failed, giving up");
+    _mcd_dispatch_operation_finish (self, error->domain, error->code,
+                                    "%s", error->message);
+    _mcd_dispatch_operation_close_as_undispatchable (self);
 }
 
 static gboolean
diff --git a/test/twisted/dispatcher/handle-channels-fails.py b/test/twisted/dispatcher/handle-channels-fails.py
index adbe08e..04b51ef 100644
--- a/test/twisted/dispatcher/handle-channels-fails.py
+++ b/test/twisted/dispatcher/handle-channels-fails.py
@@ -204,9 +204,8 @@ def test(q, bus, mc):
 
     e = q.expect('dbus-error', method='HandleWith')
 
-    if 0: # FIXME: at the moment the error is a generic "no more handlers"
-        assert e.error.get_dbus_name() == cs.NOT_AVAILABLE
-        assert e.error.get_dbus_message() == 'Also blind drunk'
+    assert e.error.get_dbus_name() == cs.NOT_AVAILABLE
+    assert e.error.get_dbus_message() == 'Also blind drunk'
 
     # MC gives up and closes the channel. This is the end of the CDO.
     q.expect_many(
-- 
1.5.6.5




More information about the telepathy-commits mailing list