]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: rework StopWhenUnneeded= logic
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Aug 2018 14:26:27 +0000 (16:26 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 10 Aug 2018 14:19:01 +0000 (16:19 +0200)
commita3c1168ac293f16d9343d248795bb4c246aaff4a
tree226c589269ae7337ca7c21d785dfb5936f2cd11c
parentb257b19e6ba05559c126356526a4b7e095afa39e
core: rework StopWhenUnneeded= logic

Previously, we'd act immediately on StopWhenUnneeded= when a unit state
changes. With this rework we'll maintain a queue instead: whenever
there's the chance that StopWhenUneeded= might have an effect we enqueue
the unit, and process it later when we have nothing better to do.

This should make the implementation a bit more reliable, as the unit notify event
cannot immediately enqueue tons of side-effect jobs that might
contradict each other, but we do so only in a strictly ordered fashion,
from the main event loop.

This slightly changes the check when to consider a unit "unneeded".
Previously, we'd assume that a unit in "deactivating" state could also
be cleaned up. With this new logic we'll only consider units unneeded
that are fully up and have no job queued. This means that whenever
there's something pending for a unit we won't clean it up.
src/core/manager.c
src/core/manager.h
src/core/unit.c
src/core/unit.h