[systemd-devel] dbus API for unit state change?

Lennart Poettering lennart at poettering.net
Sun Oct 6 15:10:06 PDT 2013


On Fri, 04.10.13 17:19, Brandon Philips (brandon at ifup.co) wrote:

> 
> Another dbus question:
> 
> Is it expected that a UnitNew and UnitRemove are sent when I use
> org.freedesktop.DBus.Properties.Get or GetAll? This also happens with
> `systemctl status doesnt-exist.service`

Yupp it kinda is.

The logic behing this is that systemd minimizes the unit file
descriptions it has loaded into memory. Basically, unit files are
unloaded if they are not active and if no other unit that is loaded
references them. Each time something is loaded or unloaded you get a
UnitNew or UnitRemoved signal, to keep you updated what is currently in
memory. Any unit request will implicitly load the units referenced by
it, in order to make this scheme race-free for the client.

> Here is an example of what I am seeing:
> https://gist.github.com/philips/6834913/raw/5bd36998829ca44c25c3798afd3c77c147b1ba27/gistfile1.txt
> 
> This isn't very nice because I need to explicitly guard against
> getting into an infinite loop of looking up properties on non-existent
> units.

So, yeah, if you respond to each UnitNew signal you get with a property
Get/GetAll call, then this will result in endless ping pong, which is
certainly not a good idea.

What are you trying to do? Write some tool that tracks all units that
are loaded?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list