thoenig at suse.de
Sun May 21 03:57:24 PDT 2006
(cc'ing Holger as we've recently discussed this; he is off-list.)
On Sat, 2006-05-20 at 21:49 -0400, Havoc Pennington wrote:
> I may be missing something since this seems like an obvious bug:
> dbus_bus_get() docs claim it returns a reference. However, you can't
> possibly call unref() because you can only call unref() on a connection
> if you either a) know it's been disconnected or b) know you don't have
> the only outstanding ref to it. For dbus_bus_get() these are more or
> less impossible right now.
> The obvious simple hello world prints warnings:
> connection = dbus_bus_get();
> /* do stuff */
> NetworkManager seems to have as a workaround only unref'ing on the
> disconnect message...
That was not meant to be a workaround.
That is how I got used to fix up applications suffering from not being
able to recover after D-BUS disconnects: First unref the dead
connection, only then dare to request a new. As I did not have a look
at the D-BUS side of things for this I expected this to be the intended
> Obviously I messed this up in the first place but it seems pretty lame
> to me now.
> I think the right fix is to leave dbus_bus_get() returning a ref, but
> have it also hold a strong ref internally instead of a weak ref. Then
> you can know it's safe to unref this connection since the
> internal-to-dbus strong ref is held until it's disconnected.
Agreed. If there was no requirement on having applications to call
dbus_connection_unref() this sounds definitely like a the way to fix
More information about the dbus