Async server with sd-bus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Mon, May 21, 2018 at 8:37 AM, Stanislav AngeloviÄ?
<angelovic.s at gmail.com> wrote:
> Hi folks,
>
> Suppose we have a server whose methods may take relatively long time and I
> would like to process them asynchronously within the server, so while a
> client is waiting for reply to his time-consuming call, other clients (which
> could be served quickly, for example) are not starved because of this.
>
> I suppose sd-bus supports such an approach, since it is message-based.

Correct but this is nothing special to sd-bus but specific to dbus
protocol itself. The magic is in reply cookie field of the replies.
Check this out -
https://dbus.freedesktop.org/doc/dbus-specification.html.

>
> Also, implementation-wise, I suppose these async replies must be sent back
> by the processing thread that handles requests upon the bus connection
> (since sd_bus and sd_bus_message seem to no be thread-safe). So I need to
> sent the reply messages from the worker thread back to the processing
> thread, to send them out.

sd-bus is not thread safe. You either need to handle synchronization
between API calls or do as you suggested for sending out the reply
messages. The same is valid for receiving side of your server. If your
receiver, under the context of receiving task, is performing CPU
intensive operation, no new dbus message is going to be fetched from
the wire until the task is ready to do something else.

Umut

>
> I am right with my assumptions and statements? Have you already solved such
> a problem somewhere in systemd?
>
> Thanks for help and cheers!
>
> Stanislav.
>
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux