Persistent buffers allocation

Eran Kornblau eran.kornblau at kaltura.com
Thu Aug 22 14:11:18 UTC 2019


Hi all,

I noticed today that I'm missing something basic... I wanted to allocate some buffers that will live throughout the lifetime of the process =
not associated with any specific request. I believe I've already done something like that in the past, and I used the cycle pool for that.
However, after digging a bit in the code, I found that in single process mode, if nginx is reloaded, a new cycle is created and the
old one destroyed.

If my understanding is correct, this has many implications far exceeding the simple question I started with...
For example, since the configuration is allocated on the cycle pool, it means that modules should not read the configuration
of the request in any asynchronous callback, because there is a chance that the configuration was already freed since the request
object was created.

I then found this issue - https://trac.nginx.org/nginx/ticket/945 so I guess that this problem is known and ignored because
'master_process off' is only for dev, and no need to support reload there...

So, back to my original question... is using ngx_cycle->pool the correct way to allocate such "persistent" buffers?
Another option is to use ngx_alloc directly (if the process quits, it doesn't matter...), but cycle pool sounds a bit more elegant
(and won't have valgrind report leaks...)

Thank you!

Eran

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20190822/962a020d/attachment.html>


More information about the nginx-devel mailing list