From 0bce6f89744cae3c9d9ec180531b35cac1616a4e Mon Sep 17 00:00:00 2001 From: davidhaas Date: Wed, 9 Apr 2003 20:12:12 +0000 Subject: [PATCH] Fixed bug where tearing down a connection would cause loss of memory. --- src/api/api_lib.c | 4 ++-- src/include/lwip/sys.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/api_lib.c b/src/api/api_lib.c index e2d3e03d..602d0798 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -255,7 +255,7 @@ netconn_delete(struct netconn *conn) /* Drain the recvmbox. */ if(conn->recvmbox != SYS_MBOX_NULL) { - while(sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != 0) { + while(sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) { if(conn->type == NETCONN_TCP) { pbuf_free((struct pbuf *)mem); } else { @@ -269,7 +269,7 @@ netconn_delete(struct netconn *conn) /* Drain the acceptmbox. */ if(conn->acceptmbox != SYS_MBOX_NULL) { - while(sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != 0) { + while(sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != SYS_ARCH_TIMEOUT) { netconn_delete((struct netconn *)mem); } diff --git a/src/include/lwip/sys.h b/src/include/lwip/sys.h index 94bc0790..88aea208 100644 --- a/src/include/lwip/sys.h +++ b/src/include/lwip/sys.h @@ -68,6 +68,9 @@ struct sys_timeout {u8_t dummy;}; #include "arch/sys_arch.h" +/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ +#define SYS_ARCH_TIMEOUT 0xffffffff + typedef void (* sys_timeout_handler)(void *arg); struct sys_timeout {