Re: 2.0.13 Sockets Stuck on close

Linus Torvalds (torvalds@cs.helsinki.fi)
Thu, 22 Aug 1996 13:05:35 +0300 (EET DST)


On 22 Aug 1996, Thomas Koenig wrote:
>
> In linux.dev.kernel, "Eric Schenk" <schenk@cs.toronto.edu> wrote:
> >Does the stuck socket eventually
> >disappear, or does it stick around until a reboot?
>
> It sticks around until the process dies (in my case, sendmail).

Umm.. This sounds like "TCP_CLOSE_WAIT" as opposed to "TCP_CLOSE". And that
makes sense, because any socket in TCP_CLOSE shouldn't even show up on
netstat (because it simply isn't there any more). Maybe "netstat" has a
bug and reports the wrong state?

And "TCP_CLOSE_WAIT" should NOT time out. Because the state essentially
means that the other end has closed the connection, and the networking
side is now waiting for _our_ application to close down the socket. And
obviously the kernel can't time out on that.

So if you see sockets in CLOSE state (and assuming this really is
TCP_CLOSE_WAIT), it probably means that there is a local application that for
some unfathomable reason keeps the socket open. So rather than a kernel
problem, it might indicate a user-level problem (a application getting stuck
waiting for something to happen, possibly due to race conditions within the
application itself due to signal handling or something)?

Linus