Patch ID	: P95043001
Summary		: tcp sockets hang in CLOSE_WAIT
Status		: Mandatory
Date		: 04/30/95
Release		: OS 4.1C
Architectures	: Series5 S4000 Series6
Affected bugs	:
	2746

Changed files	:
	sys/netinet/tcp_timer.c (delta 1.4)
	sys/netinet/tcp_input.c (delta 1.3)
	sys/netinet/in_proto.c (delta 1.2)

Problem Description:

This patch addresses two problems that can result in sockets never being
released, resulting in resource starvation and hung processes.

The first problem is when a TCP connection is initiated with a packet
whose SYN and FIN bits are set.  This is not legal by the TCP spec, but
apparently some DOS-based implementations do this.  The result is a socket
that netstat reports to be in CLOSE_WAIT that never goes away.

The second problem is a connection to a remote host, where the host has
crashed or for some other reason become unavailable, and the transmit window
is closed.  Such sockets *should* time out and be reset approximately ten
minutes after data is queued for transmission, but this hasn't been happening.

The fix for the first problem is to ignore the FIN bit in TCP packets that
contain a SYN.  The handshake then proceeds according to the TCP spec, with
the remote system sending the FIN again in a packet that does not contain a
SYN.

The fix for the second problem is a somewhat ugly hack, given the definition
of TCP.  If the window has remained closed for the entire TCP back-off period,
and no packets have been received from the remote system, drop the connection.

