Skip to content
Permalink
Browse files

Linux: Fix stability problem with ethernet (2)

Fix bug with tcp sockets where socket descriptor wasn't being freed.
  • Loading branch information...
marceloaqno committed Mar 11, 2018
1 parent ca8865d commit a40d4441b7460225100398ff6f2581c2b0df36ea
Showing with 3 additions and 6 deletions.
  1. +3 −6 drivers/Linux/EthernetClient.cpp
@@ -220,9 +220,8 @@ void EthernetClient::stop()
gettimeofday(&startTime, NULL);

// wait up to a second for the connection to close
uint8_t s;
do {
s = status();
uint8_t s = status();
if (s == ETHERNETCLIENT_W5100_CLOSED) {
break; // exit the loop
}
@@ -231,10 +230,8 @@ void EthernetClient::stop()
} while (((curTime.tv_sec - startTime.tv_sec) * 1000000) + (curTime.tv_usec - startTime.tv_usec) <
1000000);

// if it hasn't closed, close it forcefully
if (s != ETHERNETCLIENT_W5100_CLOSED) {
::close(_sock);
}
// free up the socket descriptor
::close(_sock);
_sock = -1;
}

0 comments on commit a40d444

Please sign in to comment.
You can’t perform that action at this time.