[systemd-devel] sd-bus delayed reply

Jean Valjean valjean.jean1802 at gmail.com
Mon Jan 28 22:24:57 UTC 2019


I feel like Tom Hanks in the Cast Away when he made fire. Thank you.

Boris


On Mon, 28 Jan 2019 at 14:07, Lennart Poettering <lennart at poettering.net> wrote:
>
> On Mo, 28.01.19 14:00, Jean Valjean (valjean.jean1802 at gmail.com) wrote:
> 65;5403;1c
> > Can I, in principle, register objects and interfaces with
> > sd_bus_add_object_vtable like in
> > http://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
> > and in handler function, take a copy, of a reference to message
> > object, to global variable and use it later with
> > sd_bus_reply_method_return?
> > I tried to do that. But it seems, that when handler function returns,
> > it sends an error message to calling client if
> > sd_bus_reply_method_return
> > was not called inside handler.
>
> Depends on what you return in the handler function:
>
> 1. Returning < 0 means sd-bus will generate an automatic error reply
>    for you, taking the returned value as negative errno (or looking
>    into the sd_bus_error struct passed to you, which takes
>    precedence).
>
> 2. Returning 0 means it will generate an automatic response suggesting
>    that the method call was not handled.
>
> 3. Returning > 0 means however that you handled the message, and
>    sd-bus will not generate any reply.
>
> Hence, just exit your function with "return 1" if you don't want any
> automatic reply to be generated and all is good.
>
> (The above applies to all msg handler functions in sd-bus
> basically. The reason for doing #2 is that if you install filter
> functions that are called on every single incoming msg you can decide
> by returning 0 or 1 whether further filter functions shall be called,
> or not)
>
> Lennart
>
> --
> Lennart Poettering, Red Hat


More information about the systemd-devel mailing list