Mercurial > hg > nginx
changeset 7995:7752d8523066
Core: simplify reader lock release.
author | Pavel Pautov <p.pautov@f5.com> |
---|---|
date | Wed, 19 Jan 2022 17:37:34 -0800 |
parents | aeab41dfd260 |
children | 5d88e2bf92b3 |
files | src/core/ngx_rwlock.c |
diffstat | 1 files changed, 3 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_rwlock.c Mon Jan 17 17:05:12 2022 +0300 +++ b/src/core/ngx_rwlock.c Wed Jan 19 17:37:34 2022 -0800 @@ -89,22 +89,10 @@ void ngx_rwlock_unlock(ngx_atomic_t *lock) { - ngx_atomic_uint_t readers; - - readers = *lock; - - if (readers == NGX_RWLOCK_WLOCK) { + if (*lock == NGX_RWLOCK_WLOCK) { (void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0); - return; - } - - for ( ;; ) { - - if (ngx_atomic_cmp_set(lock, readers, readers - 1)) { - return; - } - - readers = *lock; + } else { + (void) ngx_atomic_fetch_add(lock, -1); } }