Skip to content

Commit 11fbbc5

Browse files
authored
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`
2 parents 02ebca2 + d2120e6 commit 11fbbc5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/std/src/sys/pal/unix/sync/condvar.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ impl Condvar {
6464
// https://gist.github.com/stepancheg/198db4623a20aad2ad7cddb8fda4a63c
6565
//
6666
// To work around this issue, the timeout is clamped to 1000 years.
67-
#[cfg(target_vendor = "apple")]
67+
//
68+
// Cygwin implementation is based on NT API and a super large timeout
69+
// makes the syscall block forever.
70+
#[cfg(any(target_vendor = "apple", target_os = "cygwin"))]
6871
let dur = Duration::min(dur, Duration::from_secs(1000 * 365 * 86400));
6972

7073
let timeout = Timespec::now(Self::CLOCK).checked_add_duration(&dur);

0 commit comments

Comments
 (0)