Pages: [1]   Go Down
Author Topic: Bug in Ethernet/Server.cpp  (Read 463 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's a bug in Ethernet/Server.cpp that causes very short client connections to be missed, which in turn leaves the connection state around and eventually preventing new connections from being established.

This is the patch:

[size=12]--- Server.cpp# 2010-09-03 16:43:28.000000000 -0700
+++ Server.cpp  2010-09-07 00:50:54.000000000 -0700
@@ -55,7 +55,8 @@
   for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
     Client client(sock);
     if (EthernetClass::_server_port[sock] == _port &&
-      client.status() == SnSR::ESTABLISHED) {
+        (client.status() == SnSR::ESTABLISHED ||
+         client.status() == SnSR::CLOSE_WAIT)) {
       if (client.available()) {
         // XXX: don't always pick the lowest numbered socket.
         return client;[/size]

What happens is that if a client connects, sends a small amount of data, and disconnects all before Server::available() is called, then client.status() is left in CLOSE_WAIT and available() never returns the connection.

Also, I think a client that connects and disconnects without sending any data should also be recognized as a valid connection.  After all, no data is also information.  I'll look into a fix (in both accept() and available()), but that one is an incompatible change (such connections are currently ignored so existing programs may not be equipped to handle it), so I'm not sure it's a good idea to do now.

Pages: [1]   Go Up
Jump to: