dbus_connection_read_write_dispatch sometimes causing 100% cpu usage

Burton Samograd burton at userful.com
Fri Sep 3 13:04:02 PDT 2010


Hello,

I've written a dbus application that uses
dbus_connection_read_write_dispatch in the following way:

while(1) {
    /* uid_log("Calling dbus_connection_read_write_dispatch..."); */
    if(dbus_connection_read_write_dispatch(uid_dbus.conn, 100) == FALSE) {
      uid_error("main: dbus connection has been disconnected; attempting to reconnect...");
      if(uid_dbus_init(&uid_dbus) != SUCCESS) {
        uid_error("main: could not reconnect to dbus; exiting");
        exit(1);
      }
    }
    dbus_connection_flush(uid_dbus.conn);
  }

Occasionally, the process will start eating 100% cpu time and I've
tracked it down to this loop.  I am passing a 100ms delay time which
normally works, but after some random event occurs, no longer causes the
call to block.

The call never seems to return FALSE, so the code in the if statement is
not getting called either.

I think the call to dbus_connection_flush is probably not needed, but I
don't think it's causing the problem I'm seeing.

Any idea why dbus_connection_read_write_dispatch would start not
blocking after some time?

--
Burton Samograd



More information about the dbus mailing list