mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-01 12:24:22 +00:00
Bug in last version (fix to close problems): netconn thread might get active before calling its callback, so conn was already deallocated.
This commit is contained in:
parent
9a4a5b1816
commit
2a77b9fcc7
@ -464,6 +464,13 @@ do_close_internal(struct netconn *conn)
|
|||||||
conn->state = NETCONN_NONE;
|
conn->state = NETCONN_NONE;
|
||||||
conn->pcb.tcp = NULL;
|
conn->pcb.tcp = NULL;
|
||||||
conn->err = err;
|
conn->err = err;
|
||||||
|
/* Trigger select() in socket layer */
|
||||||
|
if (conn->callback) {
|
||||||
|
/* this should send something else so the errorfd is set,
|
||||||
|
not the read and write fd! */
|
||||||
|
(*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
|
||||||
|
(*conn->callback)(conn, NETCONN_EVT_SENDPLUS, 0);
|
||||||
|
}
|
||||||
/* wake up the application task */
|
/* wake up the application task */
|
||||||
sys_mbox_post(conn->mbox, NULL);
|
sys_mbox_post(conn->mbox, NULL);
|
||||||
break;
|
break;
|
||||||
@ -503,26 +510,26 @@ do_delconn(struct api_msg_msg *msg)
|
|||||||
case NETCONN_TCP:
|
case NETCONN_TCP:
|
||||||
msg->conn->state = NETCONN_CLOSE;
|
msg->conn->state = NETCONN_CLOSE;
|
||||||
do_close_internal(msg->conn);
|
do_close_internal(msg->conn);
|
||||||
|
/* conn->callback is called inside do_close_internal, before releasing
|
||||||
|
the application thread, so we can return at this point! */
|
||||||
|
return;
|
||||||
break;
|
break;
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* tcp netconns don't come here! */
|
||||||
|
|
||||||
/* Trigger select() in socket layer */
|
/* Trigger select() in socket layer */
|
||||||
if (msg->conn->callback) {
|
if (msg->conn->callback) {
|
||||||
|
/* this send should something else so the errorfd is set,
|
||||||
|
not the read and write fd! */
|
||||||
(*msg->conn->callback)(msg->conn, NETCONN_EVT_RCVPLUS, 0);
|
(*msg->conn->callback)(msg->conn, NETCONN_EVT_RCVPLUS, 0);
|
||||||
(*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDPLUS, 0);
|
(*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDPLUS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((msg->conn->mbox != SYS_MBOX_NULL)
|
if (msg->conn->mbox != SYS_MBOX_NULL) {
|
||||||
#if LWIP_TCP
|
|
||||||
/* for tcp netconns, do_close_internal ACKs the message */
|
|
||||||
&& (NETCONNTYPE_GROUP(msg->conn->type) != NETCONN_TCP))
|
|
||||||
#else
|
|
||||||
)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
TCPIP_APIMSG_ACK(msg);
|
TCPIP_APIMSG_ACK(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user