Systemd/src/core
Michal Koutný 204d140c4d core/timer: Prevent timer looping when unit cannot start
When a unit job finishes early (e.g. when fork(2) fails) triggered unit goes
through states
        stopped->failed (or failed->failed),
in case a ExecStart= command fails unit passes through
        stopped->starting->failed.

The former transition doesn't result in unit active/inactive timestamp being
updated and timer (OnUnitActiveSec= or OnUnitInactiveSec=) would use an expired
timestamp triggering immediately again (repeatedly).

This patch exploits timer's last trigger timestamp to ensure the timer isn't
triggered more frequently than OnUnitActiveSec=/OnUnitInactiveSec= period.

Steps to reproduce:

0) Create sample units:

cat >~/.config/systemd/user/looper.service <<EOD
[Service]
ExecStart=/usr/bin/sleep 2
EOD

cat >~/.config/systemd/user/looper.timer <<EOD
[Timer]
AccuracySec=5
OnUnitActiveSec=5
EOD

1) systemctl --user daemon-reload

2) systemctl --user start looper.timer
   # to have first activation timestamp/sentinel
   systemctl --user start looper.service

o  Observe the service is being regularly triggered.

3) systemctl set-property user@$UID.service TasksMax=2

o  Observe the tight looping as long as the looper.service cannot be started.

Ref: #5969
2018-01-22 17:13:00 +01:00
..
audit-fd.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
audit-fd.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
automount.c tree-wide: make use of new STRLEN() macro everywhere (#7639) 2017-12-14 19:02:29 +01:00
automount.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
bpf-firewall.c bpf-firewall: actually invoke BPF_PROG_ATTACH to check whether cgroup/bpf is available 2017-11-29 20:15:23 +01:00
bpf-firewall.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
cgroup.c core: un-break PrivateDevices= by allowing it to mknod /dev/ptmx 2018-01-18 12:10:20 +00:00
cgroup.h core: warn about left-over processes in cgroup on unit start 2017-11-25 17:08:21 +01:00
chown-recursive.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
chown-recursive.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-automount.c dbus-automount: support more options in transient automount unit 2018-01-02 02:23:30 +09:00
dbus-automount.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-cgroup.c dbus-cgroup: simplify bus_cgroup_set_property() 2018-01-03 02:33:16 +09:00
dbus-cgroup.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-device.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-device.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-execute.c dbus-execute: define bus_set_transient_errno() only if HAVE_SECCOMP (#7869) 2018-01-13 08:48:53 +09:00
dbus-execute.h core: rename bus_exec_command_set_transient_property() to bus_set_transient_exec_command() 2018-01-02 02:23:56 +09:00
dbus-job.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-job.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-kill.c dbus-kill: simplify bus_kill_context_set_transient_property() 2018-01-02 02:23:36 +09:00
dbus-kill.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-manager.c core: rename dbus property StartLimitIntervalSec= to StartLimitIntervalUSec= 2018-01-02 02:23:49 +09:00
dbus-manager.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-mount.c dbus-mount: support more options in transient mount unit 2018-01-02 02:23:32 +09:00
dbus-mount.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-path.c dbus-path: add Paths= option to set path specs in transient path unit 2018-01-03 02:32:30 +09:00
dbus-path.h core/path: implement transient path unit 2017-12-15 09:10:34 +09:00
dbus-scope.c dbus-scope: simplify bus_scope_set_transient_property() 2018-01-02 02:23:38 +09:00
dbus-scope.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-service.c dbus-service: expose *ExitStatus= settings on bus 2018-01-03 02:32:10 +09:00
dbus-service.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-slice.c core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-slice.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-socket.c dbus-socket: simplify bus_socket_set_transient_property() 2018-01-02 02:25:04 +09:00
dbus-socket.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-swap.c core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-swap.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-target.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-target.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dbus-timer.c core: double free in bus_timer_set_transient_property 2018-01-04 11:31:37 +01:00
dbus-timer.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-unit.c dbus-unit: support more options in transient units 2018-01-02 02:23:52 +09:00
dbus-unit.h core: add proper escaping to writing of drop-ins/transient unit files 2017-11-29 12:34:12 +01:00
dbus-util.c dbus-util: properly parse timeout values 2018-01-11 15:12:16 +01:00
dbus-util.h dbus-cgroup: simplify bus_cgroup_set_property() 2018-01-03 02:33:16 +09:00
dbus.c Merge pull request #7855 from poettering/log-h-includes 2018-01-15 13:43:09 +04:00
dbus.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
device.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
device.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
dynamic-user.c tree-wide: make use of new STRLEN() macro everywhere (#7639) 2017-12-14 19:02:29 +01:00
dynamic-user.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
emergency-action.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
emergency-action.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
execute.c Merge pull request #7763 from yuwata/fix-7761 2018-01-05 12:38:29 +01:00
execute.h Merge pull request #7198 from poettering/stdin-stdout 2017-11-19 19:49:11 +01:00
hostname-setup.c hostname-util: rework read_hostname_config() a bit 2017-11-20 16:43:15 +01:00
hostname-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
ima-setup.c tree-wide: make use of new STRLEN() macro everywhere (#7639) 2017-12-14 19:02:29 +01:00
ima-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
ip-address-access.c ip-address-access: let's exit the loop after invalidating our entry a (#7803) 2018-01-04 13:24:40 +01:00
ip-address-access.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
job.c cocci: use strempty() at more places 2018-01-10 17:11:19 +01:00
job.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
kill.c cocci: use strempty() at more places 2018-01-10 17:11:19 +01:00
kill.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
killall.c shutdown: make kill timeout configurable (#7835) 2018-01-10 19:00:20 +01:00
killall.h shutdown: make kill timeout configurable (#7835) 2018-01-10 19:00:20 +01:00
kmod-setup.c Fix build without libkmod 2017-11-24 13:54:20 +01:00
kmod-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
load-dropin.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
load-dropin.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
load-fragment-gperf-nulstr.awk build-sys: fix the script used for generating load_fragment_gperf_nulstr (#6646) 2017-08-26 23:21:23 +09:00
load-fragment-gperf.gperf.m4 load-fragment: obsolete OnFailureIsolate= 2018-01-02 02:23:17 +09:00
load-fragment.c socket-util: introduce parse_socket_address_bind_ipv6_only_or_bool() 2018-01-02 02:23:21 +09:00
load-fragment.h Merge pull request #7198 from poettering/stdin-stdout 2017-11-19 19:49:11 +01:00
locale-setup.c log: minimize includes in log.h 2018-01-11 14:44:31 +01:00
locale-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
loopback-setup.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
loopback-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
machine-id-setup.c machine-id-setup: use return log_error… pattern 2017-12-19 15:20:38 +01:00
machine-id-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
macros.systemd.in Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
main.c core: delay logging the taint string until after basic.target is reached (#7935) 2018-01-21 21:17:54 +09:00
manager.c core: delay logging the taint string until after basic.target is reached (#7935) 2018-01-21 21:17:54 +09:00
manager.h core: delay logging the taint string until after basic.target is reached (#7935) 2018-01-21 21:17:54 +09:00
meson.build core: add dbus-util.[ch] to simplify creating transient units 2018-01-02 02:22:36 +09:00
mount-setup.c mount-setup: fix MNT_CHECK_WRITABLE error handling, and log about the issue 2017-12-15 20:52:28 +01:00
mount-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
mount.c core: prevent spurious retries of umount 2018-01-13 17:22:46 +00:00
mount.h core: unify common code for preparing for forking off unit processes 2017-11-21 11:54:08 +01:00
namespace.c Merge pull request #7913 from sourcejedi/devpts 2018-01-18 21:56:26 +00:00
namespace.h namespace: introduce parse_protect_system()_or_bool 2018-01-02 02:23:13 +09:00
org.freedesktop.systemd1.conf Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
org.freedesktop.systemd1.policy.in.in Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
org.freedesktop.systemd1.service Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
path.c core/path: implement transient path unit 2017-12-15 09:10:34 +09:00
path.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
scope.c core: generalize the cgroup empty check on GC 2017-11-25 17:08:21 +01:00
scope.h core: track scope controllers on the bus 2017-11-23 21:47:48 +01:00
selinux-access.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
selinux-access.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
selinux-setup.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
selinux-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
service.c Merge pull request #7816 from poettering/chase-pid 2018-01-15 14:14:34 +04:00
service.h service: Don't stop unneeded units needed by restarted service (#7526) 2017-12-05 16:51:19 +01:00
show-status.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
show-status.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
shutdown.c Merge pull request #7846 from poettering/nobody-getenv 2018-01-10 20:18:51 +01:00
slice.c core: reuse slice_build_parent_slice 2017-12-15 14:57:07 +01:00
slice.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
smack-setup.c tree-wide: use __fsetlocking() instead of fxyz_unlocked() 2017-12-14 10:42:25 +01:00
smack-setup.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
socket.c tree-wide: unify the process name we pass to wait_for_terminate_and_check() with the one we pass to safe_fork() 2018-01-04 13:27:27 +01:00
socket.h core/socket: add socket_port_type_from_string() 2017-12-23 18:46:16 +09:00
swap.c core: warn about left-over processes in cgroup on unit start 2017-11-25 17:08:21 +01:00
swap.h core: unify common code for preparing for forking off unit processes 2017-11-21 11:54:08 +01:00
system.conf manager: hook up IP accounting defaults 2017-09-22 15:24:55 +02:00
systemd.pc.in build-sys: make the dynamic UID range, and the container UID range configurable 2017-12-06 12:55:37 +01:00
target.c Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
target.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
timer.c core/timer: Prevent timer looping when unit cannot start 2018-01-22 17:13:00 +01:00
timer.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
transaction.c Replace free and return NULL with return mfree 2017-11-24 10:31:49 +00:00
transaction.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
triggers.systemd.in Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
umount.c log: minimize includes in log.h 2018-01-11 14:44:31 +01:00
umount.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
unit-printf.c specifier: unify specifier implementations for user-related specifiers 2017-11-29 12:32:56 +01:00
unit-printf.h Add SPDX license identifiers to source files under the LGPL 2017-11-19 19:08:15 +01:00
unit.c tree-wide: install matches asynchronously 2018-01-05 13:58:32 +01:00
unit.h core: be stricter when handling PID files and MAINPID sd_notify() messages 2018-01-11 15:12:16 +01:00
user.conf core: rename StartLimitInterval= to StartLimitIntervalSec= 2016-04-29 16:27:48 +02:00