[systemd-devel] sd-bus: calling D-Bus method from a D-Bus method callback upon the same D-Bus connection

Lennart Poettering lennart at poettering.net
Sat Jan 26 15:22:47 UTC 2019


On Sa, 26.01.19 16:15, Stanislav Angelovič (angelovic.s at gmail.com) wrote:

> Hi guys,
>
> in sd-bus, when D-Bus method callback of my service is invoked (someone is
> calling me), is it possible to issue another synchronous call to another
> service upon *the same sd_bus connection*? I.e. does sd_bus instance allow
> that while it is processing incoming requests and invoking callbacks, a
> callback in its body uses this sd_bus instance to quickly issue another
> request-reply call before returning?

Yes, you may synchronously call into other bus services from an async
msg hander, but as long as that call runs no incoming msgs besides the
expected reply will be processed. This means effectively that while
the synchronous call is running all incoming messages are queued until
the reply is seen, then the reply is processed and the call returns,
and only then after you return back into the event loop the queued
incoming messages are dispatched.

This also means that while in dbus normally everything is strictly
ordered, if you do things in this way the reply is "pulled ahead"
during processing, and the other msgs incoming "pushed back".

Hope this makes sense?

Lennart

--
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list