mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-21 21:22:31 +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:
@ -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()
|
||||
|
Reference in New Issue
Block a user