Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pautov <p.pautov@f5.com>2022-01-20 04:37:34 +0300
committerPavel Pautov <p.pautov@f5.com>2022-01-20 04:37:34 +0300
commit950390108cbb8431845635176c36466653b05487 (patch)
tree4575dbb897d11ab184d8dbf1458cb6c3f0f6fb47
parent429150c1fa78317bdb19de380ce709651dbc042c (diff)
Core: simplify reader lock release.
-rw-r--r--src/core/ngx_rwlock.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/core/ngx_rwlock.c b/src/core/ngx_rwlock.c
index ed2b0f810..e7da8a8ec 100644
--- a/src/core/ngx_rwlock.c
+++ b/src/core/ngx_rwlock.c
@@ -89,22 +89,10 @@ ngx_rwlock_rlock(ngx_atomic_t *lock)
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);
}
}