diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -701,6 +701,8 @@ goto out; } tp = intotcpcb(inp); + if (tp->t_state == TCPS_TIME_WAIT) + goto out; TCPDEBUG1(); tcp_disconnect(tp); out: @@ -1322,16 +1324,18 @@ ("tcp_usr_close: inp_socket == NULL")); /* - * If we still have full TCP state, and we're not dropped, initiate + * If we are still connected and we're not dropped, initiate * a disconnect. */ if (!(inp->inp_flags & INP_DROPPED)) { tp = intotcpcb(inp); - tp->t_flags |= TF_CLOSED; - TCPDEBUG1(); - tcp_disconnect(tp); - TCPDEBUG2(PRU_CLOSE); - TCP_PROBE2(debug__user, tp, PRU_CLOSE); + if (tp->t_state != TCPS_TIME_WAIT) { + tp->t_flags |= TF_CLOSED; + TCPDEBUG1(); + tcp_disconnect(tp); + TCPDEBUG2(PRU_CLOSE); + TCP_PROBE2(debug__user, tp, PRU_CLOSE); + } } if (!(inp->inp_flags & INP_DROPPED)) { soref(so);