dbus fork problem

Havoc Pennington hp at redhat.com
Thu Apr 5 06:34:14 PDT 2007


Peter Clifton wrote:
> If you have a dbus connection (raw libdbus), and unref it to 0 ref
> counts, it DOES NOT finalise. This is a broken API IMHO, but this is the
> way dbus behaved for "shared" (default) bus connections, and some
> applications rely on the stupid ability to unref, then re-open the same
> connection!
> 

You aren't really explaining this properly. It is not possible to unref 
it to 0, would be more accurate, because libdbus owns one of the references.

> In short - once dbus is in your app, you can't get it to leave.

This is not quite the case; you can dbus_shutdown() if you truly know 
nobody is using libdbus anymore. (There may be or have been a bug where 
this did not disconnect the shared connections, I don't remember, but 
that would be considered a bug.)

That's the core issue, though. Do you know that nobody is using libdbus 
anymore? If you do then you can nuke the whole lib. If you don't, then 
part of the lib is those global shared connections, and someone might be 
using them.

The "connectedness" of the shared connection is global state, in other 
words. If you don't want global state and want complete control, just 
use a private connection instead, which creates more overhead but gives 
you a connection you can control as you see fit.

Havoc



More information about the dbus mailing list