[patch][python] Survive being kicked off the bus during a method call

John (J5) Palmieri johnp at redhat.com
Wed Feb 21 09:12:28 PST 2007


Commit.  Looks good.

On Wed, 2007-02-21 at 15:51 +0000, Simon McVittie wrote:
> This causes the crash Erich Schubert reported to "only" raise
> DBusException when we try to introspect /org/freedesktop/DBus/Local,
> rather than carrying on regardless with a NULL PendingCall.
> 
> >From f1e0a64b9f02a77cfd468f146ed3f398b2c1c8bc Mon Sep 17 00:00:00 2001
> From: Simon McVittie <simon.mcvittie at collabora.co.uk>
> Date: Wed, 21 Feb 2007 15:04:20 +0000
> Subject: [PATCH] If send_with_reply() returns TRUE but with pending call NULL, cope gracefully.
> This is a workaround for the fact that trying to use the object path
> /org/freedesktop/DBus/Local in a message header (e.g. when introspecting
> trackerd with dbus-inspector) causes us to be disconnected by the bus daemon.
> ---
>  _dbus_bindings/conn-methods.c |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/_dbus_bindings/conn-methods.c b/_dbus_bindings/conn-methods.c
> index dae1816..d4d031b 100644
> --- a/_dbus_bindings/conn-methods.c
> +++ b/_dbus_bindings/conn-methods.c
> @@ -403,6 +403,13 @@ Connection_send_message_with_reply(Connection *self, PyObject *args, PyObject *k
>          return PyErr_NoMemory();
>      }
>  
> +    if (!pending) {
> +        /* connection is disconnected (doesn't return FALSE!) */
> +        PyErr_SetString (DBusPyException, "Connection is disconnected - "
> +                                          "unable to make method call");
> +        return NULL;
> +    }
> +
>      return DBusPyPendingCall_ConsumeDBusPendingCall(pending, callable);
>  }
>  



More information about the dbus mailing list