Low-level API: dbus_bus_get() + dbus_connection_set_exit_on_disconnect() in a library

Michał Górny mgorny at gentoo.org
Tue Aug 16 10:48:01 PDT 2011


On Tue, 16 Aug 2011 16:52:09 +0100
Simon McVittie <simon.mcvittie-ZGY8ohtN/8pPYcu2f3hruQ at public.gmane.org>
wrote:

> On Tue, 16 Aug 2011 at 17:10:39 +0200, Michał Górny wrote:
> > The case I'm considering is that some application is using
> > dbus_bus_get() internally and wants D-Bus to exit on disconnect. If
> > my library gets the same connection using dbus_bus_get(), will
> > calling dbus_connection_set_exit_on_disconnect(..., FALSE) override
> > that application's preference?
> 
> Yes. You can safely call it on a connection returned by
> dbus_bus_get_private(), but that has the cost that if something else
> in your application has connected to the same bus, you're running two
> parallel connections (wasting memory).

That's what I was afraid I'd have to use.

> Are you connecting to the system bus or the session bus?

The session bus.

> (One way this could be fixed in a hypothetical D-Bus 2.0 would be for
> dbus2_bus_get() to take an explicit boolean exit_on_close parameter -
> the application would exit-on-close if at least one of the calls to
> dbus_bus_get() had requested exit-on-close behaviour.)

Or just switch the default to FALSE.

And please don't drop CCs from mails. Getting message-IDs for reply via
GMane is really time-consuming.

-- 
Best regards,
Michał Górny
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 316 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20110816/68cbc9ed/attachment.pgp>


More information about the dbus mailing list