<div>hi all.</div><div><br></div>I am reading  nginx's source(version is 0.7.66), but i don't understand this section:<div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">ngx_int_t</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">ngx_http_subrequest(ngx_http_request_t *r,</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr,</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â ngx_http_post_subrequest_t *ps, ngx_uint_t flags)</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">{</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">   ngx_connection_t        *c;</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">   ngx_http_request_t       *sr;</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">   ngx_http_core_srv_conf_t    *cscf;</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">   ngx_http_postponed_request_t  *pr, *p;</font></font></div>
<div><font class="Apple-style-span" color="#FF0000" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" color="#FF0000" face="'courier new', monospace">//i know subrequests's default is NGX_HTTP_MAX_SUBREQUESTS + 1 = 51;</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â r->main->subrequests--;</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000"><br>
</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">//when subrequests </font></font><span class="Apple-style-span" style="font-family: 'courier new', monospace; color: rgb(255, 0, 0); ">is </span><span class="Apple-style-span" style="font-family: 'courier new', monospace; color: rgb(255, 0, 0); "> 0? </span></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â if (r->main->subrequests == 0) {</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â Â Â ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â Â Â Â Â Â Â Â Â Â "subrequests cycle while processing \"%V\"", uri);</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â Â Â r->main->subrequests = 1;</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â Â Â return NGX_ERROR;</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â }</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">....................................................................</font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000"><br></font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">//why subrequests need plus plus? </font></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â r->main->subrequests++;</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000"><br>
</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â *psr = sr;</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000"><br>
</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">Â Â Â return ngx_http_post_request(sr);</font></font></div><div><font class="Apple-style-span" face="'courier new', monospace"><font class="Apple-style-span" color="#FF0000">}</font></font></div>
<div><br></div>the problem is after call <span class="Apple-style-span" style="font-family: 'courier new', monospace; ">ngx_http_subrequest and</span><span class="Apple-style-span" style="font-family: 'courier new', monospace; color: rgb(255, 0, 0); "> </span> r->main->subrequests will not change(because subrequests-- and then ++), so <font class="Apple-style-span" face="'courier new', monospace">when subrequests </font><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">is </span><span class="Apple-style-span" style="font-family: 'courier new', monospace; "> 0?</span></div>
<div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "><br></span></div><div><font class="Apple-style-span" face="'courier new', monospace">I think if </font> r->main->subrequests is the max subrequests number,  <span class="Apple-style-span" style="font-family: 'courier new', monospace; ">r->main->subrequests++ need to be  removed.</span></div>
<meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">thanks.</span></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>
-- <br>åšè§‚约å–<br><br>douban :<a href="http://www.douban.com/people/mustang/">www.douban.com/people/mustang/</a><br><br>blog: <a href="http://simohayha.javaeye.com">simohayha.javaeye.com</a><br><br>twitter: <a href="http://www.twitter.com/minibobo">www.twitter.com/minibobo</a><br>
</div>