[PATCH] nginx does not close the connection for 412 responses under extreme conditions
agentzh at gmail.com
Sat May 12 15:10:09 UTC 2012
On Sat, May 12, 2012 at 8:47 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> I assume you use error_page to redirect 412, right? You may want
> to show config (and more complete debug log) to simplify reading.
Nope. There is no error_page directive in my nginx.conf. Here is the
configure file I'm using:
The request I'm using is this:
GET / HTTP/1.1
If-Unmodified-Since: Thu, 10 May 2012 07:50:47 GMT
The debug log is here (only the first part is given, because the whole
is too huge):
>> 2 2012/05/12 20:14:01 [debug] 2770#0: *1 http finalize request:
>> -4, "/index.html?" a:1, c:2
> How this happens to be -4 (NGX_DONE)?
In short, the ngx_http_finalize_request(r, NGX_DONE) call was caused
by recursive calling of ngx_http_core_content_phase due to the
standard ngx_index module.
To be more specific, the backtrace for the (first)
ngx_http_finalize_request(r, NGX_AGAIN) call looks like this
#0 ngx_http_finalize_request (r=0x77ccb0, rc=-2) at
#1 0x0000000000455758 in ngx_http_core_content_phase (r=0x77ccb0, ph=0x78d5c8)
#2 0x00000000004542a4 in ngx_http_core_run_phases (r=0x77ccb0)
#3 0x000000000045421b in ngx_http_handler (r=0x77ccb0) at
#4 0x0000000000457d53 in ngx_http_internal_redirect (r=0x77ccb0,
#5 0x0000000000482b8b in ngx_http_index_handler (r=0x77ccb0)
#6 0x000000000045573a in ngx_http_core_content_phase (r=0x77ccb0, ph=0x78d598)
#7 0x00000000004542a4 in ngx_http_core_run_phases (r=0x77ccb0)
#8 0x000000000045421b in ngx_http_handler (r=0x77ccb0) at
We can see that when ngx_http_finalize_request (r=0x77ccb0, rc=-2)
returns, the ngx_http_internal_redirect call at frame #4 will then
return NGX_DONE to ngx_http_index_handler at frame #5, and in turn,
ngx_http_index_handler will also return NGX_DONE to
ngx_http_core_content_phase at frame #6, and finally triggering the
call ngx_http_finalize_request(r, NGX_DONE).
If you have further questions, please let me know :) And thank you
very much for looking into this!
More information about the nginx-devel