From 47c02cdde254cb2df3f617c585e75d464e06484c Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 26 Jan 1998 06:58:31 +0000 Subject: [PATCH] PR: If SCO's going to break their links, I'm not going to go searching for where they moved it to. Cold and rainy and dark. ml" -->

Connections in the FIN_WAIT_2 state and Apache

  1. What is the FIN_WAIT_2 state?

    Starting with the Apache 1.2 betas, people are reporting many more connections in the FIN_WAIT_2 state (as reported by netstat) than they saw using older versions. When the server closes a TCP connection, it sends a packet with the FIN bit sent to the client, which then responds with a packet with the ACK bit set. The client then sends a packet with the FIN bit set to the server, which responds with an ACK and the connection is closed. The state that the connection is in during the period between when the server gets the ACK from the client and the server gets the FIN from the client is known as FIN_WAIT_2. See the TCP RFC for the technical details of the state transitions.

    The FIN_WAIT_2 state is somewhat unusual in that there is no timeout defined in the standard for it. This means that on many operating systems, a connection in the FIN_WAIT_2 state will stay around until the system is rebooted. If the system does not have a timeout and too many FIN_WAIT_2 connections build up, it can fill up the space allocated for storing information about the connections and crash the kernel. The connections in FIN_WAIT_2 do not tie up an httpd process.

  2. But why does it happen?

    There are numerous reasons for it happening, some of them may not yet be fully clear. What is known follows.

    Buggy clients and persistent connections

    Several clients have a bug which pops up when dealing with persistent connections (aka keepalives). When the connection is idle and the server closes the connection (based on the KeepAliveTimeout), the client is programmed so that the client does not send back a FIN and ACK to the server. This means that the connection stays in the FIN_WAIT_2 state until one of the following happens:

    • The client opens a new connection to the same or a different site, which causes it to fully close the older connection on that socket.
    • The user exits the client, which on some (most?) clients causes the OS to fully shutdown the connection.
    • The FIN_WAIT_2 times out, on servers that have a timeout for this state.

    If you are lucky, this means that the buggy client will fully close the connection and release the resources on your server. However, there are some cases where the socket is never fully closed, such as a dialup client disconnecting from their provider before closing the client. In addition, a client might sit idle for days without making another connection, and thus may hold its end of the socket open for days even though it has no further use for it. This is a bug in the browser or in its operating system's TCP implementation.

    The clients on which this problem has been verified to exist:

    • Mozilla/3.01 (X11; I; FreeBSD 2.1.5-RELEASE i386)
    • Mozilla/2.02 (X11; I; FreeBSD 2.1.5-RELEASE i386)
    • Mozilla/3.01Gold (X11; I; SunOS 5.5 sun4m)
    • MSIE 3.01 on the Macintosh
    • MSIE 3.01 on Windows 95

    This does not appear to be a problem on:

    • Mozilla/3.01 (Win95; I)

    It is expected that many other clients have the same problem. What a client should do is periodically check its open socket(s) to see if they have been closed by the server, and close their side of the connection if the server has closed. This check need /export/home/cvs/CVSROOT/cvsedit git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@80009 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/misc/fin_wait_2.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/manual/misc/fin_wait_2.html b/docs/manual/misc/fin_wait_2.html index e0276594bc..0027263f8e 100644 --- a/docs/manual/misc/fin_wait_2.html +++ b/docs/manual/misc/fin_wait_2.html @@ -165,9 +165,6 @@ The following systems are known to have a timeout: modify tcp_fin_wait_2_flush_interval, but the default should be appropriate for most servers and improper tuning can have negative impacts. -

  3. SCO TCP/IP Release 1.2.1 - can be modified to have a timeout by following - SCO's instructions.
  4. Linux 2.0.x and earlier(?)
  5. HP-UX 10.x defaults to -- 2.40.0