Skip to content

Commit d6f1f0d

Browse files
committed
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.
1 parent f6d232f commit d6f1f0d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

libraries/ESP8266WiFi/src/include/ClientContext.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,14 @@ class ClientContext
353353
_written = 0;
354354
_op_start_time = millis();
355355
do {
356-
_write_some();
356+
if (_write_some()) {
357+
_op_start_time = millis();
358+
}
357359

358360
if (!_datasource->available() || _is_timeout() || state() == CLOSED) {
361+
if (_is_timeout()) {
362+
DEBUGV(":wtmo\r\n");
363+
}
359364
delete _datasource;
360365
_datasource = nullptr;
361366
break;
@@ -368,10 +373,10 @@ class ClientContext
368373
return _written;
369374
}
370375

371-
void _write_some()
376+
bool _write_some()
372377
{
373378
if (!_datasource || !_pcb) {
374-
return;
379+
return false;
375380
}
376381

377382
size_t left = _datasource->available();
@@ -403,7 +408,9 @@ class ClientContext
403408
}
404409
if( need_output ) {
405410
tcp_output(_pcb);
411+
return true;
406412
}
413+
return false;
407414
}
408415

409416
void _write_some_from_cb()

0 commit comments

Comments
 (0)