[systemd-devel] sd-bus: process ret_error from callback

Lennart Poettering lennart at poettering.net
Fri Jun 28 13:15:04 UTC 2019


On Do, 27.06.19 18:50, Liam Beguin (lvb at xiphos.com) wrote:

> Hi all,
>
> I'm trying to process the `sd_bus_error` set in a
> `sd_bus_message_handler_t` callback in my main loop but I can't seem
> to be able to do it properly...

What have you bound that handler to? If you bound it to a method
vtable entry, then note that the error you return in the bus error is
automatically sent by to the client as method reply.

If you have bound it to a signal, then the error is debug logged, and
the signal binding is turned off. It's not useful beyond debugging to
return a bus error object from such a signal message handler.

Or hmm, i figure there's some confusion about the error parameter of
the function prototype alltogether? note that it is a *return*
paramter, not an input parameter. I.e. your implementation of a
message handler function can use it to return an error back, it's not
recieving anything that way. The argument name in the prototype is
called "ret_error" btw, the "ret_" is supposed to indicate that it's a
return parameter, not an input parameter. (Also if it was input we'd
declare it const, which it isn't)

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list