[PATCH 27 of 31] Core: protect from subrequest loops

Maxim Dounin mdounin at mdounin.ru
Tue Feb 15 16:33:43 MSK 2011


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1297776703 -10800
# Node ID 04d83b2dd806307ec120c322e936588350636ffb
# Parent  2fe2f9c552aca65581268a5add6b37eba5f86e6c
Core: protect from subrequest loops.

Without protection subrequest loop results in r->count overflow and
SIGSEGV.  Protection was broken in 0.7.25.

Note that this also limits number of parallel subrequests.  This
wasn't exactly the case before 0.7.25 as local subrequests were
completed directly.

See here for details:

http://nginx.org/pipermail/nginx-ru/2010-February/032184.html

diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -2293,7 +2293,6 @@ ngx_http_subrequest(ngx_http_request_t *
     r->start_sec = tp->sec;
     r->start_msec = tp->msec;
 
-    r->main->subrequests++;
     r->main->count++;
 
     *psr = sr;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1976,6 +1976,7 @@ ngx_http_finalize_request(ngx_http_reque
         if (r == c->data) {
 
             r->main->count--;
+            r->main->subrequests++;
 
             if (!r->logged) {
 



More information about the nginx-devel mailing list