Welcome! Log In Create A New Profile


ngx_str_rbtree_lookup gets uint32 hash

October 26, 2020 08:22AM
Some pitfall I stepped on a couple of times, so thought I'd share here -
ngx_str_rbtree_lookup currently uses uint32_t for the hash param, however ngx_rbtree_key_t is ngx_uint_t.
This means that if someone calculates a hash that is potentially int64 (e.g.. using ngx_hash_key/_lc),
the nodes will not be found when looking them up the rbtree.

Even though it doesn't matter for nginx core (all places that reference this function in core use crc32 for the hash...)
IMHO it would be good to change the function signature to use ngx_uint_t or ngx_rbtree_key_t.
Such a change is not expected to cause any backward compatibility issue for modules that depend on this function.

Makes sense?



nginx-devel mailing list
Subject Author Views Posted

ngx_str_rbtree_lookup gets uint32 hash

erankor 194 October 26, 2020 08:22AM

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

Online Users

Guests: 62
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