Re: ngx_http_request_t's subrequests is what meaning be?

BoBo simohayha.bobo at gmail.com
Fri Jul 2 07:03:20 MSD 2010


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++.

On Thu, Jul 1, 2010 at 10:08 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> Hello!
>
> On Thu, Jul 01, 2010 at 08:08:42PM +0800, BoBo wrote:
>
> > hi all.
> >
> > I am reading  nginx's source(version is 0.7.66), but i don't understand
> this
> > section:
> >
> > ngx_int_t
> > ngx_http_subrequest(ngx_http_request_t *r,
> >     ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr,
> >     ngx_http_post_subrequest_t *ps, ngx_uint_t flags)
> > {
> >     ngx_connection_t              *c;
> >     ngx_http_request_t            *sr;
> >     ngx_http_core_srv_conf_t      *cscf;
> >     ngx_http_postponed_request_t  *pr, *p;
> >
> > //i know subrequests's default is NGX_HTTP_MAX_SUBREQUESTS + 1 = 51;
> >     r->main->subrequests--;
> >
> > //when subrequests is  0?
> >     if (r->main->subrequests == 0) {
> >         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
> >                       "subrequests cycle while processing \"%V\"", uri);
> >         r->main->subrequests = 1;
> >         return NGX_ERROR;
> >     }
> > ....................................................................
> >
> > //why subrequests need plus plus?
> >     r->main->subrequests++;
> >
> >     *psr = sr;
> >
> >     return ngx_http_post_request(sr);
> > }
> >
> > the problem is after call ngx_http_subrequest and  r->main->subrequests
> will
> > not change(because subrequests-- and then ++), so when subrequests is  0?
>
> Right now - it would never be 0 (and this strikes badly as long as
> you issue > 255 subrequests, as r->main->counter overflows).  This
> logic was introduced for older subrequest implementation where
> subrequests were completed directly.  Subrequest processing was
> changed in 0.7.25 and this subrequests-- and subrequests++ no
> longer make sense.
>
> I've posted a patch a while ago which moves r->main->subrequests++
> into request finalization, see here (in Russian):
>
> http://nginx.org/pipermail/nginx-ru/2010-February/032184.html
>
> Maxim Dounin
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



-- 
博观约取

豆瓣:www.douban.com/people/mustang/

blog: simohayha.javaeye.com

twitter: www.twitter.com/minibobo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20100702/1063f7ed/attachment-0001.html>


More information about the nginx mailing list