<br><br><div class="gmail_quote">On Mon, Oct 22, 2012 at 12:06 PM, Glyph <span dir="ltr">&lt;<a href="mailto:glyph@twistedmatrix.com" target="_blank">glyph@twistedmatrix.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div class="im"><br><div><div>On Oct 20, 2012, at 7:56 PM, gelin yan &lt;<a href="mailto:dynamicgl@gmail.com" target="_blank">dynamicgl@gmail.com</a>&gt; wrote:</div><br><blockquote type="cite">
<div style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
&quot;<font face="arial, helvetica, sans-serif"><span style="color:rgb(42,42,42);font-size:12px;line-height:18px">A pending operation is indicated when the function that started the operation returns </span><strong style="color:rgb(42,42,42);font-size:12px;line-height:18px">FALSE</strong><span style="color:rgb(42,42,42);font-size:12px;line-height:18px">, and the </span><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms679360(v=vs.85).aspx" style="text-decoration:none;color:rgb(3,105,122);font-size:12px;line-height:18px" target="_blank"><strong>GetLastError</strong></a><span style="color:rgb(42,42,42);font-size:12px;line-height:18px"> function returns </span><strong style="color:rgb(42,42,42);font-size:12px;line-height:18px">ERROR_IO_PENDING</strong><span style="color:rgb(42,42,42);font-size:12px;line-height:18px">. When an I/O operation is pending, the function that started the operation resets the </span><strong style="color:rgb(42,42,42);font-size:12px;line-height:18px">hEvent</strong><span style="color:rgb(42,42,42);font-size:12px;line-height:18px"> member of the </span><strong style="color:rgb(42,42,42);font-size:12px;line-height:18px">OVERLAPPED</strong><span style="color:rgb(42,42,42);font-size:12px;line-height:18px"> structure to the nonsignaled state. Then when the pending operation has been completed, the system sets the event object to the signaled state</span></font><span style="color:rgb(42,42,42);font-family:&#39;Segoe UI&#39;,&#39;Lucida Grande&#39;,Verdana,Arial,Helvetica,sans-serif;font-size:12px;line-height:18px">.&quot;</span></div>
<div style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<span style="color:rgb(42,42,42);font-family:&#39;Segoe UI&#39;,&#39;Lucida Grande&#39;,Verdana,Arial,Helvetica,sans-serif;font-size:12px;line-height:18px"><br></span></div><div style="font-family:Menlo;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<span style="color:rgb(42,42,42);font-family:&#39;Segoe UI&#39;,&#39;Lucida Grande&#39;,Verdana,Arial,Helvetica,sans-serif;font-size:12px;line-height:18px"> <span> </span></span><span style="color:rgb(42,42,42);font-family:&#39;Segoe UI&#39;,&#39;Lucida Grande&#39;,Verdana,Arial,Helvetica,sans-serif;line-height:18px"><font size="4">If we can know when event object is in the signaled state we definitely can use a queue directly. Any idea?</font></span></div>
<br></blockquote></div><br></div><div>Sounds like you&#39;re at the point where you should just try doing an implementation, and if it works and passes all the tests you can think of for it, submit it for code review.  Much more speculation without testing wouldn&#39;t be useful.</div>
<div><br></div><div>Thanks for working on this!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-glyph</div></font></span></div><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br><div>Hi All</div><div><br></div><div>   Sorry for coming late. The day before yesterday, I dig out what happen in that code. Actually, ERROR_IO_PENDING isn&#39;t the root of problem. The problem is doWrite method might be triggered twice instead of once; in particular, when trying to send a large chunks data whose size is bigger then SEND_LIMIT, it will always happen.</div>
<div><br></div><div>    When doWrite being invoked twice, it means the same buffer data will be sent twice. It is for sure that PB is unable to deserialize  these data and finally it raise an exception, now, we can see connection lost.</div>
<div><br></div><div>    The solution is to make sure doWrite calling in order; hence I introduce a new field named _doWriteCalling to detect whether doWrite call is completed. (due to doWrite always post an event to IOCP, so once _cbWrite get called, it means we can schedule another doWrite). If _cbWrite isn&#39;t called, we simply re-schedule the doWrite by reactor.callLater.</div>
<div><br></div><div>    I attach a modified abstract.py here. You may put it in  Path\twisted\internet\iocpreactor</div><div>and give it a try.</div><div><br></div><div>Regards</div><div><br></div><div>gelin yan</div><div>
  </div>