misc/capnproto: patch to avoid monotonic time checks
From time to time, our KVM's CI machine clock goes in a weird direction during NixOS tests, this is known on certain hardware, e.g. macOS, where the check is disabled. Cap'n'Proto removed the check everywhere now. Fixes fj#754. We can remove the patch once it hits a stable version of Cap'n'Proto. Change-Id: I4c9be5061c3b244f601486a8ac4521dff44ceb92 Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
committed by
eldritch horrors
parent
294c55026c
commit
3f3060ebed
@@ -0,0 +1,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 running an Intel processor, 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 on these machines.
|
||||
- // See also https://github.com/capnproto/capnproto/issues/1693
|
||||
-#if __APPLE__ && defined(__x86_64__)
|
||||
+ // 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
|
||||
|
||||
@@ -38,6 +38,8 @@ stdenv.mkDerivation rec {
|
||||
patches = [
|
||||
# backport of https://github.com/capnproto/capnproto/pull/1810
|
||||
./capnproto-promise-nodiscard.patch
|
||||
# backport of https://github.com/capnproto/capnproto/pull/2296
|
||||
./capnproto-monotonic-clocks-are-a-lie.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
+5
-1
@@ -51,6 +51,7 @@ pre-commit-run {
|
||||
excludes = [
|
||||
"\\.drv$"
|
||||
"^tests/functional/lang/"
|
||||
''\.patch$''
|
||||
];
|
||||
};
|
||||
mixed-line-endings = {
|
||||
@@ -107,7 +108,10 @@ pre-commit-run {
|
||||
trim-trailing-whitespace = {
|
||||
enable = true;
|
||||
stages = [ "pre-commit" ];
|
||||
excludes = [ "^tests/functional/lang/" ];
|
||||
excludes = [
|
||||
''^tests/functional/lang/''
|
||||
''\.patch$''
|
||||
];
|
||||
};
|
||||
treefmt = {
|
||||
enable = true;
|
||||
|
||||
Reference in New Issue
Block a user