We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
pthread_mutex_lock
1 parent 366d112 commit 5fae61eCopy full SHA for 5fae61e
library/std/src/sys/pal/unix/locks/pthread_mutex.rs
@@ -1,4 +1,5 @@
1
use crate::cell::UnsafeCell;
2
+use crate::io::Error;
3
use crate::mem::{forget, MaybeUninit};
4
use crate::sys::cvt_nz;
5
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
@@ -103,8 +104,17 @@ impl Mutex {
103
104
105
#[inline]
106
pub unsafe fn lock(&self) {
107
+ #[cold]
108
+ #[inline(never)]
109
+ fn fail() -> ! {
110
+ let error = Error::last_os_error();
111
+ panic!("failed to lock mutex: {error}");
112
+ }
113
+
114
let r = libc::pthread_mutex_lock(raw(self));
- debug_assert_eq!(r, 0);
115
+ if r != 0 {
116
+ fail()
117
118
}
119
120
0 commit comments