Running dbus_connection_read_write_dispatch in a separate thread

Alexandru Sorodoc <[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <[email protected]>
Hello,

I'm trying to write a daemon that uses libdbus. I create a private 
connection, register a bus and an object path, and then start a thread 
that calls dbus_connection_read_write_dispatch(c, -1) in a loop (as 
described in the documentation).

All works fine, but when I want to shutdown the daemon I call 
dbus_connection_close from the main thread but 
dbus_connection_read_write_dispatch (running in the other thread) never 
returns unless it receives a dbus message.

Is this the expected behaviour? I did disable exiting on disconnect:

     dbus_connection_set_exit_on_disconnect(c, false)

But I expected that dbus_connection_close would close the underlying 
socket and would cause the read_write_dispatch call to return.

The documentation says:
 > The loop terminates when the last message from the connection (the 
disconnected signal) is processed.

But also:
 > Note that, while it is blocked on I/O, it cannot be interrupted (even 
by other threads)

It's not clear to me if dbus_connection_close triggers the "disconnected 
signal" and interrupts the blocking wait or if the "disconnected signal" 
is only checked once before entering the blocking wait.

Also, I did call dbus_threads_init_default before any other libdbus call.

Thanks,
Alex

_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.