Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

D-Bus threading model

I am starting to use D-Bus as the IPC mechanism for a new project in Linux/KDE. And I've discovered that the documentation does not really address concurrency at all. How are D-Bus services expected to deal with multiple concurrent calls coming in from different clients? What's the threading model? Can a service assume that it is single-threaded and D-Bus will queue up requests on its own?

like image 469
Rob H Avatar asked Jan 02 '10 20:01

Rob H


1 Answers

As a protocol, D-Bus doesn't address threading.

D-Bus connections receive message serially. At the protocol level, replies to message are asynchronous: i.e. the sender doesn't have to wait for replies before sending more messages.

While in principle a D-Bus implementation could dispatch messages to service implementations concurrently, I don't know of any that do this.

Typically, a D-Bus implementation (or "binding", if you will) allows the service to decide for each method (or even for each method call) whether to respond to incoming method calls synchronously or asynchronously. The details of this are up to the particular implementation you're using.

If you're responding to method calls asynchronously, your service implementation is responsible for making sure that any state is kept consistent while multiple responses are pending. If you always respond synchronously, then you know you're only dealing with one method call at a time.

like image 141
daf Avatar answered Oct 18 '22 17:10

daf