Welcome! Log In Create A New Profile

Advanced

[nginx] Core: simplify reader lock release.

Pavel Pautov via nginx-devel
January 20, 2022 07:02PM
details: https://hg.nginx.org/nginx/rev/7752d8523066
branches:
changeset: 7995:7752d8523066
user: Pavel Pautov <p.pautov@f5.com>
date: Wed Jan 19 17:37:34 2022 -0800
description:
Core: simplify reader lock release.

diffstat:

src/core/ngx_rwlock.c | 18 +++---------------
1 files changed, 3 insertions(+), 15 deletions(-)

diffs (29 lines):

diff -r aeab41dfd260 -r 7752d8523066 src/core/ngx_rwlock.c
--- 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 @@ 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);
}
}

_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[nginx] Core: simplify reader lock release.

Pavel Pautov via nginx-devel 218 January 20, 2022 07:02PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 126
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready