Maxim Dounin mdounin at
Tue Apr 18 12:35:42 UTC 2023


On Tue, Apr 18, 2023 at 06:14:46AM +0000, Yuval Abadi via nginx wrote:

> Ngx_list_t   have create api but no free_list api
> Why?
> I wrote my own free_list,  is anyone else   face this  issue?

Much like many things in nginx, ngx_list_t structure is an 
append-only structure, and it is expected to be used as a list of 
items being added.  Most notably, ngx_list_t is used for request 
headers (these are added to the list when they are parsed), and 
response headers (these are added when they are generated 

If you have to remove an item for some reason (which shouldn't be 
common case for legitimate usage, but might happen to be needed 
occasionally), the common approach is to use a "skip" flag in the 
structures being listed.  For example, response headers are 
cleared by setting the "hash" field to 0, so such headers are 
ignored by the code iterating over the list.

If you need something more dynamic in your code, ngx_list_t might 
not be the right structure to use.  Something like ngx_queue_t or 
ngx_rbtree_t might be a better choice.

Maxim Dounin

More information about the nginx mailing list