LWIP_NETCONN_FULLDUPLEX: fixed shutdown during write (bug #50274)

(cherry picked from commit 6dca664217)

Conflicts:
	CHANGELOG
This commit is contained in:
sg 2017-02-16 22:09:02 +01:00 committed by goldsimon
parent 4d1d567ab7
commit 2ca39c275a

View File

@ -1784,25 +1784,28 @@ lwip_netconn_do_close(void *m)
#if LWIP_NETCONN_FULLDUPLEX #if LWIP_NETCONN_FULLDUPLEX
if (msg->msg.sd.shut & NETCONN_SHUT_WR) { if (msg->msg.sd.shut & NETCONN_SHUT_WR) {
/* close requested, abort running write */ /* 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); 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->err = ERR_CLSD;
msg->conn->current_msg = NULL; msg->conn->current_msg = NULL;
msg->conn->write_offset = 0; msg->conn->write_offset = 0;
msg->conn->state = NETCONN_NONE; msg->conn->state = NETCONN_NONE;
state = NETCONN_NONE;
NETCONN_SET_SAFE_ERR(msg->conn, ERR_CLSD); NETCONN_SET_SAFE_ERR(msg->conn, ERR_CLSD);
sys_sem_signal(op_completed_sem); sys_sem_signal(write_completed_sem);
} else { } else {
LWIP_ASSERT("msg->msg.sd.shut == NETCONN_SHUT_RD", msg->msg.sd.shut == NETCONN_SHUT_RD); 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 /* In this case, let the write continue and do not interfere with
conn->current_msg or conn->state! */ conn->current_msg or conn->state! */
msg->err = tcp_shutdown(msg->conn->pcb.tcp, 1, 0); msg->err = tcp_shutdown(msg->conn->pcb.tcp, 1, 0);
} }
}
if (state == NETCONN_NONE) {
#else /* LWIP_NETCONN_FULLDUPLEX */ #else /* LWIP_NETCONN_FULLDUPLEX */
msg->err = ERR_INPROGRESS; msg->err = ERR_INPROGRESS;
#endif /* LWIP_NETCONN_FULLDUPLEX */
} else { } else {
#endif /* LWIP_NETCONN_FULLDUPLEX */
if (msg->msg.sd.shut & NETCONN_SHUT_RD) { if (msg->msg.sd.shut & NETCONN_SHUT_RD) {
/* Drain and delete mboxes */ /* Drain and delete mboxes */
netconn_drain(msg->conn); netconn_drain(msg->conn);