1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

WiFiClient: apply write timeout to single chunk (#3273)

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.
This commit is contained in:
Ivan Grokhotkov 2017-05-22 20:08:16 +08:00
parent f6d232f1ac
commit d6f1f0d5d7

View File

@ -353,9 +353,14 @@ protected:
_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;
@ -368,10 +373,10 @@ protected:
return _written;
}
void _write_some()
bool _write_some()
{
if (!_datasource || !_pcb) {
return;
return false;
}
size_t left = _datasource->available();
@ -403,7 +408,9 @@ protected:
}
if( need_output ) {
tcp_output(_pcb);
return true;
}
return false;
}
void _write_some_from_cb()