From d64b3f21e6e6071be8bdb0f4f81dd26caeb464f2 Mon Sep 17 00:00:00 2001 From: marcbou Date: Thu, 16 Aug 2007 18:24:29 +0000 Subject: [PATCH] Initialize newconn->state to NETCONN_NONE in accept_function; otherwise it was left to NETCONN_CLOSE and sent_tcp() could prematurely close the connection. --- src/api/api_msg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/api_msg.c b/src/api/api_msg.c index e11a0f43..1a112789 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -70,7 +70,8 @@ recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, conn = arg; if ((conn != NULL) && (conn->recvmbox != SYS_MBOX_NULL)) { - if (!(buf = memp_malloc(MEMP_NETBUF))) { + buf = memp_malloc(MEMP_NETBUF); + if (!buf) { return 0; } pbuf_ref(p); @@ -331,6 +332,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) newconn->type = NETCONN_TCP; newconn->pcb.tcp = newpcb; setup_tcp(newconn); + newconn->state = NETCONN_NONE; newconn->acceptmbox = SYS_MBOX_NULL; newconn->err = err; /* Register event with callback */