From e039d4103fcdf3e2b87cd34942da8ae4a6c89ae4 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Mon, 17 Oct 2011 19:38:47 +0200 Subject: [PATCH] fixed bug #34569: shutdown(SHUT_WR) crashes netconn/socket api --- CHANGELOG | 3 +++ src/api/api_msg.c | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 789e1aa7..eb699311 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -69,6 +69,9 @@ HISTORY ++ Bugfixes: + 2011-10-17: Simon Goldschmidt + * api_msg.c: fixed bug #34569: shutdown(SHUT_WR) crashes netconn/socket api + 2011-10-13: Simon Goldschmidt * tcp_in.c, tcp_out.c: fixed bug #34517 (persist timer is started although no zero window is received) by starting the persist timer when a zero window is diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 4227a632..d1d26bcf 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -778,21 +778,21 @@ do_close_internal(struct netconn *conn) } } /* Try to close the connection */ - if (shut == NETCONN_SHUT_RDWR) { + if (close) { err = tcp_close(conn->pcb.tcp); } else { - err = tcp_shutdown(conn->pcb.tcp, shut & NETCONN_SHUT_RD, shut & NETCONN_SHUT_WR); + err = tcp_shutdown(conn->pcb.tcp, shut_rx, shut_tx); } if (err == ERR_OK) { /* Closing succeeded */ conn->current_msg->err = ERR_OK; conn->current_msg = NULL; conn->state = NETCONN_NONE; - /* Set back some callback pointers as conn is going away */ - conn->pcb.tcp = NULL; - /* Trigger select() in socket layer. Make sure everybody notices activity - on the connection, error first! */ if (close) { + /* Set back some callback pointers as conn is going away */ + conn->pcb.tcp = NULL; + /* Trigger select() in socket layer. Make sure everybody notices activity + on the connection, error first! */ API_EVENT(conn, NETCONN_EVT_ERROR, 0); } if (shut_rx) {