Skip to content

Commit

Permalink
WiFiClient: apply write timeout to single chunk (#3273)
Browse files Browse the repository at this point in the history
WiFiClient write timeouts introduced in #3257 applied to the whole write
operation, which could take long time if data size was large. This
change makes the timeout happen per chunk. Timeout now happens if no
data has been delivered within a given interval.
  • Loading branch information
igrr committed May 22, 2017
1 parent f6d232f commit d6f1f0d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libraries/ESP8266WiFi/src/include/ClientContext.h
Expand Up @@ -353,9 +353,14 @@ class ClientContext
_written = 0;
_op_start_time = millis();
do {
_write_some();
if (_write_some()) {
_op_start_time = millis();
}

if (!_datasource->available() || _is_timeout() || state() == CLOSED) {
if (_is_timeout()) {
DEBUGV(":wtmo\r\n");
}
delete _datasource;
_datasource = nullptr;
break;
Expand All @@ -368,10 +373,10 @@ class ClientContext
return _written;
}

void _write_some()
bool _write_some()
{
if (!_datasource || !_pcb) {
return;
return false;
}

size_t left = _datasource->available();
Expand Down Expand Up @@ -403,7 +408,9 @@ class ClientContext
}
if( need_output ) {
tcp_output(_pcb);
return true;
}
return false;
}

void _write_some_from_cb()
Expand Down

0 comments on commit d6f1f0d

Please sign in to comment.