Skip to content

Commit 912c0db

Browse files
sislakdd-a-v
authored andcommitted
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
1 parent 2b7846d commit 912c0db

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ void WiFiClientSecure::_freeSSL() {
248248
_recvapp_len = 0;
249249
// This connection is toast
250250
_handshake_done = false;
251+
_timeout = 15000;
251252
}
252253

253254
bool WiFiClientSecure::_clientConnected() {
@@ -1009,6 +1010,9 @@ bool WiFiClientSecure::_connectSSL(const char* hostName) {
10091010
_x509_insecure = nullptr;
10101011
_x509_knownkey = nullptr;
10111012

1013+
// reduce timeout after successful handshake to fail fast if server stop accepting our data for whathever reason
1014+
if (ret) _timeout = 5000;
1015+
10121016
return ret;
10131017
}
10141018

libraries/ESP8266WiFi/src/include/ClientContext.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ class ClientContext
456456
}
457457

458458
_send_waiting = true;
459-
esp_yield();
459+
// This delay will be interrupted by esp_schedule on next received ack
460+
delay(_timeout_ms);
460461
} while(true);
461462
_send_waiting = false;
462463

0 commit comments

Comments
 (0)