Race condition when using dbus_connection_send() from multiple threads sharing the same connection

Avery Pennarun apenwarr at gmail.com
Thu Sep 17 11:00:42 PDT 2009


[Disclaimer: I haven't actually looked at how the dbus send queue code works]

> As a result, the message is in the outgoing queue,
> but is essentially stuck and won't be sent until the next call to
> dbus_connection_send().

Since dbus_connection_send() is supposed to be asynchronous, and
socket buffers aren't infinite, there must *always* be a possibility
that the data won't go out right away.  In most applications I've
seen, some other part of the program is doing select() on the socket
and will write the output queue to the socket when select() returns
true.

If you don't select() on your socket on a regular basis, you shouldn't
expect dbus to work properly.  This has something to do with the
DBusWatch functions, I think.  If you're using the dbus-glib bindings,
this probably happens automatically for you.

Anyway, I don't think the right place to fix this is at
dbus_connection_send() time; it sounds like your application doesn't
have its mainloop setup correctly.

Avery


More information about the dbus mailing list