@@ -42,9 +42,9 @@ use crate::sync::atomic::{
42
42
Ordering :: { Acquire , Relaxed , Release } ,
43
43
} ;
44
44
use crate :: sys:: futex:: zircon:: {
45
- zx_futex_wait, zx_futex_wake_single_owner, zx_handle_t, zx_nanosleep , zx_thread_self ,
46
- ZX_ERR_BAD_HANDLE , ZX_ERR_BAD_STATE , ZX_ERR_INVALID_ARGS , ZX_ERR_TIMED_OUT , ZX_ERR_WRONG_TYPE ,
47
- ZX_OK , ZX_TIME_INFINITE , ZX_TIME_INFINITE ,
45
+ zx_futex_wait, zx_futex_wake_single_owner, zx_handle_t, zx_thread_self , ZX_ERR_BAD_HANDLE ,
46
+ ZX_ERR_BAD_STATE , ZX_ERR_INVALID_ARGS , ZX_ERR_TIMED_OUT , ZX_ERR_WRONG_TYPE , ZX_OK ,
47
+ ZX_TIME_INFINITE , ZX_TIME_INFINITE ,
48
48
} ;
49
49
50
50
// The lowest two bits of a `zx_handle_t` are always set, so the lowest bit is used to mark the
@@ -122,18 +122,18 @@ impl Mutex {
122
122
ZX_TIME_INFINITE ,
123
123
) {
124
124
ZX_OK | ZX_ERR_BAD_STATE | ZX_ERR_TIMED_OUT => ( ) ,
125
- // Either the current thread is trying to lock a mutex it has already locked,
126
- // or the previous owner did not unlock the mutex before exiting. Since it is
127
- // not possible to reliably detect which is the case, the current thread is
128
- // deadlocked. This makes debugging these cases quite a bit harder, but encourages
129
- // portable programming, since all other platforms do the same.
130
- //
131
- // Note that if the thread handle is reused, an arbitrary thread's priority could
132
- // be boosted by the wait, but there is currently no way to prevent that.
133
- ZX_ERR_INVALID_ARGS | ZX_ERR_BAD_HANDLE | ZX_ERR_WRONG_TYPE => loop {
134
- zx_nanosleep ( ZX_TIME_INFINITE ) ;
135
- } ,
136
- error => unreachable ! ( "unexpected error code in futex wait : {error}" ) ,
125
+ // Note that if a thread handle is reused after its associated thread
126
+ // exits without unlocking the mutex, an arbitrary thread's priority
127
+ // could be boosted by the wait, but there is currently no way to
128
+ // prevent that.
129
+ ZX_ERR_INVALID_ARGS | ZX_ERR_BAD_HANDLE | ZX_ERR_WRONG_TYPE => {
130
+ panic ! (
131
+ "either the current thread is trying to lock a mutex it has
132
+ already locked, or the previous uowner did not unlock the mutex
133
+ before exiting"
134
+ )
135
+ }
136
+ error => panic ! ( "unexpected error in zx_futex_wait : {error}" ) ,
137
137
}
138
138
}
139
139
}
0 commit comments