Crash when using HAL in multiple libraries
William Jon McCann
mccann at jhu.edu
Wed Jun 7 09:41:37 PDT 2006
David Zeuthen wrote:
> 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().
OK, in that case then libhal_ctx_set_dbus_connection should probably ref
the connection and then unref in libhal_ctx_shutdown, right? That
should handle both private and shared connections correctly.
Jon
More information about the hal
mailing list