Files
lix/misc/capnproto-monotonic-clocks-are-a-lie.patch
T
eldritch horrors a55fe35dac apply capnp patches again
This partially reverts commit f68233ec43.

while more modern capnp in *does* have the build system changes, it
does *not* have the patches. and those patches are rather important
to us; the clock patch because our CI machiens don't behave the way
capnp expect and the nodiscard patch because it *is* a bugsquasher.

Change-Id: Ic273777f09fd8e5e7001f815db8998dae2dd7b88
2025-10-17 19:21:17 +00:00

48 lines
1.7 KiB
Diff

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