<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        font-size:10.5pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=ZH-CN link=blue vlink=purple style='text-justify-trim:punctuation'>

<div class=Section1>

<p class=MsoNormal><span lang=EN-US>Hi all,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Currently I&#8217;m working on a HTTP server based on ACE, and I found that the
implementation of TP Reactor on ACE 5.5.10 might cause some problems when
there&#8217;re many connections.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>The implementation of dispatch_i() is the
following (simplified):<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:21.0pt;mso-para-margin-left:2.0gd'><span
lang=EN-US>this-&gt;handle_timer_events (event_count, guard);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:21.0pt;mso-para-margin-left:2.0gd'><span
lang=EN-US>this-&gt;handle_notify_events (event_count, guard);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:21.0pt;mso-para-margin-left:2.0gd'><span
lang=EN-US>this-&gt;handle_socket_events (event_count, guard);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:21.0pt;mso-para-margin-left:2.0gd'><span
lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:21.0pt;mso-para-margin-left:2.0gd'><span
lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>I have to register a timeout event on the
reactor when a new connection comes, in order to disconnect it when it is idle.
However, the strategy might be buggy considering the following timing sequence:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:10.5pt;mso-para-margin-left:1.0gd'><span
lang=EN-US>Connection A comes<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:10.5pt;mso-para-margin-left:1.0gd'><span
lang=EN-US>Connection B comes<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:10.5pt;mso-para-margin-left:1.0gd'><span
lang=EN-US>The peer of connection B send some data<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:10.5pt;mso-para-margin-left:1.0gd'><span
lang=EN-US>Handle_events() ( Invoke handle_input() to process B&#8217;s request)<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:10.5pt;mso-para-margin-left:1.0gd'><span
lang=EN-US>The peer of connection A send some data<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:10.5pt;mso-para-margin-left:1.0gd'><span
lang=EN-US>A timeout<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:10.5pt;mso-para-margin-left:1.0gd'><span
lang=EN-US>Handle_events() ( Invoke handle_timeout() for A)<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>We can see that the request from connection
A is lost. When the server has many connections and limited threads for
handling them, it seems that the sequence above happens occasionally, which is
frustrating for a HTTP server, making HTTP client gets nothing.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>It seems that making handle_socket_events()
comes first in dispatch_i() would solve the problem. But I also noticed that
Prof. Schmidt once mentioned the primary concern of the implementation is to
maximize the throughput, yet it would be useful for TCP server to change the
priority of the events for better services.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>The comments of ACE 5.5.1 says that
introducing an Strategy class would solve problem, but those comments are gone
in ACE 5.5.10. Does it means that the problem is solved?<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>The e-mail seems a bit long </span><span
lang=EN-US style='font-family:Wingdings'>L</span><span lang=EN-US>, thanks for
reading it, any comments would be appreciated </span><span lang=EN-US
style='font-family:Wingdings'>J</span><span lang=EN-US><o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Mai<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

</div>

</body>

</html>