From 4c3dfb92b7667068226f602a1e658f4a8ad8d757 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sat, 21 Jan 2012 18:05:15 +0100 Subject: [PATCH] fixed bug #34636: FIN_WAIT_2 - Incorrect shutdown of TCP pcb: don't let PCBs time out from FIN_WAIT_2 if the RX side wasn't close (by either calling tcp_close or tcp_shutdown(RDWR)) --- CHANGELOG | 3 +++ src/core/tcp.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index edb085cf..8caf218f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -76,6 +76,9 @@ HISTORY ++ Bugfixes: + 2012-01-21: Simon Goldschmidt + * tcp.c: fixed bug #34636: FIN_WAIT_2 - Incorrect shutdown of TCP pcb + 2012-01-20: Simon Goldschmidt * dhcp.c: fixed bug #35151: DHCP asserts on incoming option lengths diff --git a/src/core/tcp.c b/src/core/tcp.c index 150cd966..162ca366 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -906,10 +906,15 @@ tcp_slowtmr_start: } /* Check if this PCB has stayed too long in FIN-WAIT-2 */ if (pcb->state == FIN_WAIT_2) { - if ((u32_t)(tcp_ticks - pcb->tmr) > - TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); + /* If this PCB is in FIN_WAIT_2 because of SHUT_WR don't let it time out. */ + if (pcb->flags & TF_RXCLOSED) { + /* PCB was fully closed (either through close() or SHUT_RDWR): + normal FIN-WAIT timeout handling. */ + if ((u32_t)(tcp_ticks - pcb->tmr) > + TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { + ++pcb_remove; + LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); + } } }