From 25c95ac185ab08f9c166e58b7e3f26ca440743f1 Mon Sep 17 00:00:00 2001 From: Dave <47106837+sislakd@users.noreply.github.com> Date: Fri, 17 May 2019 00:00:12 +0200 Subject: [PATCH] Bugfix for stuck in write method of WiFiClient and WiFiClientSecure until the remote peer closed connection (#6104) * Bugfix - write method of WiFiClient and WiFiClientSecure can stuck forever * Adjustment of uint8_t to bool to have it clear flag --- libraries/ESP8266WiFi/src/include/ClientContext.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index 5be690f24..0126621a6 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -437,7 +437,7 @@ protected: size_t _write_from_source(DataSource* ds) { assert(_datasource == nullptr); - assert(_send_waiting == 0); + assert(!_send_waiting); _datasource = ds; _written = 0; _op_start_time = millis(); @@ -455,10 +455,10 @@ protected: break; } - ++_send_waiting; + _send_waiting = true; esp_yield(); } while(true); - _send_waiting = 0; + _send_waiting = false; if (_sync) wait_until_sent(); @@ -525,8 +525,8 @@ protected: void _write_some_from_cb() { - if (_send_waiting == 1) { - _send_waiting--; + if (_send_waiting) { + _send_waiting = false; esp_schedule(); } } @@ -650,7 +650,7 @@ private: size_t _written = 0; uint32_t _timeout_ms = 5000; uint32_t _op_start_time = 0; - uint8_t _send_waiting = 0; + bool _send_waiting = false; uint8_t _connect_pending = 0; int8_t _refcnt;