Socket wont die, is this a bug?? can someone fix it?

Michael (michael@bizsystems.com)
Thu, 28 May 1998 11:18:52 +0000


kernel 2.0.33 i586

I have a program that tries to open a socket and connect to a host
server every 20 seconds or so. If the host is down, for a long
time, say an hour, and then reactivated, the client in the mean
time has open 252 sockets which end up in the CLOSE (most) and a few
in the CLOSE_WAIT condition. These were left when the server shut
down. All of the CLOSE timers are in the ON state n.nn/0 but they
apparently continually get reset to 2.nn/0. Netstat shows the timers
CLOSE_WAIT are OFF and at 00.0/0 but the socket never dies. When
testing this condition I was able to get one socket to show n.nn/6
all the rest show n.nn/0, none ever change states or die, even after
waiting hours. Even though the host server is re-activated, this
condition never clears. This is repeatable and the condition can be
created by a repeat call to this TCPOpen with the host server down.
Continuing this call while re-activating the host server simply
leaves the client with no ability to connect to the server at that
port. I think this is a kernel bug somewhere in the tcp timer
mechanism. Is there something wrong with the code??

static int TCPOpen (unsigned long HostAddr, unsigned short Port)
{
int fd;
struct sockaddr_in server_addr;

bzero (&server_addr, sizeof (server_addr));
server_addr.sin_family = AF_INET;

if (Port <= 0)
{
LogError ("tcp_open", "must specify a port");
return -1;
}

server_addr.sin_port = htons (Port);

if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
{
LogError ("tcp_open", "can't create socket");
return -1;
}

bcopy (&HostAddr, &server_addr.sin_addr, sizeof (HostAddr));

if (connect (fd,
(struct sockaddr *) &server_addr,
sizeof (server_addr))
< 0)
{
LogError ("tcp_open", "can't connect to server");
return -1;
}

return fd;
}

Michael
Michael@bzs.org

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu