Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perl.h: Convert reentrant locks to allow many readers, avoid deadlock if hold write lock then request it as read-only #22282

Merged
merged 2 commits into from
Jun 24, 2024

Conversation

khwilliamson
Copy link
Contributor

This is in preparation for future use of these.
The only current mutex that is reentrant is the one for locales.

This is in preparation for future use of these.
The only current mutex that is reentrant is the one for locales.

This simply changes the reentrant locks from using the single reader
locks to using the multiple reader locks.
In a reentrant mutex, the previous commit added the ability to have
multiple readers.  But if a thread already owns a mutex for writing, and
requests a read lock as well, prior to this commit the thread will be
deadlocked by itself.

Avoid this by testing for the condition and handling separately.

All reentrant mutexes currently have no read lock attempts.  So this
case is entirely theoretical for the moment.
@khwilliamson khwilliamson merged commit 262c141 into Perl:blead Jun 24, 2024
30 checks passed
@khwilliamson khwilliamson deleted the locks branch June 24, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants