diff options
| author | Ralf Jung <post@ralfj.de> | 2020-05-05 09:08:00 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-05-05 09:08:00 +0200 |
| commit | f9866f95afad4ea97b975631c6016aa951fd4f83 (patch) | |
| tree | 7731f8889e88b18d38d33f35d3d71d6870c7591f | |
| parent | 3f50292edce92fb889bcd7318fead1a8905b6342 (diff) | |
| download | rust-f9866f95afad4ea97b975631c6016aa951fd4f83.tar.gz rust-f9866f95afad4ea97b975631c6016aa951fd4f83.zip | |
rely on rdlock/wrlock not returning anything but the specified error codes
| -rw-r--r-- | src/libstd/sys/unix/rwlock.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/rwlock.rs b/src/libstd/sys/unix/rwlock.rs index 3e3a01b4ea3..2b5067a34f6 100644 --- a/src/libstd/sys/unix/rwlock.rs +++ b/src/libstd/sys/unix/rwlock.rs @@ -46,7 +46,9 @@ impl RWLock { } panic!("rwlock read lock would result in deadlock"); } else { - assert_eq!(r, 0); + // According to POSIX, for a properly initialized rwlock this can only + // return EAGAIN or EDEADLK or 0. We rely on that. + debug_assert_eq!(r, 0); self.num_readers.fetch_add(1, Ordering::Relaxed); } } @@ -83,7 +85,9 @@ impl RWLock { } panic!("rwlock write lock would result in deadlock"); } else { - assert_eq!(r, 0); + // According to POSIX, for a properly initialized rwlock this can only + // return EDEADLK or 0. We rely on that. + debug_assert_eq!(r, 0); } *self.write_locked.get() = true; } |
