mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
LibC: Fix race condition in pthread_mutex_unlock()
This ensures the store to mutex->lock doesn't get re-ordered before the store to mutex->owner which could otherwise result in a locked owner-less mutex if another thread tries to acquire the lock at the same time.
This commit is contained in:
parent
5ca1d4289b
commit
90f4c9e44c
1 changed files with 1 additions and 1 deletions
|
@ -119,7 +119,7 @@ int __pthread_mutex_unlock(pthread_mutex_t* mutex)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
mutex->owner = 0;
|
mutex->owner = 0;
|
||||||
mutex->lock = 0;
|
AK::atomic_store(&mutex->lock, 0u, AK::memory_order_release);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue