C-API

Havoc Pennington hp at redhat.com
Thu Oct 12 17:34:56 PDT 2006


Thiago Macieira wrote:
> Havoc Pennington wrote:
>> Thiago Macieira wrote:
>>> The thread solution doesn't really work. We've talking about that on
>>> IRC and code inspection revealed that any blocking sends performed in
>>> other threads will not work -- the transport is locked.
>> To be clear, this is a bug, not by design...
> 
> I wouldn't classify it as a bug. dbus_connection_read_write_dispatch can 
> block.
> 
> When it blocks, it blocks. It can't be woken up by other threads. If it 
> could, then libdbus-1 would have to work out which thread would get 
> access to messages first. What would happen if the wrong thread popped 
> and processed the reply that another thread was waiting for?
> 
> No, it's too complex a solution for libdbus-1 when a simple mainloop 
> implementation (even in a thread) is enough to solve the problem.
> 

With two read_write_dispatch I guess I agree. I think it should work 
though if you block on a DBusPendingCall from another thread and then 
dispatch (via read_write_dispatch or main loop) from the main thread. So 
send_with_reply_and_block should also work.

There's code in dbus-connection.c that is supposed to give pending calls 
first shot at their replies (i.e. the intended answer to the question 
"which thread gets it" is "the pending call object always gets it")

Havoc


More information about the dbus mailing list