Crash when using HAL in multiple libraries
David Zeuthen
david at fubar.dk
Wed Jun 7 09:33:47 PDT 2006
On Wed, 2006-06-07 at 10:39 -0400, William Jon McCann wrote:
> > You might want to try to use dbus_bus_get_private() instead of
> > dbus_bus_get() in your libraries. Notwithstanding, this should work so
> > it may be a bug in libhal or libdbus (more likely it's libhal). But it
> > would be interesting to see if using _private() makes a difference.
>
> Nice, I didn't know about dbus_bus_get_private.
It was added some time ago, wasn't always there.
> Just to clarify... In
> this case, unlike dbus_bus_get, the caller owns the reference to the
> connection. Should this ownership transfer to libhal when
> libhal_ctx_set_dbus_connection is used? In other words who should be
> responsible for unreffing it?
The caller is responsible for unreffing it because otherwise it wouldn't
work in a process that loads libraries / plugins where the library /
plugin uses libhal. Plus DBusConnection objects from dbus_bus_get are
shared between all callers of that function.
Btw, IIRC the default behavior of libdbus is to call exit(1) on
disconnects unless you call dbus_connection_set_exit_connect(connection,
FALSE). So you never really want to unref connections obtained through
dbus_bus_get().
Cheers,
David
More information about the hal
mailing list