libdbus - simple mainloop?

Thomas Themel thomas at themel.com
Wed Jun 16 02:23:56 PDT 2010


Hi,

I'm currently writing dbus bindings for a library that needs to have minimal
dependencies and so am stuck with libdbus. Not a problem for the calls
themselves since they are rather simple, but I seem to misunderstand how to use
DBus with threads. I thought I'd make a separate thread to drive DBus, just 
looping over dbus_connection_read_write_dispatch(conn, -1) there.

While this does what I want when responding to method calls, I can't figure out
how to properly emit signals in this setup.  I can dbus_connection_send() the
message okay, but it doesn't actually show up on the bus until the next incoming message (eg a method call) arrives in my application.

I tried calling dbus_connection_flush() after the send, but that hangs,
probably because the main loop in another thread is holding the lock on the
connection.

Is it supposed to be this way? Is there a way to keep the simple blocking main
loop while still emitting signals at arbitrary times?

thanks,
-- 
[*Thomas  Themel*] Tim has been implying that I am a pinko, gold nut, and
[extended contact] randroid, which sort of hints that Ayn Rand is too pink
[info provided in] for him.
[*message header*]          - James A. Donald about Tim May on cypherpunks


More information about the dbus mailing list