Index: sys/netinet/tcp_output.c =================================================================== --- sys/netinet/tcp_output.c +++ sys/netinet/tcp_output.c @@ -286,6 +286,14 @@ sendwin = min(tp->snd_wnd, tp->snd_cwnd); flags = tcp_outflags[tp->t_state]; + if (__predict_false(flags & TH_FIN) && !(tp->t_flags & TF_SENTFIN)) { + /* clear FIN if there is still unacknowledged data */ + if (SEQ_LT(tp->snd_una, tp->snd_max)) + flags &= ~TH_FIN; + else + tp->t_flags |= TF_ACKNOW; + } + } /* * Send any SACK-generated retransmissions. If we're explicitly trying * to send out new data (when sendalot is 1), bypass this function.