Skip to content

Commit 291b321

Browse files
authored
ClientContext: restore use of two different pending booleans for connect and write #6483
1 parent 07d8128 commit 291b321

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

Diff for: libraries/ESP8266WiFi/src/include/ClientContext.h

+16-14
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ class ClientContext
128128
if (err != ERR_OK) {
129129
return 0;
130130
}
131-
_delaying = true;
131+
_connect_pending = true;
132132
_op_start_time = millis();
133133
// Following delay will be interrupted by connect callback
134-
for (decltype(_timeout_ms) i = 0; _delaying && i < _timeout_ms; i++) {
134+
for (decltype(_timeout_ms) i = 0; _connect_pending && i < _timeout_ms; i++) {
135135
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
136136
delay(1);
137137
}
138-
_delaying = false;
138+
_connect_pending = false;
139139
if (!_pcb) {
140140
DEBUGV(":cabrt\r\n");
141141
return 0;
@@ -432,16 +432,17 @@ class ClientContext
432432

433433
void _notify_error()
434434
{
435-
if (_delaying) {
436-
_delaying = false;
435+
if (_connect_pending || _send_waiting) {
436+
_send_waiting = false;
437+
_connect_pending = false;
437438
esp_schedule(); // break current delay()
438439
}
439440
}
440441

441442
size_t _write_from_source(DataSource* ds)
442443
{
443444
assert(_datasource == nullptr);
444-
assert(!_delaying);
445+
assert(!_send_waiting);
445446
_datasource = ds;
446447
_written = 0;
447448
_op_start_time = millis();
@@ -459,13 +460,13 @@ class ClientContext
459460
break;
460461
}
461462

462-
_delaying = true;
463+
_send_waiting = true;
463464
// Following delay will be interrupted by on next received ack
464-
for (decltype(_timeout_ms) i = 0; _delaying && i < _timeout_ms; i++) {
465+
for (decltype(_timeout_ms) i = 0; _send_waiting && i < _timeout_ms; i++) {
465466
// Give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
466467
delay(1);
467468
}
468-
_delaying = false;
469+
_send_waiting = false;
469470
} while(true);
470471

471472
if (_sync)
@@ -533,8 +534,8 @@ class ClientContext
533534

534535
void _write_some_from_cb()
535536
{
536-
if (_delaying) {
537-
_delaying = false;
537+
if (_send_waiting) {
538+
_send_waiting = false;
538539
esp_schedule(); // break current delay()
539540
}
540541
}
@@ -609,8 +610,8 @@ class ClientContext
609610
(void) err;
610611
(void) pcb;
611612
assert(pcb == _pcb);
612-
if (_delaying) {
613-
_delaying = false;
613+
if (_connect_pending) {
614+
_connect_pending = false;
614615
esp_schedule(); // break current delay()
615616
}
616617
return ERR_OK;
@@ -660,7 +661,8 @@ class ClientContext
660661
size_t _written = 0;
661662
uint32_t _timeout_ms = 5000;
662663
uint32_t _op_start_time = 0;
663-
bool _delaying = false;
664+
bool _send_waiting = false;
665+
bool _connect_pending = false;
664666

665667
int8_t _refcnt;
666668
ClientContext* _next;

0 commit comments

Comments
 (0)