Request Counter Clarification

M L triptothefuture.cs at
Mon Dec 21 14:54:54 UTC 2020

Dear NGINX community,

I am developing an NGINX module which would check the contents of the
request and if the key components found, would block it. Currently, it
seems to be working correctly, but I would like to clarify some parts and
make sure that I am not hard-coding anything. So, the question is mainly
about the request counter.
During the execution of the request handler (which is registered on the
HTTP_REWRITE_PHASE), the request counter is kept as it is. But once the
handler finishes the request processing, the counter is changed to 1. But
changing the counter to 1 does not seem like a right decision, as many
other modules more often decrease it in the post_handler or call the
"finalize request" function. However, the use of "finalize" cannot be
implemented, as neither connection, nor request should not be finalized
after the handler execution. Instead, the request needs to be handed over
to the other phase handlers (return NGX_DECLINED). As for the decrementing
in the post_handler of the ngx_http_read_client_request_body function, on
the heavy loads, it results in the segfaults. Finally, leaving the counter
unchanged throughout the process leads to memory leaks. Therefore, the
above-described value assignment was implemented, but, perhaps, there are
better ways of handling the request counter issue? And why the change in
the request counter can cause a segfault in the first place?

With best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list