From 6dca6642174df81dc6813c7f0cdc8f2cd5be497f Mon Sep 17 00:00:00 2001 From: sg Date: Thu, 16 Feb 2017 22:09:02 +0100 Subject: [PATCH] LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274) --- CHANGELOG | 3 +++ src/api/api_msg.c | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 00767413..f728b35d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,9 @@ HISTORY ++ Bugfixes: + 2017-02-16: Simon Goldschmidt + * LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274) + 2017-01-18: Dirk Ziegelmeier * Fix zero-copy RX, see bug bug #50064. PBUF_REFs were not supported as ARP requests. diff --git a/src/api/api_msg.c b/src/api/api_msg.c index e0a0a631..dd99c1e0 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -1784,25 +1784,28 @@ lwip_netconn_do_close(void *m) #if LWIP_NETCONN_FULLDUPLEX if (msg->msg.sd.shut & NETCONN_SHUT_WR) { /* close requested, abort running write */ - sys_sem_t* op_completed_sem; + sys_sem_t* write_completed_sem; LWIP_ASSERT("msg->conn->current_msg != NULL", msg->conn->current_msg != NULL); - op_completed_sem = LWIP_API_MSG_SEM(msg->conn->current_msg); + write_completed_sem = LWIP_API_MSG_SEM(msg->conn->current_msg); msg->conn->current_msg->err = ERR_CLSD; msg->conn->current_msg = NULL; msg->conn->write_offset = 0; msg->conn->state = NETCONN_NONE; + state = NETCONN_NONE; NETCONN_SET_SAFE_ERR(msg->conn, ERR_CLSD); - sys_sem_signal(op_completed_sem); + sys_sem_signal(write_completed_sem); } else { LWIP_ASSERT("msg->msg.sd.shut == NETCONN_SHUT_RD", msg->msg.sd.shut == NETCONN_SHUT_RD); /* In this case, let the write continue and do not interfere with conn->current_msg or conn->state! */ msg->err = tcp_shutdown(msg->conn->pcb.tcp, 1, 0); } + } + if (state == NETCONN_NONE) { #else /* LWIP_NETCONN_FULLDUPLEX */ msg->err = ERR_INPROGRESS; -#endif /* LWIP_NETCONN_FULLDUPLEX */ } else { +#endif /* LWIP_NETCONN_FULLDUPLEX */ if (msg->msg.sd.shut & NETCONN_SHUT_RD) { /* Drain and delete mboxes */ netconn_drain(msg->conn);