Skip to content

Commit

Permalink
Linux: Fix stability problem with ethernet (2)
Browse files Browse the repository at this point in the history
Fix bug with tcp sockets where socket descriptor wasn't being freed.
  • Loading branch information
marceloaqno committed Mar 11, 2018
1 parent ca8865d commit a40d444
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/Linux/EthernetClient.cpp
Expand Up @@ -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
}
Expand All @@ -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;
}

Expand Down

0 comments on commit a40d444

Please sign in to comment.