Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit b0e8d56

Browse files
committed
Attempt to deal with MSS lower than 1460 along the network path
1 parent e074eaa commit b0e8d56

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/ESPAsyncTCP.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ AsyncClient::AsyncClient(tcp_pcb* pcb):
5959
, _pcb_sent_at(0)
6060
, _close_pcb(false)
6161
, _ack_pcb(true)
62+
, _tx_unacked_len(0)
63+
, _tx_acked_len(0)
64+
, _tx_unsent_len(0)
6265
, _rx_last_packet(0)
6366
, _rx_since_timeout(0)
6467
, _ack_timeout(ASYNC_MAX_ACK_TIME)
@@ -234,8 +237,10 @@ size_t AsyncClient::add(const char* data, size_t size, uint8_t apiflags) {
234237
#if ASYNC_TCP_SSL_ENABLED
235238
if(_pcb_secure){
236239
int sent = tcp_ssl_write(_pcb, (uint8_t*)data, size);
237-
if(sent >= 0)
240+
if(sent >= 0){
241+
_tx_unacked_len += sent;
238242
return sent;
243+
}
239244
_close();
240245
return 0;
241246
}
@@ -244,6 +249,7 @@ size_t AsyncClient::add(const char* data, size_t size, uint8_t apiflags) {
244249
int8_t err = tcp_write(_pcb, data, will_send, apiflags);
245250
if(err != ERR_OK)
246251
return 0;
252+
_tx_unsent_len += will_send;
247253
return will_send;
248254
}
249255

@@ -255,8 +261,11 @@ bool AsyncClient::send(){
255261
if(tcp_output(_pcb) == ERR_OK){
256262
_pcb_busy = true;
257263
_pcb_sent_at = millis();
264+
_tx_unacked_len += _tx_unsent_len;
265+
_tx_unsent_len = 0;
258266
return true;
259267
}
268+
_tx_unsent_len = 0;
260269
return false;
261270
}
262271

@@ -354,9 +363,14 @@ void AsyncClient::_ssl_error(int8_t err){
354363
int8_t AsyncClient::_sent(tcp_pcb* pcb, uint16_t len) {
355364
_rx_last_packet = millis();
356365
ASYNC_TCP_DEBUG("_sent: %u\n", len);
357-
_pcb_busy = false;
358-
if(_sent_cb)
359-
_sent_cb(_sent_cb_arg, this, len, (millis() - _pcb_sent_at));
366+
_tx_unacked_len -= len;
367+
_tx_acked_len += len;
368+
if(_tx_unacked_len == 0){
369+
_pcb_busy = false;
370+
if(_sent_cb)
371+
_sent_cb(_sent_cb_arg, this, _tx_acked_len, (millis() - _pcb_sent_at));
372+
_tx_acked_len = 0;
373+
}
360374
return ERR_OK;
361375
}
362376

src/ESPAsyncTCP.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class AsyncClient {
7474
uint32_t _pcb_sent_at;
7575
bool _close_pcb;
7676
bool _ack_pcb;
77+
uint32_t _tx_unacked_len;
78+
uint32_t _tx_acked_len;
79+
uint32_t _tx_unsent_len;
7780
uint32_t _rx_ack_len;
7881
uint32_t _rx_last_packet;
7982
uint32_t _rx_since_timeout;

0 commit comments

Comments
 (0)