Skip to content

Commit

Permalink
Rollup merge of #136908 - mustartt:aix-mutex-destory-einval, r=joboet
Browse files Browse the repository at this point in the history
[AIX] expect `EINVAL` for `pthread_mutex_destroy`

Calling `pthread_mutex_destory` on a mutex initalized with the static initializer macro `PTHREAD_MUTEX_INITIALIZER` will result in `EINVAL` if the mutex is not lock/unlocked prior to calling `pthread_mutex_destroy`.
  • Loading branch information
workingjubilee authored Feb 14, 2025
2 parents a82d7d6 + 4b086d4 commit dfc235f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/std/src/sys/pal/unix/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ impl Drop for Mutex {
// `PTHREAD_MUTEX_INITIALIZER`, which is valid at all locations. Thus,
// this call always destroys a valid mutex.
let r = unsafe { libc::pthread_mutex_destroy(self.raw()) };
if cfg!(target_os = "dragonfly") {
// On DragonFly pthread_mutex_destroy() returns EINVAL if called on a
// mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER.
if cfg!(any(target_os = "aix", target_os = "dragonfly")) {
// On AIX and DragonFly pthread_mutex_destroy() returns EINVAL if called
// on a mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER.
// Once it is used (locked/unlocked) or pthread_mutex_init() is called,
// this behaviour no longer occurs.
debug_assert!(r == 0 || r == libc::EINVAL);
Expand Down

0 comments on commit dfc235f

Please sign in to comment.