Re: ngx_http_request_t's subrequests is what meaning be?

Maxim Dounin mdounin at
Fri Jul 2 12:47:46 MSD 2010


On Fri, Jul 02, 2010 at 11:03:20AM +0800, BoBo wrote:

> thanks , but now  nginx use what to  avoid subrequests cycle?
> I think your patch doesn't avoid subrequests cycle, because the certain  may
>  call ngx_http_subrequest again finalize request(the newest subrequest), and
> then cause subrequests cycle.
> so i think should remove r->main->subrequests++.

Removing r->main->subrequests++ completely will limit total number 
of subrequests to NGX_HTTP_MAX_SUBREQUESTS.  This isn't intended 
(and will cause problems in many configurations, e.g. in the thread 
I linked it exceeded 255 without any loops).

Limit on number of subrequests was always meant to limit number of 
simulteneously executing subrequests, and this is what currently 
causes problems (due to r->main->count overflow and resulting 

In general, I see three options on how to handle this:

1. Resurrect r->main->subrequests limit as in patch linked.

2. Drop r->main->subrequests limit and check for r->main->count 
overflows intead.

3. Drop r->main->subrequests limit and introduce something like 
subrequest recursion counter to limit depth of subrequests, not 
it's count.  This implies (2) or bumping r->main->count to 
some bigger datatype to avoid overflows.

Maxim Dounin

More information about the nginx mailing list