Skip to content

Commit

Permalink
rely on rdlock/wrlock not returning anything but the specified error …
Browse files Browse the repository at this point in the history
…codes
  • Loading branch information
RalfJung committed May 5, 2020
1 parent 3f50292 commit f9866f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libstd/sys/unix/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f9866f9

Please sign in to comment.