1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
From 11375442cf591f055ca95902f27c68b0e983d371 Mon Sep 17 00:00:00 2001
From: Fabio Rossetto <fabio.rossetto@zhinst.com>
Date: Thu, 8 May 2025 18:18:10 +0200
Subject: [PATCH] Remove check for monotonic time
The check was disabled on Mac, but in #2261 it was reported also on
Linux. At this point, it makes more sense to remove the KJ_REQUIRE for
monotonicity alltogether.
Backport of the original PR #2296 to v1.0.2.
Signed-off-by: Raito Bezarius <raito@lix.systems>
Co-authored-by: Raito Bezarius <raito@lix.systems>
---
c++/src/kj/timer.c++ | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/c++/src/kj/timer.c++ b/c++/src/kj/timer.c++
index e5cd2648..a659e5d0 100644
--- a/c++/src/kj/timer.c++
+++ b/c++/src/kj/timer.c++
@@ -110,16 +110,13 @@ Maybe<uint64_t> TimerImpl::timeoutToNextEvent(TimePoint start, Duration unit, ui
}
void TimerImpl::advanceTo(TimePoint newTime) {
- // On Macs, it has been observed that clock_gettime
- // may return non monotonic time, even when CLOCK_MONOTONIC is used.
- // This workaround is to avoid the assert triggering if this happens.
- // See also https://github.com/capnproto/capnproto/issues/1693
-#if __APPLE__
+ // It has been observed that clock_gettime may return non monotonic time,
+ // even when CLOCK_MONOTONIC is used.
+ // We use std::max to guard against this rare issue.
+ // - on Mac: https://github.com/capnproto/capnproto/issues/1693
+ // - on Linux: https://github.com/capnproto/capnproto/issues/2261
+
time = std::max(time, newTime);
-#else
- KJ_REQUIRE(newTime >= time, "can't advance backwards in time") { return; }
- time = newTime;
-#endif
for (;;) {
auto front = impl->timers.begin();
--
2.49.0
|