summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2012-10-28 19:58:20 +0000
committerandre <andre@FreeBSD.org>2012-10-28 19:58:20 +0000
commit07dc51f3cc94ec2fd1c6fb1c015164b7fef7d15b (patch)
tree6a428fc7feb4e012718b3e2238930a3b3f44c64d /sys/netinet
parentb824892b5780fb527f784ed0ce0eb7e9f7f707fb (diff)
downloadFreeBSD-src-07dc51f3cc94ec2fd1c6fb1c015164b7fef7d15b.zip
FreeBSD-src-07dc51f3cc94ec2fd1c6fb1c015164b7fef7d15b.tar.gz
If the user has closed the socket then drop a persisting connection
after a much reduced timeout. Typically web servers close their sockets quickly under the assumption that the TCP connections goes away as well. That is not entirely true however. If the peer closed the window we're going to wait for a long time with lots of data in the send buffer. MFC after: 2 weeks
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/tcp_timer.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index 678ce32..71ce426 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -447,6 +447,16 @@ tcp_timer_persist(void *xtp)
tp = tcp_drop(tp, ETIMEDOUT);
goto out;
}
+ /*
+ * If the user has closed the socket then drop a persisting
+ * connection after a much reduced timeout.
+ */
+ if (tp->t_state > TCPS_CLOSE_WAIT &&
+ (ticks - tp->t_rcvtime) >= TCPTV_PERSMAX) {
+ TCPSTAT_INC(tcps_persistdrop);
+ tp = tcp_drop(tp, ETIMEDOUT);
+ goto out;
+ }
tcp_setpersist(tp);
tp->t_flags |= TF_FORCEDATA;
(void) tcp_output(tp);
OpenPOWER on IntegriCloud