Methods need always return values?

Simon McVittie simon.mcvittie at
Tue Apr 15 09:37:26 PDT 2008

Hash: SHA1

On Tue, 15 Apr 2008 at 14:45:40 +0000, Robert Rawlins wrote:
> At the moment I'm returning from the method immediately and then performing some long running tasks, then emitting some signals when they are complete. By returning a value immediately it means the DBUS method call doesn't timeout whilst the processes in the method take some time to run. The problem which occurs is due to the fact that I need to use 'context' later on in the method, this means it crashes my application with a segfault, presumably because 'context' has already been returned.

According to the gtkdoc, the only things you can do with a
DBusGMethodInvocation are to return successfully (dbus_g_method_return),
return a failure (dbus_g_method_return_error), construct a custom reply message
(best avoided), or get the unique-name of the sender

All of those except dbus_g_method_get_sender fall under the heading of
"return from the method call", and you can only sensibly do that once.
As you have noticed, dbus-glib takes advantage of this to free the context
after you've returned something from the method.

So, if you want the sender address, retrieve it first, and pass *that*
to your other code.

(I can easily believe that there are undocumented functions to get other
properties of the method-call message, but the same comments would apply to
those too.)



More information about the dbus mailing list