<div dir="ltr"><div>Hi,</div><div><br></div><div>After converting an application to  socket.erl in OTP 22.1, the test suites started to fail with random timeouts. It took me a while to figure out that gen_server:calls arrived multiple seconds late in the server.</div><div><br></div><div>I have a demonstration at <a href="https://gist.github.com/RoadRunnr/311a7679fff6fbdf367c455b960f1ba8">https://gist.github.com/RoadRunnr/311a7679fff6fbdf367c455b960f1ba8</a>. It implements a simple UDP echo server with socket.erl. The client uses gen_udp to send messages and wait for the response.</div><div>The client also sends Erlang ping message to the server and expects to get a pong answer back. The socket.erl based server is supposed to not block (and as far as I can tell, it does not), it therefore should be able to answer the Erlang ping message all the time.</div><div>There are also some simple busy loop process running to get some load. Without them the problem is not reproducible.</div><div><br></div><div>The sample is failing in about 20% off the test runs, when it does the output is something like:</div><div><br></div><div><font face="monospace">$ ~/stest.escript<br></font></div><div><font face="monospace">Server Pid <0.78.0><br>Server Addr #{addr => {127,0,0,1},family => inet,port => 38959}<br>ping timeout<br>           round trip    Clnt/Srvr    Srvr/Clnt     ProcPing<br></font></div><div><font face="monospace">...</font></div><div><font face="monospace">      85: ******** ns, ******** ns,    57675 ns,    42332 ns<br></font></div><div><font face="monospace">...</font></div><div><br></div><div>The failure happens because a 'ping' message is not see in time by the receive clause in the server process. It seems that either the process is not scheduled for some time (multiple seconds), or the scanning of the mailbox is missing the message.</div><div><div><br></div><div>I have ruled out that the UDP messages are being dropped, otherwise the clients gen_udp:recv would never return.</div><div><br></div></div><div>Does anyone have a clue what might cause this? Or point out where my sample is broken.</div><div><br></div><div>Many thanks</div><div>Andreas</div><div><br></div><font face="arial, sans-serif">-- <br></font><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><p><span style="font-size:10pt"><font face="arial, sans-serif">Andreas Schultz</font></span></p>
<p><font face="arial, sans-serif"> </font></p></div></div>