about summary refs log tree commit diff
path: root/library/std/src/sys/unix/locks/futex_rwlock.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/unix/locks/futex_rwlock.rs')
-rw-r--r--library/std/src/sys/unix/locks/futex_rwlock.rs13
1 files changed, 12 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.