[systemd-devel] Calling sd_bus_reply_method_return outside method handler

Lennart Poettering mzerqung at 0pointer.de
Tue Jan 15 13:05:26 UTC 2019


On Mo, 14.01.19 21:07, Jean Valjean (valjean.jean1802 at gmail.com) wrote:

> I want to send a reply to a method call outside method_handler. Is it
> possible?
> In the method_handler I increase reference count of sd_bus_message and send
> it to the other thread. From there I want to call
> sd_bus_reply_method_return to send a reply but get Unknown method or
> interface error when I invoke method with bussctl --user call. If I call
> the return method from method_handler everything works as expected.

Note that sd-bus is not thread-safe on its own. It's threads-aware
however: if you are careful to lock around all invocations of sd_bus
using a single connection (and its associated messages) is generally
fine, but it's up to you to carefully lock.

So yeah, it's certainly OK to reply to an incoming bus call msgs
outside of the stack method handler stack frame, but if that means
threads, then make sure you know what you are doing.

Lennart

--
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list