about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-25 00:54:00 +0200
committerGitHub <noreply@github.com>2025-04-25 00:54:00 +0200
commit11fbbc54ba443f0edafdd1c34de7c069f7a325bf (patch)
treedd14c69c4f83835f55d5ebd94e50c7a078048cb8
parent02ebca2784329d8712dfa7164545042c73e073e9 (diff)
parentd2120e653e9acca9ab6f3053d0a173fa285fba04 (diff)
downloadrust-11fbbc54ba443f0edafdd1c34de7c069f7a325bf.tar.gz
rust-11fbbc54ba443f0edafdd1c34de7c069f7a325bf.zip
Rollup merge of #140210 - Berrysoft:cygwin-timedwait, r=joboet
Work around cygwin issue on condvar timeout

This workaround *just works*... Actually I don't quite understand why does it work in such way. With a simple test on Cygwin, it seems that the maximum value of `tv_sec` could be 12899331056917, while the maximum value of `tv_nsec` should be a value floating around 464600000. A larger `timespec` could block the syscall forever.

r? `@joboet`
-rw-r--r--library/std/src/sys/pal/unix/sync/condvar.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/unix/sync/condvar.rs b/library/std/src/sys/pal/unix/sync/condvar.rs
index 73631053e9f..efa6f8d7765 100644
--- a/library/std/src/sys/pal/unix/sync/condvar.rs
+++ b/library/std/src/sys/pal/unix/sync/condvar.rs
@@ -64,7 +64,10 @@ impl Condvar {
         // https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c
         //
         // To work around this issue, the timeout is clamped to 1000 years.
-        #[cfg(target_vendor = "apple")]
+        //
+        // Cygwin implementation is based on NT API and a super large timeout
+        // makes the syscall block forever.
+        #[cfg(any(target_vendor = "apple", target_os = "cygwin"))]
         let dur = Duration::min(dur, Duration::from_secs(1000 * 365 * 86400));
 
         let timeout = Timespec::now(Self::CLOCK).checked_add_duration(&dur);