1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-25 20:02:37 +03:00

Remove deadlock when server is not acking our data (#6107)

* Use bounded waiting instead of infinite one to avoid deadlock

* Reduce timeout to fail much sooner if server is not acking our data

* Return timeout to 15 seconds on every disconnect

* Add comment to introduced delay to make it super clear
This commit is contained in:
Dave 2019-05-19 22:38:24 +02:00 committed by david gauchard
parent 2b7846da5a
commit 912c0db091
2 changed files with 6 additions and 1 deletions

View File

@ -248,6 +248,7 @@ void WiFiClientSecure::_freeSSL() {
_recvapp_len = 0; _recvapp_len = 0;
// This connection is toast // This connection is toast
_handshake_done = false; _handshake_done = false;
_timeout = 15000;
} }
bool WiFiClientSecure::_clientConnected() { bool WiFiClientSecure::_clientConnected() {
@ -1009,6 +1010,9 @@ bool WiFiClientSecure::_connectSSL(const char* hostName) {
_x509_insecure = nullptr; _x509_insecure = nullptr;
_x509_knownkey = nullptr; _x509_knownkey = nullptr;
// reduce timeout after successful handshake to fail fast if server stop accepting our data for whathever reason
if (ret) _timeout = 5000;
return ret; return ret;
} }

View File

@ -456,7 +456,8 @@ protected:
} }
_send_waiting = true; _send_waiting = true;
esp_yield(); // This delay will be interrupted by esp_schedule on next received ack
delay(_timeout_ms);
} while(true); } while(true);
_send_waiting = false; _send_waiting = false;