Skip to content

ClientContext: restore use of two different pending booleans for connect and write #6483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions libraries/ESP8266WiFi/src/include/ClientContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ class ClientContext
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;
Expand Down Expand Up @@ -432,16 +432,17 @@ class ClientContext

void _notify_error()
{
if (_delaying) {
_delaying = false;
if (_connect_pending || _send_waiting) {
_send_waiting = false;
_connect_pending = false;
esp_schedule(); // break current delay()
}
}

size_t _write_from_source(DataSource* ds)
{
assert(_datasource == nullptr);
assert(!_delaying);
assert(!_send_waiting);
_datasource = ds;
_written = 0;
_op_start_time = millis();
Expand All @@ -459,13 +460,13 @@ class ClientContext
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)
Expand Down Expand Up @@ -533,8 +534,8 @@ class ClientContext

void _write_some_from_cb()
{
if (_delaying) {
_delaying = false;
if (_send_waiting) {
_send_waiting = false;
esp_schedule(); // break current delay()
}
}
Expand Down Expand Up @@ -609,8 +610,8 @@ class ClientContext
(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;
Expand Down Expand Up @@ -660,7 +661,8 @@ class ClientContext
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;
Expand Down