mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Fix rwlock stall with PREFER_WRITER_NONRECURSIVE_NP (bug 23861)
In the read lock function (__pthread_rwlock_rdlock_full) there was a code path which would fail to reload __readers while waiting for PTHREAD_RWLOCK_RWAITING to change. This failure to reload __readers into a local value meant that various conditionals used the old value of __readers and with only two threads left it could result in an indefinite stall of one of the readers (waiting for PTHREAD_RWLOCK_RWAITING to go to zero, but it never would).
This commit is contained in:
@ -314,7 +314,7 @@ __pthread_rwlock_rdlock_full (pthread_rwlock_t *rwlock,
|
||||
harmless because the flag is just about the state of
|
||||
__readers, and all threads set the flag under the same
|
||||
conditions. */
|
||||
while ((atomic_load_relaxed (&rwlock->__data.__readers)
|
||||
while (((r = atomic_load_relaxed (&rwlock->__data.__readers))
|
||||
& PTHREAD_RWLOCK_RWAITING) != 0)
|
||||
{
|
||||
int private = __pthread_rwlock_get_private (rwlock);
|
||||
|
Reference in New Issue
Block a user