From: Simon Goldschmidt Date: Thu, 22 Sep 2011 19:38:56 +0000 (+0200) Subject: fixed bug #34360 tcp_shutdown: RST on unacked is not send when shutting down both... X-Git-Url: http://rtime.felk.cvut.cz/gitweb/pes-rpp/rpp-lwip.git/commitdiff_plain/797f26e45ba762345dc398263fec0fb4478748f6 fixed bug #34360 tcp_shutdown: RST on unacked is not send when shutting down both rx AND tx --- diff --git a/CHANGELOG b/CHANGELOG index c3c14259..c829a720 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -65,6 +65,10 @@ HISTORY ++ Bugfixes: + 2011-09-22: Simon Goldschmidt + * tcp.c: fixed bug #34360 tcp_shutdown: RST on unacked is not send when + shutting down both rx AND tx + 2011-09-22: Simon Goldschmidt * tcp_impl.h: fixed bug #34355: nagle does not take snd_buf/snd_queuelen into account diff --git a/src/core/tcp.c b/src/core/tcp.c index 43244939..85315171 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -305,12 +305,7 @@ tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx) return ERR_CONN; } if (shut_rx) { - /* shut down the receive side: free buffered data... */ - if (pcb->refused_data != NULL) { - pbuf_free(pcb->refused_data); - pcb->refused_data = NULL; - } - /* ... and set a flag not to receive any more data */ + /* shut down the receive side: set a flag not to receive any more data */ pcb->flags |= TF_RXCLOSED; } if (shut_tx) { @@ -320,12 +315,18 @@ tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx) case SYN_RCVD: case ESTABLISHED: case CLOSE_WAIT: - return tcp_close_shutdown(pcb, 0); + /* if shut_tx AND shut_rx, send RST if we have unacked data */ + return tcp_close_shutdown(pcb, (u8_t)shut_rx); default: /* don't shut down other states */ break; } } + if (shut_rx && (pcb->refused_data != NULL)) { + /* shut down the receive side: free buffered data if we come here */ + pbuf_free(pcb->refused_data); + pcb->refused_data = NULL; + } /* @todo: return another err_t if not in correct state or already shut? */ return ERR_OK; }