<div dir="ltr">Hi Levente, Hi All,<div><br></div><div>    I&#39;m trying to investigate the socket issues in aio.c but have found a much moire basic issue.  With my recent changes to Network that more carefully checked for errors the SocketTest&gt;&gt;testSocketReuse test appears to lock up.  In fact, the VM is fine, happily doing what it&#39;s being told by Socket&gt;&gt;#sendData:count:</div><div><br></div><div>Socket&gt;&gt;sendData: buffer count: n<div><span class="" style="white-space:pre">        </span>&quot;Send the amount of data from the given buffer&quot;</div><div><span class="" style="white-space:pre">        </span>| sent |</div><div><span class="" style="white-space:pre">        </span>sent := 0.</div><div><span class="" style="white-space:pre">        </span>[sent &lt; n] whileTrue:[</div><div><span class="" style="white-space:pre">                </span>sent := sent + (self sendSomeData: buffer startIndex: sent+1 count: (n-sent))].</div><div><br></div><div>The VM keeps trying to send data on a socket that is being reused and gets an error from sendto, answers 0 as the number of bytes sent, as required, but Socket&gt;&gt;#sendData:count: pays no heed and spins hard.  Here&#39;s the traces:</div><div><br></div><div>The test is SocketTest&gt;&gt;testSocketReuse which spawns two processes, one to send and one to receive data.  Here are the processes:</div><div><br></div><div><div>Process  0x48641f8 priority 40</div><div>0xbfec0498 M Socket&gt;sendSomeData:startIndex:count:for: 0x4864d18: a(n) Socket</div><div>0xbfec04c0 M Socket&gt;sendSomeData:startIndex:count: 0x4864d18: a(n) Socket</div><div>0xbfec04ec M Socket&gt;sendData:count: 0x4864d18: a(n) Socket</div><div>0xbfec0520 I [] in SocketTest&gt;testSocketReuse 0x4864dd0: a(n) SocketTest</div><div>0xbfec0540 I [] in BlockClosure&gt;newProcess 0x4864df0: a(n) BlockClosure</div></div><div><br></div><div><div>Process  0x6543178 priority 40</div><div>0xbfec22c8 I [] in Delay&gt;wait 0x4864ea0: a(n) Delay</div><div>0xbfec22f0 I BlockClosure&gt;ifCurtailed: 0x4864eb8: a(n) BlockClosure</div><div>0xbfec2314 I Delay&gt;wait 0x4864ea0: a(n) Delay</div><div>0xbfec2340 I [] in SocketTest&gt;testSocketReuse 0x4864dd0: a(n) SocketTest</div><div>0xbfec2360 M BlockClosure&gt;ensure: 0x4864fa8: a(n) BlockClosure</div><div>0xbfec2390 I SocketTest&gt;testSocketReuse 0x4864dd0: a(n) SocketTest</div></div><div><br></div><div><div>Process  0x4864168 priority 40</div><div>0xbfec3438 I [] in DelayWaitTimeout&gt;wait 0x48652f8: a(n) DelayWaitTimeout</div><div>0xbfec3458 M BlockClosure&gt;ensure: 0x4865378: a(n) BlockClosure</div><div>0xbfec347c I DelayWaitTimeout&gt;wait 0x48652f8: a(n) DelayWaitTimeout</div><div>0xbfec34a0 I Semaphore&gt;waitTimeoutMSecs: 0x48652e0: a(n) Semaphore</div><div>0xbfec34c4 I Socket&gt;waitForDataIfClosed: 0x4865408: a(n) Socket</div><div>0xbfec34f0 I Socket&gt;receiveDataInto:startingAt: 0x4865408: a(n) Socket</div><div>0xbfec3520 I [] in SocketTest&gt;testSocketReuse 0x4864dd0: a(n) SocketTest</div><div>0xbfec3540 I [] in BlockClosure&gt;newProcess 0x48654c0: a(n) BlockClosure</div></div><div><br></div><div>And here&#39;s the VM spinning:</div><div><div>   15726    0 sqUnixSocket.c:1128 UDP sendData(11, 16)</div><div>   15726    0 sqUnixSocket.c:1134 UDP send failed 56 Socket is already connected</div><div>   15726    0 sqUnixSocket.c:1128 UDP sendData(11, 16)</div><div>   15726    0 sqUnixSocket.c:1134 UDP send failed 56 Socket is already connected</div><div>   15726    0 sqUnixSocket.c:1128 UDP sendData(11, 16)</div><div>   15726    0 sqUnixSocket.c:1134 UDP send failed 56 Socket is already connected</div></div><div>   ...etc...</div><div><br></div><div>Ah!! Of course.  Because I have changed the default scheduling semantics in Squeak 5 to make preemption not a yield point, Socket&gt;&gt;#sendData:count:  never yields to the other processes.  Previously when the Delay process woke up this would implicitly yield the process spinning in Socket&gt;&gt;#sendData:count:.</div><div><br></div><div>So Socket&gt;&gt;#sendData:count: needs to do a yield if no data is sent.  However, shouldn&#39;t but also check for errors if no data is sent and do something like return an error if it discovers, via Socket&gt;&gt;primSocketError:, that the socket is not happy?</div><div><br></div><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>