<DIV>Hi all,</DIV>
<DIV> </DIV>
<DIV><FONT size="3">Does limit_rate, which is in write filter module, work right when many subrequests exist?</FONT></DIV>
<DIV><FONT size="3">I meet a problem with limit_rate for many subrequests. Here is the problem.</FONT></DIV>
<DIV><FONT size="3"> </FONT></DIV>
<DIV><FONT size="3">1. limit_rate works like this:</FONT></DIV>
<DIV><FONT size="3">a) after sending data, it will set wev->delayed which disable data sending, and sleep for a while(add_timer);</FONT></DIV>
<DIV><FONT size="3">b) when timedout, the wev handler will clear wev->delayed, to enable data sending. </FONT></DIV>
<DIV><FONT size="3">For example, the handler may like this;</FONT></DIV>
<DIV>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><o:p><FONT size="3" face="Calibri"></FONT></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><STRONG><FONT size="3">src/http/ngx_http_upstream.c:<SPAN lang="EN-US"><FONT face="Calibri">ngx_http_upstream_process_downstream()</FONT></SPAN><o:p></o:p></FONT></STRONG></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>2361<SPAN style="mso-spacerun: yes"> </SPAN>if (wev->timedout) {</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>2363<SPAN style="mso-spacerun: yes"> </SPAN>if (wev->delayed) {</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>2367<SPAN style="mso-spacerun: yes"> </SPAN>wev->delayed = 0;</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>2389<SPAN style="mso-spacerun: yes"> </SPAN>}</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>2395<SPAN style="mso-spacerun: yes"> </SPAN>}</FONT></FONT></SPAN></P></DIV>
<DIV><FONT size="3"> </FONT></DIV>
<DIV><FONT size="3">2. but 1 wev (write event) corresponds to 1 connection; while 1 (downstream) connection may has many subrequests.</FONT></DIV>
<DIV><FONT size="3">so when wev timedout, wev gets the active request of the connection, like this:</FONT></DIV>
<DIV><FONT size="3"> </FONT></DIV>
<DIV>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><B style="mso-bidi-font-weight: normal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3">src/http/ngx_http_request.c:ngx_http_request_handler()<o:p></o:p></FONT></FONT></SPAN></B></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>1724<SPAN style="mso-spacerun: yes"> </SPAN>c = ev->data;</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>1725<SPAN style="mso-spacerun: yes"> </SPAN>r = c->data;</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>1726</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>1733<SPAN style="mso-spacerun: yes"> </SPAN>if (ev->write) {</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>1734<SPAN style="mso-spacerun: yes"> </SPAN>r->write_event_handler(r);</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>1737<SPAN style="mso-spacerun: yes"> </SPAN>} else {</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN><SPAN style="mso-spacerun: yes"> </SPAN>1738<SPAN style="mso-spacerun: yes"> </SPAN>r->read_event_handler(r);</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"><FONT size="3"><SPAN style="mso-spacerun: yes"> </SPAN>1739<SPAN style="mso-spacerun: yes"> </SPAN>}</FONT></FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><SPAN lang="EN-US"><FONT face="Calibri"></FONT></SPAN><FONT size="3"> </FONT></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><FONT size="3"></FONT> </P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><FONT size="3">3. The problem is that: the active request of this connection maybe not the one who added the timer. which means that the active request of the connection changes before timedout. So its write_event_handler maybe not the one expected. For example, if the active request's write_event_handler is happened to be ngx_http_request_empty_handler(), which is set in ngx_http_core_content_phase(), then the handler doesn't clear the wev->delayed. <STRONG>So the data sending in write filter module will never be enabled again</STRONG>.</FONT></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><FONT size="3"></FONT> </P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><FONT size="3">Is my analysis right? Does limit_rate work right for many subrequests?</FONT></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"> </P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><FONT size="3">I hope I made myself understood.</FONT></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><FONT size="3">Thanks,</FONT></P>
<P style="MARGIN: 0cm 0cm 0pt" class="MsoNormal"><FONT size="3">Wu<BR></FONT></P></DIV><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>