Fixed bug #27316 (netconn: Possible deadlock in err_tcp) by using sys_mbox_trypost in err_tcp

This commit is contained in:
goldsimon 2010-01-19 18:34:01 +00:00
parent 972ca9e6c1
commit 52389fc09a
2 changed files with 11 additions and 3 deletions

View File

@ -50,6 +50,9 @@ HISTORY
++ Bugfixes:
2010-01-19: Simon Goldschmidt
* api_msg.c: Fixed bug #27316: netconn: Possible deadlock in err_tcp
2010-01-18: Iordan Neshev/Simon Goldschmidt
* src/netif/ppp: reorganised PPP sourcecode to 2.3.11 including some
bugfix backports from 2.4.x.

View File

@ -312,14 +312,17 @@ err_tcp(void *arg, err_t err)
{
struct netconn *conn;
enum netconn_state old_state;
SYS_ARCH_DECL_PROTECT(lev);
conn = arg;
LWIP_ASSERT("conn != NULL", (conn != NULL));
conn->pcb.tcp = NULL;
/* no protection since this is always fatal */
/* no check since this is always fatal */
SYS_ARCH_PROTECT(lev);
conn->last_err = err;
SYS_ARCH_UNPROTECT(lev);
/* API_EVENT might call tcp_tmr, so reset conn->state now */
old_state = conn->state;
@ -328,12 +331,14 @@ err_tcp(void *arg, err_t err)
if (conn->recvmbox != SYS_MBOX_NULL) {
/* Register event with callback */
API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0);
sys_mbox_post(conn->recvmbox, NULL);
/* use trypot to preven deadlock */
sys_mbox_trypost(conn->recvmbox, NULL);
}
if (conn->acceptmbox != SYS_MBOX_NULL) {
/* Register event with callback */
API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0);
sys_mbox_post(conn->acceptmbox, NULL);
/* use trypot to preven deadlock */
sys_mbox_trypost(conn->acceptmbox, NULL);
}
if ((old_state == NETCONN_WRITE) || (old_state == NETCONN_CLOSE) ||
(old_state == NETCONN_CONNECT)) {