The system is 6.1 PatchA.
There appears to be a bug in the large tcp stack (io-net -p tcpip) when it
exhausts its thread limit (default 48). If an attempt to exceed this limit
is
made TCP locks up. The limit can be exceeded by simply listening on
too many (default 48) ports. The thread limit can be increased (io-net -p
tcpip threads=128),
but when the new limit is reached TCP locks up. The only way to unfreeze TCP
is to slay
io-net and restart it.
Has anyone seen this problem and are the any fixes??
A simple program that demonstrates the problem follows:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
short ListenPort;
int ListenCount;
void initialize (void);
void *readsockthread (void *arg);
int
main (int argc, char *argv[])
{
int i;
pthread_t tid;
ListenPort = 7000;
ListenCount = 49;
if (argc == 2)
ListenCount = atoi (argv[1]);
if (argc == 3)
ListenPort = atoi (argv[2]);
for (i = 0; i < ListenCount; ++i)
pthread_create (&tid, NULL, readsockthread, (void *)(ListenPort+i));
while (1)
sleep (1000);
return EXIT_SUCCESS;
}
void *
readsockthread (void *arg)
{
int listenport = (int)arg;
int listenfd;
struct sockaddr_in sa;
if ( (listenfd = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
printf (“socket() %d\n”, errno);
exit (EXIT_FAILURE);
}
memset (&sa, 0, sizeof (sa));
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = htonl (INADDR_ANY);
sa.sin_port = htons (listenport);
if (bind (listenfd, (struct sockaddr *) &sa, sizeof (sa)) < 0) {
printf (“bind() %d\n”, errno);
exit (EXIT_FAILURE);
}
if (listen (listenfd, 5) < 0) {
printf (“listen() %d\n”, errno);
exit (EXIT_FAILURE);
}
while (1) {
struct sockaddr_in remote;
int len;
int fd;
char msg[1];
int cnt;
len = sizeof (remote);
if ((fd = accept (listenfd, (struct sockaddr *)&remote, &len)) == -1) {
printf (“accept() failed: %d\n”, errno);
exit (EXIT_FAILURE);
}
while ((cnt = read (fd, msg, 1)) > 0)
;
if (cnt < 0)
printf (“readsockthread: read() failed: %d\n”, errno);
shutdown (fd, 2);
close (fd);
printf (“connection from %s closed\n”, inet_ntoa (remote.sin_addr));
}
}