summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2017-06-16 18:15:58 +0300
committerRuslan Ermilov <ru@nginx.com>2017-06-16 18:15:58 +0300
commit6a4a1f0e23ae07d5a425900b1a9f3623134be55a (patch)
tree35a93e60d8263461b010379fd2b5fbdfe3f35db9
parent3f26c207560037af6cc47964da72c53d587e2def (diff)
downloadnginx-6a4a1f0e23ae07d5a425900b1a9f3623134be55a.tar.gz
Introduced ngx_rwlock_downgrade().
-rw-r--r--src/core/ngx_rwlock.c9
-rw-r--r--src/core/ngx_rwlock.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/core/ngx_rwlock.c b/src/core/ngx_rwlock.c
index 0aed29af5..ed2b0f810 100644
--- a/src/core/ngx_rwlock.c
+++ b/src/core/ngx_rwlock.c
@@ -109,6 +109,15 @@ ngx_rwlock_unlock(ngx_atomic_t *lock)
}
+void
+ngx_rwlock_downgrade(ngx_atomic_t *lock)
+{
+ if (*lock == NGX_RWLOCK_WLOCK) {
+ *lock = 1;
+ }
+}
+
+
#else
#if (NGX_HTTP_UPSTREAM_ZONE || NGX_STREAM_UPSTREAM_ZONE)
diff --git a/src/core/ngx_rwlock.h b/src/core/ngx_rwlock.h
index 8b16eca20..41b42aa82 100644
--- a/src/core/ngx_rwlock.h
+++ b/src/core/ngx_rwlock.h
@@ -16,6 +16,7 @@
void ngx_rwlock_wlock(ngx_atomic_t *lock);
void ngx_rwlock_rlock(ngx_atomic_t *lock);
void ngx_rwlock_unlock(ngx_atomic_t *lock);
+void ngx_rwlock_downgrade(ngx_atomic_t *lock);
#endif /* _NGX_RWLOCK_H_INCLUDED_ */