From 291b321e6241898fbb5b087972d775f61598a7e8 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Wed, 4 Sep 2019 01:22:56 +0200 Subject: [PATCH] ClientContext: restore use of two different pending booleans for connect and write #6483 --- .../ESP8266WiFi/src/include/ClientContext.h | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index 2fd3b8dca..abbb20e81 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -128,14 +128,14 @@ public: if (err != ERR_OK) { return 0; } - _delaying = true; + _connect_pending = true; _op_start_time = millis(); // Following delay will be interrupted by connect callback - for (decltype(_timeout_ms) i = 0; _delaying && i < _timeout_ms; i++) { + for (decltype(_timeout_ms) i = 0; _connect_pending && i < _timeout_ms; i++) { // Give scheduled functions a chance to run (e.g. Ethernet uses recurrent) delay(1); } - _delaying = false; + _connect_pending = false; if (!_pcb) { DEBUGV(":cabrt\r\n"); return 0; @@ -432,8 +432,9 @@ protected: void _notify_error() { - if (_delaying) { - _delaying = false; + if (_connect_pending || _send_waiting) { + _send_waiting = false; + _connect_pending = false; esp_schedule(); // break current delay() } } @@ -441,7 +442,7 @@ protected: size_t _write_from_source(DataSource* ds) { assert(_datasource == nullptr); - assert(!_delaying); + assert(!_send_waiting); _datasource = ds; _written = 0; _op_start_time = millis(); @@ -459,13 +460,13 @@ protected: break; } - _delaying = true; + _send_waiting = true; // Following delay will be interrupted by on next received ack - for (decltype(_timeout_ms) i = 0; _delaying && i < _timeout_ms; i++) { + for (decltype(_timeout_ms) i = 0; _send_waiting && i < _timeout_ms; i++) { // Give scheduled functions a chance to run (e.g. Ethernet uses recurrent) delay(1); } - _delaying = false; + _send_waiting = false; } while(true); if (_sync) @@ -533,8 +534,8 @@ protected: void _write_some_from_cb() { - if (_delaying) { - _delaying = false; + if (_send_waiting) { + _send_waiting = false; esp_schedule(); // break current delay() } } @@ -609,8 +610,8 @@ protected: (void) err; (void) pcb; assert(pcb == _pcb); - if (_delaying) { - _delaying = false; + if (_connect_pending) { + _connect_pending = false; esp_schedule(); // break current delay() } return ERR_OK; @@ -660,7 +661,8 @@ private: size_t _written = 0; uint32_t _timeout_ms = 5000; uint32_t _op_start_time = 0; - bool _delaying = false; + bool _send_waiting = false; + bool _connect_pending = false; int8_t _refcnt; ClientContext* _next;