thanks , but now  nginx use what to  avoid <meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; font-size: 13px; border-collapse: collapse; ">subrequests cycle? </span><div>

<font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="border-collapse: collapse;">I think your patch doesn&#39;t avoid <span class="Apple-style-span" style="font-size: 13px; ">subrequests cycle, because the certain  may  call ngx_http_subrequest again finalize request(the newest subrequest), and then cause </span><span class="Apple-style-span" style="font-size: 13px; ">subrequests cycle.</span><br>

</span></font><br></div><div>so i think should remove <span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; font-size: 13px; border-collapse: collapse; ">r-&gt;main-&gt;subrequests++.</span></div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font><div class="gmail_quote">On Thu, Jul 1, 2010 at 10:08 PM, Maxim Dounin <span dir="ltr">&lt;<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>&gt;</span> wrote:<br>

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