Wow, I found it and I am a complete idiot.&nbsp; My RTO estimator sometimes generated a microsecond field of greater than 1 million.&nbsp; This causes select to fail.&nbsp; Thanks for the help.<br><br>-Amit<br><br><div class="gmail_quote">
On Dec 9, 2007 4:53 PM,  &lt;<a href="mailto:vern@cs.berkeley.edu">vern@cs.berkeley.edu</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">&gt; I am using select to wake me up on a timeout or if there is data ready to be<br>&gt; received. &nbsp;Towards the end of the transfer, select returns before a timeout<br>&gt; and FD_ISSET returns true implying that there is data to be read, so I call
<br>&gt; recvfrom which ends up blocking which would imply that there is nothing<br>&gt; there.<br><br></div>In my experience, this is pretty much always some sort of bug in the use<br>of select, though they can sometimes be very hard to find. &nbsp;You&#39;ve already
<br>taken care of the #1 suspect, which is failing to FD_ZERO or failing to<br>FD_SET correctly. &nbsp;Another possibility is that your code is structured to<br>(somewhere internal) read from the fd that you&#39;re then later trying to
<br>read due to select(), so that now it no longer has anything to return;<br>or you&#39;re reading with recvfrom and what you&#39;ve specified doesn&#39;t match<br>the packet that came in.<br><br>If you send me your select() loop, I&#39;ll try to take a look at it. &nbsp;However,
<br>I&#39;m not online much today, so I&#39;m not sure if I&#39;ll be able to reply before<br>tomorrow.<br><div class="Ih2E3d"><br>&gt; I read online that select does not guarantee that recvfrom wont<br>&gt; block because the packet may have been corrupted.
<br><br></div>That doesn&#39;t sound right to me - the kernel should make the integrity checks<br>prior to analyzing the rest of the header, and it has to do that analysis<br>in order to figure out which file descriptor to flag as being available
<br>for reading. &nbsp;(More generally, servers all over the world rely on select()<br>not causing them to occasionally block waiting to read - so this is code<br>that has *really* been hammered on.)<br><div class="Ih2E3d"><br>
&gt; So I changed my socket to<br>&gt; work in non-blocking mode.<br><br></div>Do try to avoid that. &nbsp;Like select(), it comes with its own subtle usage<br>errors, and the combination can be quite confusing.<br><br>It&#39;s worth stepping through the code executed by MNL for the recv to
<br>see whether in some cases it reads twice or something like that.<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Vern<br></blockquote></div><br>