]> git.kaiwu.me - njs.git/commit
Modules: fix SharedDict.pop() for unexpired keys in timeout zones
authorhorus <horus.li@gmail.com>
Tue, 28 Jul 2026 02:46:59 +0000 (10:46 +0800)
committerDmitry Volyntsev <xeioexception@gmail.com>
Tue, 11 Aug 2026 22:34:47 +0000 (15:34 -0700)
commit4f4eca5e8e522b27f3edb5bde1d084c6c23831d4
treedd6b3e87d8bca835df00e5f0329a67bcd8a23fa1
parentd01a22e781a349cf562321083590a4b82a5d213c
Modules: fix SharedDict.pop() for unexpired keys in timeout zones

Previously, SharedDict.pop() removed an entry from the expiration rbtree
before checking whether it had expired. ngx_rbtree_delete() clears the
removed node's key, so the subsequent expiration check treated every
entry in a timeout zone as expired. pop() therefore deleted unexpired
entries but returned undefined instead of their values.

The fix preserves the expiration key before removing the node and uses
the saved value for the check in both the njs and QuickJS
implementations. Tests are added for popping an unexpired entry from a
timeout zone.
nginx/ngx_js_shared_dict.c
nginx/t/js_shared_dict.t