]> git.ipfire.org Git - thirdparty/systemd.git/commit
timer: make sure we use the right monotonic timestamp
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Jun 2017 19:04:20 +0000 (21:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 22 Jun 2017 19:04:20 +0000 (21:04 +0200)
commitc54be90b28cc25663ff52c505956fa3de0bea1fb
tree91bef508dfd8a78137dcf87ba6028ad1a15ede0e
parent79fc8b9623354a98ca81b4d35e576e9c9e3bf687
timer: make sure we use the right monotonic timestamp

This reworks timer_enter_waiting() in a couple of ways in order to clean
it up a bit and fix #5629.

Most importantly, we previously we initialized ts_monotonic to either
the current time in CLOCK_MONOTONIC or in CLOCK_BOOTTIME, depending on
t->wake_system. Then given specific conditions we'd use this time as
base for our timers. And afterwards, if t->wake_system was on we'd
convetr the resulting value from CLOCK_MONOTONIC to CLOCK_BOOTTIME again
— which of course is wrong since we already were in CLOCK_BOOTTIME! This
fixes this logic, by using a triple timestamp so that we always have the
right base around, and initially only calculate in CLOCK_MONOTONIC and
only convert as last step.

Conversion between the clocks is now done with the generic
usec_shift_clock(), and additions via usec_add() making these
calculations a bit safer.

Fixes: #5629
src/core/timer.c