Skip to content

Commit 7b9aaa5

Browse files
Merge branch 'main' into ci
2 parents e9f25bc + 4cfb603 commit 7b9aaa5

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/AsyncTCP.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ typedef enum {
8181
LWIP_TCP_ACCEPT,
8282
LWIP_TCP_CONNECTED,
8383
LWIP_TCP_DNS
84-
} lwip_event_t;
84+
} lwip_tcp_event_t;
8585

8686
typedef struct {
87-
lwip_event_t event;
87+
lwip_tcp_event_t event;
8888
void* arg;
8989
union {
9090
struct {
@@ -118,7 +118,7 @@ typedef struct {
118118
ip_addr_t addr;
119119
} dns;
120120
};
121-
} lwip_event_packet_t;
121+
} lwip_tcp_event_packet_t;
122122

123123
static QueueHandle_t _async_queue;
124124
static TaskHandle_t _async_service_task_handle = NULL;
@@ -137,23 +137,23 @@ static uint32_t _closed_index = []() {
137137

138138
static inline bool _init_async_event_queue() {
139139
if (!_async_queue) {
140-
_async_queue = xQueueCreate(CONFIG_ASYNC_TCP_QUEUE_SIZE, sizeof(lwip_event_packet_t*));
140+
_async_queue = xQueueCreate(CONFIG_ASYNC_TCP_QUEUE_SIZE, sizeof(lwip_tcp_event_packet_t*));
141141
if (!_async_queue) {
142142
return false;
143143
}
144144
}
145145
return true;
146146
}
147147

148-
static inline bool _send_async_event(lwip_event_packet_t** e, TickType_t wait = portMAX_DELAY) {
148+
static inline bool _send_async_event(lwip_tcp_event_packet_t** e, TickType_t wait = portMAX_DELAY) {
149149
return _async_queue && xQueueSend(_async_queue, e, wait) == pdPASS;
150150
}
151151

152-
static inline bool _prepend_async_event(lwip_event_packet_t** e, TickType_t wait = portMAX_DELAY) {
152+
static inline bool _prepend_async_event(lwip_tcp_event_packet_t** e, TickType_t wait = portMAX_DELAY) {
153153
return _async_queue && xQueueSendToFront(_async_queue, e, wait) == pdPASS;
154154
}
155155

156-
static inline bool _get_async_event(lwip_event_packet_t** e) {
156+
static inline bool _get_async_event(lwip_tcp_event_packet_t** e) {
157157
if (!_async_queue) {
158158
return false;
159159
}
@@ -178,7 +178,7 @@ static inline bool _get_async_event(lwip_event_packet_t** e) {
178178
It won't be effective if user would run multiple simultaneous long running callbacks due to message interleaving.
179179
todo: implement some kind of fair dequeing or (better) simply punish user for a bad designed callbacks by resetting hog connections
180180
*/
181-
lwip_event_packet_t* next_pkt = NULL;
181+
lwip_tcp_event_packet_t* next_pkt = NULL;
182182
while (xQueuePeek(_async_queue, &next_pkt, 0) == pdPASS) {
183183
if (next_pkt->arg == (*e)->arg && next_pkt->event == LWIP_TCP_POLL) {
184184
if (xQueueReceive(_async_queue, &next_pkt, 0) == pdPASS) {
@@ -219,8 +219,8 @@ static bool _remove_events_with_arg(void* arg) {
219219
return false;
220220
}
221221

222-
lwip_event_packet_t* first_packet = NULL;
223-
lwip_event_packet_t* packet = NULL;
222+
lwip_tcp_event_packet_t* first_packet = NULL;
223+
lwip_tcp_event_packet_t* packet = NULL;
224224

225225
// figure out which is the first non-matching packet so we can keep the order
226226
while (!first_packet) {
@@ -261,7 +261,7 @@ static bool _remove_events_with_arg(void* arg) {
261261
return true;
262262
}
263263

264-
static void _handle_async_event(lwip_event_packet_t* e) {
264+
static void _handle_async_event(lwip_tcp_event_packet_t* e) {
265265
if (e->arg == NULL) {
266266
// do nothing when arg is NULL
267267
// ets_printf("event arg == NULL: 0x%08x\n", e->recv.pcb);
@@ -301,7 +301,7 @@ static void _async_service_task(void* pvParameters) {
301301
log_w("Failed to add async task to WDT");
302302
}
303303
#endif
304-
lwip_event_packet_t* packet = NULL;
304+
lwip_tcp_event_packet_t* packet = NULL;
305305
for (;;) {
306306
if (_get_async_event(&packet)) {
307307
_handle_async_event(packet);
@@ -362,7 +362,7 @@ static bool _start_async_task() {
362362
* */
363363

364364
static int8_t _tcp_clear_events(void* arg) {
365-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
365+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
366366
e->event = LWIP_TCP_CLEAR;
367367
e->arg = arg;
368368
if (!_prepend_async_event(&e)) {
@@ -373,7 +373,7 @@ static int8_t _tcp_clear_events(void* arg) {
373373

374374
static int8_t _tcp_connected(void* arg, tcp_pcb* pcb, int8_t err) {
375375
// ets_printf("+C: 0x%08x\n", pcb);
376-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
376+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
377377
e->event = LWIP_TCP_CONNECTED;
378378
e->arg = arg;
379379
e->connected.pcb = pcb;
@@ -393,7 +393,7 @@ static int8_t _tcp_poll(void* arg, struct tcp_pcb* pcb) {
393393
}
394394

395395
// ets_printf("+P: 0x%08x\n", pcb);
396-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
396+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
397397
e->event = LWIP_TCP_POLL;
398398
e->arg = arg;
399399
e->poll.pcb = pcb;
@@ -405,7 +405,7 @@ static int8_t _tcp_poll(void* arg, struct tcp_pcb* pcb) {
405405
}
406406

407407
static int8_t _tcp_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* pb, int8_t err) {
408-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
408+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
409409
e->arg = arg;
410410
if (pb) {
411411
// ets_printf("+R: 0x%08x\n", pcb);
@@ -429,7 +429,7 @@ static int8_t _tcp_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* pb, int8_t
429429

430430
static int8_t _tcp_sent(void* arg, struct tcp_pcb* pcb, uint16_t len) {
431431
// ets_printf("+S: 0x%08x\n", pcb);
432-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
432+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
433433
e->event = LWIP_TCP_SENT;
434434
e->arg = arg;
435435
e->sent.pcb = pcb;
@@ -442,7 +442,7 @@ static int8_t _tcp_sent(void* arg, struct tcp_pcb* pcb, uint16_t len) {
442442

443443
static void _tcp_error(void* arg, int8_t err) {
444444
// ets_printf("+E: 0x%08x\n", arg);
445-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
445+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
446446
e->event = LWIP_TCP_ERROR;
447447
e->arg = arg;
448448
e->error.err = err;
@@ -452,7 +452,7 @@ static void _tcp_error(void* arg, int8_t err) {
452452
}
453453

454454
static void _tcp_dns_found(const char* name, struct ip_addr* ipaddr, void* arg) {
455-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
455+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
456456
// ets_printf("+DNS: name=%s ipaddr=0x%08x arg=%x\n", name, ipaddr, arg);
457457
e->event = LWIP_TCP_DNS;
458458
e->arg = arg;
@@ -469,7 +469,7 @@ static void _tcp_dns_found(const char* name, struct ip_addr* ipaddr, void* arg)
469469

470470
// Used to switch out from LwIP thread
471471
static int8_t _tcp_accept(void* arg, AsyncClient* client) {
472-
lwip_event_packet_t* e = (lwip_event_packet_t*)malloc(sizeof(lwip_event_packet_t));
472+
lwip_tcp_event_packet_t* e = (lwip_tcp_event_packet_t*)malloc(sizeof(lwip_tcp_event_packet_t));
473473
e->event = LWIP_TCP_ACCEPT;
474474
e->arg = arg;
475475
e->accept.client = client;

0 commit comments

Comments
 (0)