dbus_connection_read_write_dispatch sometimes causing 100% cpu usage

Havoc Pennington hp at pobox.com
Fri Sep 10 12:32:59 PDT 2010


On Fri, Sep 10, 2010 at 2:56 PM, Burton Samograd <burton at userful.com> wrote:
> For the first part, I am having trouble finding how this code will ever
> exit the loop, since connection->dispatch_acquired is never set
> anywhere.  This seems like a standard infinite loop, but maybe someone
> could shed some light on how this is supposed to exit.

dispatch_acquired does get set, see
_dbus_connection_acquire_dispatch() and

> but since thread_functions.condvar_wait is 0, the code is never executed
> (since I don't call dbus_init_threads (or whatever that function is
> called) in my code since it is single threaded)...

This makes me suspect you're recursing and re-entering dispatch
(trying to _dbus_connection_acquire_dispatch() twice without releasing

> Here is a stack trace from where I am in the loop:
> #0  _dbus_connection_acquire_dispatch (connection=0x1053c00) at dbus-connection.c:3864
> #1  0x00007f96c57726bb in dbus_connection_dispatch (connection=0x1053c00) at dbus-connection.c:4303
> #2  0x00007f96c5770654 in _dbus_connection_read_write_dispatch (connection=0x1053c00,
>    timeout_milliseconds=100, dispatch=1) at dbus-connection.c:3431
> #3  0x00007f96c5770a22 in dbus_connection_read_write_dispatch (connection=0x1053c00,
>    timeout_milliseconds=100) at dbus-connection.c:3513

It looks like you somehow have read_write_dispatch from inside
read_write_dispatch, and the inner read_write_dispatch is waiting for
the outer one to give up dispatch_acquired (i.e.


More information about the dbus mailing list