diff options
Diffstat (limited to 'library/std/src/sys/unix/locks')
| -rw-r--r-- | library/std/src/sys/unix/locks/futex_rwlock.rs | 13 | ||||
| -rw-r--r-- | library/std/src/sys/unix/locks/mod.rs | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/locks/futex_rwlock.rs b/library/std/src/sys/unix/locks/futex_rwlock.rs index e42edb25858..8829ed4db25 100644 --- a/library/std/src/sys/unix/locks/futex_rwlock.rs +++ b/library/std/src/sys/unix/locks/futex_rwlock.rs @@ -283,7 +283,18 @@ impl RwLock { /// writer that was about to go to sleep. fn wake_writer(&self) -> bool { self.writer_notify.fetch_add(1, Release); - futex_wake(&self.writer_notify) + cfg_if::cfg_if! { + if #[cfg(target_os = "dragonfly")] { + // DragonFlyBSD doesn't tell us whether it woke up any threads or not. + // So, we always return `false` here, as that still results in correct behaviour. + // The downside is an extra syscall in case both readers and writers were waiting, + // and unnecessarily waking up readers when a writer is about to attempt to lock the lock. + futex_wake(&self.writer_notify); + false + } else { + futex_wake(&self.writer_notify) + } + } } /// Spin for a while, but stop directly at the given condition. diff --git a/library/std/src/sys/unix/locks/mod.rs b/library/std/src/sys/unix/locks/mod.rs index 61fc0d5841d..d39da200dda 100644 --- a/library/std/src/sys/unix/locks/mod.rs +++ b/library/std/src/sys/unix/locks/mod.rs @@ -5,6 +5,7 @@ cfg_if::cfg_if! { all(target_os = "emscripten", target_feature = "atomics"), target_os = "openbsd", target_os = "netbsd", + target_os = "dragonfly", ))] { mod futex; mod futex_rwlock; |
