Welcome! Log In Create A New Profile

Advanced

[njs] Modules: fixed clear() method of a shared dictionary without timeout.

Dmitry Volyntsev
March 20, 2024 09:30PM
details: https://hg.nginx.org/njs/rev/f632fe16ba05
branches:
changeset: 2303:f632fe16ba05
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Mar 19 21:05:51 2024 -0700
description:
Modules: fixed clear() method of a shared dictionary without timeout.

Previously, the code did not unlock the rwlock when a dict was empty.

The issue was introduced in 4a15613f4e8b (0.8.3).

This closes issue #699 on Github.

diffstat:

nginx/ngx_js_shared_dict.c | 4 +++-
nginx/t/js_shared_dict.t | 1 +
2 files changed, 4 insertions(+), 1 deletions(-)

diffs (32 lines):

diff -r 85313a068147 -r f632fe16ba05 nginx/ngx_js_shared_dict.c
--- a/nginx/ngx_js_shared_dict.c Mon Mar 18 22:24:57 2024 -0700
+++ b/nginx/ngx_js_shared_dict.c Tue Mar 19 21:05:51 2024 -0700
@@ -479,7 +479,7 @@ njs_js_ext_shared_dict_clear(njs_vm_t *v
rbtree = &dict->sh->rbtree;

if (rbtree->root == rbtree->sentinel) {
- return NJS_OK;
+ goto done;
}

for (rn = ngx_rbtree_min(rbtree->root, rbtree->sentinel);
@@ -494,6 +494,8 @@ njs_js_ext_shared_dict_clear(njs_vm_t *v
}
}

+done:
+
ngx_rwlock_unlock(&dict->sh->rwlock);

njs_value_undefined_set(retval);
diff -r 85313a068147 -r f632fe16ba05 nginx/t/js_shared_dict.t
--- a/nginx/t/js_shared_dict.t Mon Mar 18 22:24:57 2024 -0700
+++ b/nginx/t/js_shared_dict.t Tue Mar 19 21:05:51 2024 -0700
@@ -266,6 +266,7 @@ EOF

function set_clear(r) {
var dict = ngx.shared.no_timeout;
+ dict.clear();
dict.set("test", "test value");
dict.set("test1", "test1 value");
dict.clear();
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Modules: fixed clear() method of a shared dictionary without timeout.

Dmitry Volyntsev 116 March 20, 2024 09:30PM



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

Online Users

Guests: 169
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready