1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00
systemd/test/test-path
Michael Chapman 708961c701 core/path: recheck path specs when triggered unit changes state
As documented in systemd.path(5):

    When a service unit triggered by a path unit terminates (regardless
    whether it exited successfully or failed), monitored paths are
    checked immediately again, and the service accordingly restarted
    instantly.

This commit implements this behaviour for PathExists=, PathExistsGlob=,
and DirectoryNotEmpty=. These predicates are essentially
"level-triggered": the service should be activated whenever the
predicate is true. PathChanged= and PathModified=, on the other hand,
are "edge-triggered": the service should only be activated when the
predicate *becomes* true.

The behaviour has been broken since at least as far back as commit
8fca6944c2 ("path: stop watching path specs once we triggered the target
unit"). This commit had systemd stop monitoring inotify whenever the
triggered unit was activated. Unfortunately this meant it never updated
the ->inotify_triggered flag, so it never rechecked the path specs when
the triggered unit deactivated.

With this commit, systemd rechecks all paths specs whenever the
triggered unit deactivates. If any PathExists=, PathExistsGlob= or
DirectoryNotEmpty= predicate passes, the triggered unit is reactivated.

If the target unit is activated by something outside of the path unit,
the path unit immediately transitions to a running state. This ensures
the path unit stops monitoring inotify in this situation.

With this change in place, commit d7cf8c24d4 ("core/path: fix spurious
triggering of PathExists= on restart/reload") is no longer necessary.
The path unit (and its triggered unit) is now always active whenever
the PathExists= predicate passes, so there is no spurious restart when
systemd is reloaded or restarted.
2020-05-05 13:56:02 +10:00
..
basic.target test: replace symlinks with actual unit files 2020-03-22 10:22:42 +01:00
path-changed.path
path-changed.service core/path: recheck path specs when triggered unit changes state 2020-05-05 13:56:02 +10:00
path-directorynotempty.path
path-directorynotempty.service core/path: recheck path specs when triggered unit changes state 2020-05-05 13:56:02 +10:00
path-exists.path
path-exists.service core/path: recheck path specs when triggered unit changes state 2020-05-05 13:56:02 +10:00
path-existsglob.path
path-existsglob.service core/path: recheck path specs when triggered unit changes state 2020-05-05 13:56:02 +10:00
path-makedirectory.path
path-makedirectory.service core/path: recheck path specs when triggered unit changes state 2020-05-05 13:56:02 +10:00
path-modified.path
path-modified.service core/path: recheck path specs when triggered unit changes state 2020-05-05 13:56:02 +10:00
path-mycustomunit.service core/path: recheck path specs when triggered unit changes state 2020-05-05 13:56:02 +10:00
path-service.service
path-unit.path
paths.target test: replace symlinks with actual unit files 2020-03-22 10:22:42 +01:00
sysinit.target test: replace symlinks with actual unit files 2020-03-22 10:22:42 +01:00