[Patch] Auto-Close dbus-daemon when unused

Leon Winter winter-dbus at bfw-online.de
Tue Sep 29 06:51:15 PDT 2015


Hi,

> Stop using autolaunch and start D-Bus at the beginning of your X11 session, 
> like everyone else. It will exit when the X11 session exits.

our requirements are unlike those of "everyone else" especially normal desktop
users who are probably powering off the computer after every session.

> autolaunch was created for running D-Bus applications in legacy environments 
> that did not start X. We're in 2015, 10 years after D-Bus was created. Please 
> don't give yourself the tag "legacy environment".

I suppose you would consider a SSH shell also "legacy" when X forwarding is not
enabled. Also you are suggesting that memory constraint systems are "legacy" but
in different scenarios like embedded systems one want to keep the system as
small as possible with least memory footprint.
Running D-Bus daemons for a whole session when the user never requires it, *is*
a waste of resources.
But again I know our requirements differ from the majority of users and it is
perfectly fine for you to say D-Bus is designed for the average desktop user.

> I don't want the autoexit feature for two reasons: first, there may be races 
> associated with exiting the daemon, as you can't be sure that a process did 
> not obtain the socket path before the X11 window was closed.

Assuming the daemon clears the X11 atom indicating the socket (and any other
indications of its presence) and afterwards closing the socket, I assume you
refer to the time in between where a client obtains the address of the socket
but "waits" before finally connecting. At the time the connect happens, the
socket would already be closed.
You are right that running D-Bus alongside X11 gives every application a strong
assurance of its availability. Should an application fetch the socket address
and wait "too long" it also be "informed" about the absence of D-Bus via the
indication of X11 quitting.
In theory the race can only be handled in the client which would need to retry
the two-phase D-Bus connect (of looking up the address and connecting) since any
client could in theory wait very long after the lookup and before the actual
connection attempt. If the daemon therefore experiences a "time-out"/inactivity
it would simply shut down by removing indication to the socket and then the
socket itself. The clients/dbus-launch in turn would try to lookup the address
and connect to the socket. Should it fail on the way, it could wait a little and
do the process once again. If no socket indicator is present, dbus-launch would
of course autolaunch a new dbus-daemon.

> And second, use of D-Bus is very common in modern Linux desktop applications,
> so it's not really wasting resources.

If all the applications require D-Bus also the auto-exit enabled dbus-daemon
would not quit but stay. It only terminates when it is not in use any more.
Whether this is actually the case depends on ones setup. To some extend one can
configure/build also modern desktop applications with D-Bus disabled.

Regards,
Leon


More information about the dbus mailing list