Mercurial > hg > nginx
comparison src/core/ngx_rwlock.c @ 7995:7752d8523066
Core: simplify reader lock release.
author | Pavel Pautov <p.pautov@f5.com> |
---|---|
date | Wed, 19 Jan 2022 17:37:34 -0800 |
parents | d1816a2696de |
children |
comparison
equal
deleted
inserted
replaced
7994:aeab41dfd260 | 7995:7752d8523066 |
---|---|
87 | 87 |
88 | 88 |
89 void | 89 void |
90 ngx_rwlock_unlock(ngx_atomic_t *lock) | 90 ngx_rwlock_unlock(ngx_atomic_t *lock) |
91 { | 91 { |
92 ngx_atomic_uint_t readers; | 92 if (*lock == NGX_RWLOCK_WLOCK) { |
93 | |
94 readers = *lock; | |
95 | |
96 if (readers == NGX_RWLOCK_WLOCK) { | |
97 (void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0); | 93 (void) ngx_atomic_cmp_set(lock, NGX_RWLOCK_WLOCK, 0); |
98 return; | 94 } else { |
99 } | 95 (void) ngx_atomic_fetch_add(lock, -1); |
100 | |
101 for ( ;; ) { | |
102 | |
103 if (ngx_atomic_cmp_set(lock, readers, readers - 1)) { | |
104 return; | |
105 } | |
106 | |
107 readers = *lock; | |
108 } | 96 } |
109 } | 97 } |
110 | 98 |
111 | 99 |
112 void | 100 void |