mirror of
https://github.com/eledio-devices/thirdparty-AsyncTCPSock.git
synced 2025-10-30 16:15:40 +01:00
Only process ACK timeout if buffer has not been fully written
Otherwise a buffer queued past _ack that has been fully written yet not removed from the queue risks triggering an incorrect timeout event. This has caused incomplete file downloads with ESPAsyncWebServer.
This commit is contained in:
@@ -730,14 +730,16 @@ void AsyncClient::_sockPoll(void)
|
||||
|
||||
// ACK Timeout - simulated by write queue staleness
|
||||
xSemaphoreTake(_write_mutex, (TickType_t)portMAX_DELAY);
|
||||
uint32_t sent_delay = now - _writeQueue.front().queued_at;
|
||||
if (_writeQueue.size() > 0 && !_ack_timeout_signaled && _ack_timeout && sent_delay >= _ack_timeout) {
|
||||
_ack_timeout_signaled = true;
|
||||
//log_w("ack timeout %d", pcb->state);
|
||||
xSemaphoreGive(_write_mutex);
|
||||
if(_timeout_cb)
|
||||
_timeout_cb(_timeout_cb_arg, this, sent_delay);
|
||||
return;
|
||||
if (_writeQueue.size() > 0 && !_ack_timeout_signaled && _ack_timeout) {
|
||||
uint32_t sent_delay = now - _writeQueue.front().queued_at;
|
||||
if (sent_delay >= _ack_timeout && _writeQueue.front().written_at == 0) {
|
||||
_ack_timeout_signaled = true;
|
||||
//log_w("ack timeout %d", pcb->state);
|
||||
xSemaphoreGive(_write_mutex);
|
||||
if(_timeout_cb)
|
||||
_timeout_cb(_timeout_cb_arg, this, sent_delay);
|
||||
return;
|
||||
}
|
||||
}
|
||||
xSemaphoreGive(_write_mutex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user