Core: simplify reader lock release.

This commit is contained in:
Pavel Pautov 2022-01-19 17:37:34 -08:00
parent 429150c1fa
commit 950390108c

View File

@ -89,22 +89,10 @@ ngx_rwlock_rlock(ngx_atomic_t *lock)
void void
ngx_rwlock_unlock(ngx_atomic_t *lock) ngx_rwlock_unlock(ngx_atomic_t *lock)
{ {
ngx_atomic_uint_t readers; if (*lock == NGX_RWLOCK_WLOCK) {
readers = *lock;
if (readers == NGX_RWLOCK_WLOCK) {
(void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0); (void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0);
return; } else {
} (void) ngx_atomic_fetch_add(lock, -1);
for ( ;; ) {
if (ngx_atomic_cmp_set(lock, readers, readers - 1)) {
return;
}
readers = *lock;
} }
} }