mg_lwip: Fix race during clean conenction teardown

Set CLOSE_IMMEDIATELY flag when destroying conn.
This avoid some races in LWIP adapter.

CL: mg_lwip: Fix race during clean conenction teardown

PUBLISHED_FROM=5c67982390dfaf83527e85d1291f64c6050aa932
This commit is contained in:
Deomid Ryabkov authored and Cesanta Bot committed 2018-06-18 16:35:04 +00:00
1 parent d949c19c7e
commit 9ba6eb716d
4 files changed
+20 -8

No files matched your search

+1 -1
View File
@@ -126,7 +126,7 @@ static err_t mg_lwip_tcp_conn_cb(void *arg, struct tcp_pcb *tpcb, err_t err) {
static void mg_lwip_tcp_error_cb(void *arg, err_t err) {
struct mg_connection *nc = (struct mg_connection *) arg;
DBG(("%p conn error %d", nc, err));
if (nc == NULL) return;
if (nc == NULL || (nc->flags & MG_F_CLOSE_IMMEDIATELY)) return;
struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock;
cs->pcb.tcp = NULL; /* Has already been deallocated */
if (nc->flags & MG_F_CONNECTING) {