Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more logs to warn about problematic queue size #24

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/AsyncTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ static int8_t _tcp_clear_events(void *arg) {
e->arg = arg;
if (!_prepend_async_event(&e)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_CLEAR");
return ERR_TIMEOUT;
}
return ERR_OK;
Expand All @@ -374,6 +375,7 @@ static int8_t _tcp_connected(void *arg, tcp_pcb *pcb, int8_t err) {
e->connected.err = err;
if (!_prepend_async_event(&e)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_CONNECTED");
return ERR_TIMEOUT;
}
return ERR_OK;
Expand All @@ -399,6 +401,7 @@ static int8_t _tcp_poll(void *arg, struct tcp_pcb *pcb) {
// poll events are not critical 'cause those are repetitive, so we may not wait the queue in any case
if (!_send_async_event(&e, 0)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_POLL");
return ERR_TIMEOUT;
}
return ERR_OK;
Expand Down Expand Up @@ -427,6 +430,7 @@ static int8_t _tcp_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *pb, int8_t
}
if (!_send_async_event(&e)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_RECV or LWIP_TCP_FIN");
return ERR_TIMEOUT;
}
return ERR_OK;
Expand All @@ -445,6 +449,7 @@ static int8_t _tcp_sent(void *arg, struct tcp_pcb *pcb, uint16_t len) {
e->sent.len = len;
if (!_send_async_event(&e)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_SENT");
return ERR_TIMEOUT;
}
return ERR_OK;
Expand All @@ -462,6 +467,7 @@ static void _tcp_error(void *arg, int8_t err) {
e->error.err = err;
if (!_send_async_event(&e)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_ERROR");
}
}

Expand All @@ -482,6 +488,7 @@ static void _tcp_dns_found(const char *name, struct ip_addr *ipaddr, void *arg)
}
if (!_send_async_event(&e)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_DNS");
}
}

Expand All @@ -497,6 +504,7 @@ static int8_t _tcp_accept(void *arg, AsyncClient *client) {
e->accept.client = client;
if (!_prepend_async_event(&e)) {
free((void *)(e));
log_e("Failed to queue event: LWIP_TCP_ACCEPT");
return ERR_TIMEOUT;
}
return ERR_OK;
Expand Down Expand Up @@ -538,6 +546,8 @@ static err_t _tcp_output_api(struct tcpip_api_call_data *api_call_msg) {
msg->err = ERR_CONN;
if (msg->closed_slot == INVALID_CLOSED_SLOT || !_closed_slots[msg->closed_slot]) {
msg->err = tcp_output(msg->pcb);
} else {
log_e("pcb was closed before reaching LwIP task");
}
return msg->err;
}
Expand All @@ -558,6 +568,8 @@ static err_t _tcp_write_api(struct tcpip_api_call_data *api_call_msg) {
msg->err = ERR_CONN;
if (msg->closed_slot == INVALID_CLOSED_SLOT || !_closed_slots[msg->closed_slot]) {
msg->err = tcp_write(msg->pcb, msg->write.data, msg->write.size, msg->write.apiflags);
} else {
log_e("pcb was closed before reaching LwIP task");
}
return msg->err;
}
Expand All @@ -584,6 +596,8 @@ static err_t _tcp_recved_api(struct tcpip_api_call_data *api_call_msg) {
// if(msg->closed_slot != INVALID_CLOSED_SLOT) {
msg->err = 0;
tcp_recved(msg->pcb, msg->received);
} else {
log_e("pcb was closed before reaching LwIP task");
}
return msg->err;
}
Expand All @@ -605,6 +619,8 @@ static err_t _tcp_close_api(struct tcpip_api_call_data *api_call_msg) {
msg->err = ERR_CONN;
if (msg->closed_slot == INVALID_CLOSED_SLOT || !_closed_slots[msg->closed_slot]) {
msg->err = tcp_close(msg->pcb);
} else {
log_e("pcb was closed before reaching LwIP task");
}
return msg->err;
}
Expand All @@ -625,6 +641,8 @@ static err_t _tcp_abort_api(struct tcpip_api_call_data *api_call_msg) {
msg->err = ERR_CONN;
if (msg->closed_slot == INVALID_CLOSED_SLOT || !_closed_slots[msg->closed_slot]) {
tcp_abort(msg->pcb);
} else {
log_e("pcb was closed before reaching LwIP task");
}
return msg->err;
}
Expand Down