Skip to content

Commit 8521c8f

Browse files
committed
Set default wait time to 0 (no wait) to enqueue tcp events
1 parent d558f88 commit 8521c8f

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ I personally use the following configuration in my projects:
4444
```c++
4545
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000 // (keep default)
4646
-D CONFIG_ASYNC_TCP_PRIORITY=10 // (keep default)
47-
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=64 // (keep default)
47+
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=128 // (keep default)
4848
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1 // force async_tcp task to be on same core as the app (default is core 0)
4949
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096 // reduce the stack size (default is 16K)
5050
```

platformio.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build_flags =
99
-Wall -Wextra
1010
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000
1111
-D CONFIG_ASYNC_TCP_PRIORITY=10
12-
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=64
12+
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
1313
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1
1414
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
1515
-D CONFIG_ARDUHAL_LOG_COLORS

src/AsyncTCP.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ static inline bool _init_async_event_queue() {
128128
return true;
129129
}
130130

131-
static inline bool _send_async_event(lwip_tcp_event_packet_t **e, TickType_t wait = portMAX_DELAY) {
131+
static inline bool _send_async_event(lwip_tcp_event_packet_t **e, TickType_t wait = 0) {
132132
return _async_queue && xQueueSend(_async_queue, e, wait) == pdPASS;
133133
}
134134

135-
static inline bool _prepend_async_event(lwip_tcp_event_packet_t **e, TickType_t wait = portMAX_DELAY) {
135+
static inline bool _prepend_async_event(lwip_tcp_event_packet_t **e, TickType_t wait = 0) {
136136
return _async_queue && xQueueSendToFront(_async_queue, e, wait) == pdPASS;
137137
}
138138

@@ -376,6 +376,7 @@ static int8_t _tcp_connected(void *arg, tcp_pcb *pcb, int8_t err) {
376376
if (!_prepend_async_event(&e)) {
377377
free((void *)(e));
378378
log_e("Failed to queue event: LWIP_TCP_CONNECTED");
379+
tcp_abort(pcb);
379380
return ERR_TIMEOUT;
380381
}
381382
return ERR_OK;
@@ -402,6 +403,7 @@ static int8_t _tcp_poll(void *arg, struct tcp_pcb *pcb) {
402403
if (!_send_async_event(&e, 0)) {
403404
free((void *)(e));
404405
log_e("Failed to queue event: LWIP_TCP_POLL");
406+
tcp_abort(pcb);
405407
return ERR_TIMEOUT;
406408
}
407409
return ERR_OK;
@@ -431,6 +433,7 @@ static int8_t _tcp_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *pb, int8_t
431433
if (!_send_async_event(&e)) {
432434
free((void *)(e));
433435
log_e("Failed to queue event: LWIP_TCP_RECV or LWIP_TCP_FIN");
436+
tcp_abort(pcb);
434437
return ERR_TIMEOUT;
435438
}
436439
return ERR_OK;
@@ -450,6 +453,7 @@ static int8_t _tcp_sent(void *arg, struct tcp_pcb *pcb, uint16_t len) {
450453
if (!_send_async_event(&e)) {
451454
free((void *)(e));
452455
log_e("Failed to queue event: LWIP_TCP_SENT");
456+
tcp_abort(pcb);
453457
return ERR_TIMEOUT;
454458
}
455459
return ERR_OK;
@@ -505,6 +509,7 @@ static int8_t _tcp_accept(void *arg, AsyncClient *client) {
505509
if (!_prepend_async_event(&e)) {
506510
free((void *)(e));
507511
log_e("Failed to queue event: LWIP_TCP_ACCEPT");
512+
client->abort();
508513
return ERR_TIMEOUT;
509514
}
510515
return ERR_OK;

src/AsyncTCP.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern "C" {
4848
#endif
4949

5050
#ifndef CONFIG_ASYNC_TCP_QUEUE_SIZE
51-
#define CONFIG_ASYNC_TCP_QUEUE_SIZE 64
51+
#define CONFIG_ASYNC_TCP_QUEUE_SIZE 128
5252
#endif
5353

5454
#ifndef CONFIG_ASYNC_TCP_MAX_ACK_TIME

0 commit comments

Comments
 (0)