Signals & threads - low level C API [Newbie question]

Thiago Macieira thiago at
Fri Jan 26 00:51:29 PST 2007

Krishna R wrote:
>1. I thought i will create a thread using pthread_create and set my
>receiving filter func there and the main thread will continue to send.
> Is this ok?

Yes, but completely unrelated.

You can create threads in your program. And you can set a receiving filter 
function. libdbus has no control in which thread the filter function is 

It's up to you to run dbus_connection_dispatch (or any of the other 
dispatching functions) in the correct thread.

>2. If i do the above, when i send the signal, the send function seems to
>deadlock in dbus_connection_flush, or the call never returns (i assumed
> it was somekind of deadlock).

What function did you call in the processing thread? If you called 
dbus_connection_read_write, it'll block on the socket access. You need to 
release the transport to make other threads work.

In other words, you need a full mainloop in your thread: a select(2)-based 
socket notifier and timer implementation.

  Thiago Macieira  -  thiago (AT) - thiago (AT)
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url :

More information about the dbus mailing list