mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-08-13 05:28:00 +00:00
api_msg: fix tcp_abort thread safety (2.1.2-esp)
As this tcp_abort could be directly called by application thread without
locking the TCP/TP core.
Original commit 10197b212a
This commit is contained in:
@@ -851,6 +851,20 @@ netconn_free(struct netconn *conn)
|
||||
memp_free(MEMP_NETCONN, conn);
|
||||
}
|
||||
|
||||
#if ESP_LWIP
|
||||
struct tcp_psb_msg {
|
||||
struct tcpip_api_call_data call;
|
||||
struct tcp_pcb *pcb;
|
||||
};
|
||||
|
||||
static err_t tcp_do_abort(struct tcpip_api_call_data *msg)
|
||||
{
|
||||
struct tcp_psb_msg *pcb_msg = __containerof(msg, struct tcp_psb_msg, call);
|
||||
tcp_abort(pcb_msg->pcb);
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* ESP_LWIP */
|
||||
|
||||
/**
|
||||
* Delete rcvmbox and acceptmbox of a netconn and free the left-over data in
|
||||
* these mboxes
|
||||
@@ -913,7 +927,13 @@ netconn_drain(struct netconn *conn)
|
||||
#endif /* ESP_LWIP */
|
||||
netconn_drain(newconn);
|
||||
if (newconn->pcb.tcp != NULL) {
|
||||
#if ESP_LWIP
|
||||
struct tcp_psb_msg pcb_msg = { 0 };
|
||||
pcb_msg.pcb = newconn->pcb.tcp;
|
||||
tcpip_api_call(tcp_do_abort, &pcb_msg.call);
|
||||
#else
|
||||
tcp_abort(newconn->pcb.tcp);
|
||||
#endif /* ESP_LWIP */
|
||||
newconn->pcb.tcp = NULL;
|
||||
}
|
||||
netconn_free(newconn);
|
||||
|
||||
@@ -116,6 +116,10 @@
|
||||
#define ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER 0
|
||||
#define ESP_IP_FORWARD 1
|
||||
|
||||
#if ESP_LWIP && !defined(__containerof)
|
||||
#define __containerof(ptr, type, member) ((type *)(void *)((char *)ptr - offsetof(type, member)))
|
||||
#endif
|
||||
|
||||
#ifdef IP_NAPT
|
||||
#define IP_NAPT_MAX 16
|
||||
#undef LWIP_RAND
|
||||
|
||||
Reference in New Issue
Block a user