From 3f37a12e2df8a89f26af766197f28e11a99a10ce Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Sun, 17 Sep 2017 14:43:40 +0200 Subject: [PATCH] timer connection: fix mixing of time sources We update the alarm-scheduler time with results of Timer::Connection::curr_time when we schedule new timeouts but when handling the signal from the Timer server we updated the alarm-scheduler time with the result of Timer::Connection::elapsed_us. Mixing times like this could cause a non-monotone time value in the alarm scheduler. The alarm scheduler then thought that the time value wrapped and triggered all timeouts immediately. The problem was fixed by always using Timer::Connection::curr_time as time source. Ref #2490 --- repos/os/src/lib/timeout/timeout.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/repos/os/src/lib/timeout/timeout.cc b/repos/os/src/lib/timeout/timeout.cc index 27739adee..f3a44a5e9 100644 --- a/repos/os/src/lib/timeout/timeout.cc +++ b/repos/os/src/lib/timeout/timeout.cc @@ -65,9 +65,11 @@ bool Timeout::Alarm::on_alarm(unsigned) ** Alarm_timeout_scheduler ** *****************************/ -void Alarm_timeout_scheduler::handle_timeout(Duration curr_time) +void Alarm_timeout_scheduler::handle_timeout(Duration) { - unsigned long const curr_time_us = curr_time.trunc_to_plain_us().value; + unsigned long const curr_time_us = + _time_source.curr_time().trunc_to_plain_us().value; + _alarm_scheduler.handle(curr_time_us); unsigned long sleep_time_us;