From: Michal Koutný Date: Tue, 16 Jan 2018 18:22:46 +0000 (+0100) Subject: core/timer: Prevent timer looping when unit cannot start X-Git-Tag: v237~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=204d140c4def364c47d36226e4514a7e077fa196;p=thirdparty%2Fsystemd.git 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 <~/.config/systemd/user/looper.timer <last_trigger.monotonic); break; @@ -443,6 +444,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { if (base <= 0) continue; + base = MAX(base, t->last_trigger.monotonic); break;