Linux: Fix stability problem with ethernet (#1091)

- Fix a problem where mysgw stops working and consumes a lot of cpu.
- Fix bug with tcp sockets where socket descriptor wasn't being
  freed.
This commit is contained in:
Marcelo Aquino
2018-03-24 08:16:44 +01:00
committed by Mikael Falkvidd
parent 2175c993ef
commit ea6d07cb79
2 changed files with 4 additions and 9 deletions
+3 -6
View File
@@ -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;
}