ngx_http_request_t's subrequests is what meaning be?

BoBo simohayha.bobo at gmail.com
Thu Jul 1 16:08:42 MSD 2010


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?

I think if  r->main->subrequests is the max subrequests number,
r->main->subrequests++
need to be  removed.

thanks.
-- 
博观约取

douban :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/20100701/2f8c42eb/attachment.html>


More information about the nginx mailing list