tcpip lockup

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));
}
}

“Ray Hausman” <rayh@nbs-inc.com> wrote in message
news:9v8lf8$f9f$1@inn.qnx.com

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.

What do you mean by “locks up”? Is the machine sluggish? Or you can’t
create any more threads or a call to listen() fails? The large stack is is
probably not the culprit, more likely io-net is - does this behaviour occur
if you use the small stack? What state is io-net in when this occurs (do a
pidin)

-Adam

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));
}
}

I think my problem is also related to io-net (check out ‘Changes from 6.1 to
6.1a’ thread in installation group). So, since there seems to be a known
problem with io-net is there a planned bug fix to be released or should I
just go back to 6.1 until 6.1.1 is released? I didn’t need any of the fixes
in 6.1.a so I’m seriously considering going back to 6.1.

Jim

“Operating Systems Group” <os@qnx.com> wrote in message
news:9vd4j1$qi0$1@nntp.qnx.com

“Ray Hausman” <> rayh@nbs-inc.com> > wrote in message
news:9v8lf8$f9f$> 1@inn.qnx.com> …

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.

What do you mean by “locks up”? Is the machine sluggish? Or you can’t
create any more threads or a call to listen() fails? The large stack is
is
probably not the culprit, more likely io-net is - does this behaviour
occur
if you use the small stack? What state is io-net in when this occurs (do
a
pidin)

-Adam

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));
}
}

\

Oops, I forgot I DID need the 6.1a update since I had problems with the
devb-eide driver eating up all my memory. :frowning: Please tell me that a fix is
on the way.

Jim

“Jim Lambert” <jlambert@futurex.com> wrote in message
news:9vddrs$rsb$1@inn.qnx.com

I think my problem is also related to io-net (check out ‘Changes from 6.1
to
6.1a’ thread in installation group). So, since there seems to be a known
problem with io-net is there a planned bug fix to be released or should I
just go back to 6.1 until 6.1.1 is released? I didn’t need any of the
fixes
in 6.1.a so I’m seriously considering going back to 6.1.

Jim

“Operating Systems Group” <> os@qnx.com> > wrote in message
news:9vd4j1$qi0$> 1@nntp.qnx.com> …
“Ray Hausman” <> rayh@nbs-inc.com> > wrote in message
news:9v8lf8$f9f$> 1@inn.qnx.com> …

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.

What do you mean by “locks up”? Is the machine sluggish? Or you can’t
create any more threads or a call to listen() fails? The large stack is
is
probably not the culprit, more likely io-net is - does this behaviour
occur
if you use the small stack? What state is io-net in when this occurs
(do
a
pidin)

-Adam

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));
}
}



\

“Operating Systems Group” <os@qnx.com> wrote in message
news:9vd4j1$qi0$1@nntp.qnx.com

“Ray Hausman” <> rayh@nbs-inc.com> > wrote in message
news:9v8lf8$f9f$> 1@inn.qnx.com> …

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.

What do you mean by “locks up”? Is the machine sluggish? Or you can’t
create any more threads or a call to listen() fails? The large stack is
is
probably not the culprit, more likely io-net is - does this behaviour
occur
if you use the small stack? What state is io-net in when this occurs (do
a
pidin)

-Adam

The system is still responsive.
The system responds to pings.
Netstat hangs and can not be killed.
The problem does not occur if I use the small stack.
I will get back to you with a pidin.
Ray

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));
}
}

\

“Ray Hausman” <rayh@nbs-inc.com> wrote in message
news:9vdhpb$15k$1@inn.qnx.com

“Operating Systems Group” <> os@qnx.com> > wrote in message
news:9vd4j1$qi0$> 1@nntp.qnx.com> …
“Ray Hausman” <> rayh@nbs-inc.com> > wrote in message
news:9v8lf8$f9f$> 1@inn.qnx.com> …

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.

What do you mean by “locks up”? Is the machine sluggish? Or you can’t
create any more threads or a call to listen() fails? The large stack is
is
probably not the culprit, more likely io-net is - does this behaviour
occur
if you use the small stack? What state is io-net in when this occurs
(do
a
pidin)

-Adam

The system is still responsive.
The system responds to pings.
Netstat hangs and can not be killed.
The problem does not occur if I use the small stack.
I will get back to you with a pidin.
Ray

Pidin after the hang:
pid tid name prio STATE Blocked
1 1 procnto 0f READY
1 2 procnto 0f RUNNING
1 3 procnto 63r RECEIVE 1
1 4 procnto 10r RUNNING
1 5 procnto 63r RECEIVE 1
1 6 procnto 10r RECEIVE 1
1 7 procnto 10r RECEIVE 1
1 8 procnto 15r RECEIVE 1
1 9 procnto 10r RECEIVE 1
1 10 procnto 15r RECEIVE 1
1 11 procnto 15r RECEIVE 1
1 12 procnto 15r RECEIVE 1
2 1 proc/boot/slogger 10r RECEIVE 1
4099 1 proc/boot/pci-bios 10r RECEIVE 1
4100 1 roc/boot/devb-eide 10o SIGWAITINFO
4100 2 roc/boot/devb-eide 21r RECEIVE 1
4100 3 roc/boot/devb-eide 21r RECEIVE 4
4100 4 roc/boot/devb-eide 15o RECEIVE 10
4100 5 roc/boot/devb-eide 10r CONDVAR b037866c
4100 6 roc/boot/devb-eide 10o RECEIVE 7
4100 7 roc/boot/devb-eide 15o RECEIVE 7
4100 8 roc/boot/devb-eide 10o RECEIVE 7
20485 1 proc/boot/devc-con 10r RECEIVE 1
20486 1 sbin/tinit 10r REPLY 1
40967 1 sbin/pipe 10r RECEIVE 1
40967 2 sbin/pipe 10r RECEIVE 1
40967 3 sbin/pipe 10r RECEIVE 1
40967 4 sbin/pipe 10r RECEIVE 1
45064 1 sbin/mqueue 10r RECEIVE 1
57353 1 sbin/devc-pty 20r RECEIVE 1
61450 1 sbin/devc-ser8250 10r RECEIVE 1
6000651 1 ./tcpbug 10r NANOSLEEP
6000651 2 ./tcpbug 10r REPLY 5865484
6000651 3 ./tcpbug 10r REPLY 5865484
6000651 4 ./tcpbug 10r REPLY 5865484
6000651 5 ./tcpbug 10r REPLY 5865484
6000651 6 ./tcpbug 10r REPLY 5865484
6000651 7 ./tcpbug 10r REPLY 5865484
6000651 8 ./tcpbug 10r REPLY 5865484
6000651 9 ./tcpbug 10r REPLY 5865484
6000651 10 ./tcpbug 10r REPLY 5865484
6000651 11 ./tcpbug 10r REPLY 5865484
6000651 12 ./tcpbug 10r REPLY 5865484
6000651 13 ./tcpbug 10r REPLY 5865484
6000651 14 ./tcpbug 10r REPLY 5865484
6000651 15 ./tcpbug 10r REPLY 5865484
6000651 16 ./tcpbug 10r REPLY 5865484
6000651 17 ./tcpbug 10r REPLY 5865484
6000651 18 ./tcpbug 10r REPLY 5865484
6000651 19 ./tcpbug 10r REPLY 5865484
6000651 20 ./tcpbug 10r REPLY 5865484
6000651 21 ./tcpbug 10r REPLY 5865484
6000651 22 ./tcpbug 10r REPLY 5865484
6000651 23 ./tcpbug 10r REPLY 5865484
6000651 24 ./tcpbug 10r REPLY 5865484
6000651 25 ./tcpbug 10r REPLY 5865484
6000651 26 ./tcpbug 10r REPLY 5865484
6000651 27 ./tcpbug 10r REPLY 5865484
6000651 28 ./tcpbug 10r REPLY 5865484
6000651 29 ./tcpbug 10r REPLY 5865484
6000651 30 ./tcpbug 10r REPLY 5865484
6000651 31 ./tcpbug 10r REPLY 5865484
6000651 32 ./tcpbug 10r REPLY 5865484
6000651 33 ./tcpbug 10r REPLY 5865484
6000651 34 ./tcpbug 10r REPLY 5865484
6000651 35 ./tcpbug 10r REPLY 5865484
6000651 36 ./tcpbug 10r REPLY 5865484
6000651 37 ./tcpbug 10r REPLY 5865484
6000651 38 ./tcpbug 10r REPLY 5865484
6000651 39 ./tcpbug 10r REPLY 5865484
6000651 40 ./tcpbug 10r REPLY 5865484
6000651 41 ./tcpbug 10r REPLY 5865484
6000651 42 ./tcpbug 10r REPLY 5865484
6000651 43 ./tcpbug 10r REPLY 5865484
6000651 44 ./tcpbug 10r REPLY 5865484
6000651 45 ./tcpbug 10r REPLY 5865484
6000651 46 ./tcpbug 10r REPLY 5865484
6000651 47 ./tcpbug 10r REPLY 5865484
6000651 48 ./tcpbug 10r REPLY 5865484
6000651 49 ./tcpbug 10r REPLY 5865484
6000651 50 ./tcpbug 10r REPLY 5865484
5865484 1 sbin/io-net 10r SIGWAITINFO
5865484 2 sbin/io-net 10r RECEIVE 1
5865484 3 sbin/io-net 10r RECEIVE 1
5865484 4 sbin/io-net 15r RECEIVE 1
5865484 5 sbin/io-net 21r RECEIVE 5
5865484 6 sbin/io-net 21r RECEIVE 9
5865484 9 sbin/io-net 20r RECEIVE 13
155661 1 sbin/devb-fdc 10r SIGWAITINFO
155661 2 sbin/devb-fdc 21r RECEIVE 1
155661 3 sbin/devb-fdc 10r RECEIVE 7
155661 4 sbin/devb-fdc 10r CONDVAR b037866c
155661 5 sbin/devb-fdc 10r RECEIVE 4
155661 6 sbin/devb-fdc 10r RECEIVE 4
159758 1 usr/sbin/random 10r SIGWAITINFO
159758 2 usr/sbin/random 10r RECEIVE 1
159758 3 usr/sbin/random 10r NANOSLEEP
405519 1 bin/sh 10r SIGSUSPEND
5771280 1 bin/sh 10r SIGSUSPEND
192529 1 bin/sh 10r SIGSUSPEND
192530 1 bin/login 10r REPLY 20485
5943315 1 usr/sbin/inetd 10r SIGWAITINFO
6033428 1 usr/bin/netstat 10r REPLY 5865484
6090773 1 bin/pidin 10r REPLY 1

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));
}
}



\

The problem is that the stack needs a thread to handle
the unblock request. This is no longer the case for
the 6.2 stack.

-seanb


Ray Hausman <rayh@nbs-inc.com> wrote:

: “Operating Systems Group” <os@qnx.com> wrote in message
: news:9vd4j1$qi0$1@nntp.qnx.com
:> “Ray Hausman” <rayh@nbs-inc.com> wrote in message
:> news:9v8lf8$f9f$1@inn.qnx.com
:>
:> > 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.
:>
:> What do you mean by “locks up”? Is the machine sluggish? Or you can’t
:> create any more threads or a call to listen() fails? The large stack is
: is
:> probably not the culprit, more likely io-net is - does this behaviour
: occur
:> if you use the small stack? What state is io-net in when this occurs (do
: a
:> pidin)
:>
:> -Adam

: The system is still responsive.
: The system responds to pings.
: Netstat hangs and can not be killed.
: The problem does not occur if I use the small stack.
: I will get back to you with a pidin.
: Ray

:>
:> > 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));
:> > }
:> > }
:> >
:> >
:> >
:>
:>

So is it correct to set the ‘thread=’ argument (io-net -ptcpip threads=512)
to a large number
say 512 and hope I dont hit the limit?
Ray

“Sean Boudreau” <seanb@qnx.com> wrote in message
news:9vdj9b$7gg$1@nntp.qnx.com

The problem is that the stack needs a thread to handle
the unblock request. This is no longer the case for
the 6.2 stack.

-seanb


Ray Hausman <> rayh@nbs-inc.com> > wrote:

: “Operating Systems Group” <> os@qnx.com> > wrote in message
: news:9vd4j1$qi0$> 1@nntp.qnx.com> …
:> “Ray Hausman” <> rayh@nbs-inc.com> > wrote in message
:> news:9v8lf8$f9f$> 1@inn.qnx.com> …
:
:> > 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.
:
:> What do you mean by “locks up”? Is the machine sluggish? Or you can’t
:> create any more threads or a call to listen() fails? The large stack
is
: is
:> probably not the culprit, more likely io-net is - does this behaviour
: occur
:> if you use the small stack? What state is io-net in when this occurs
(do
: a
:> pidin)
:
:> -Adam

: The system is still responsive.
: The system responds to pings.
: Netstat hangs and can not be killed.
: The problem does not occur if I use the small stack.
: I will get back to you with a pidin.
: Ray

:
:> > 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));
:> > }
:> > }
:
:
:
:
:

Unfortunately, that’s the only workaround for the stack you have.

-seanb

Ray Hausman <rayh@nbs-inc.com> wrote:
: So is it correct to set the ‘thread=’ argument (io-net -ptcpip threads=512)
: to a large number
: say 512 and hope I dont hit the limit?
: Ray

: “Sean Boudreau” <seanb@qnx.com> wrote in message
: news:9vdj9b$7gg$1@nntp.qnx.com
:>
:> The problem is that the stack needs a thread to handle
:> the unblock request. This is no longer the case for
:> the 6.2 stack.
:>
:> -seanb
:>
:>
:> Ray Hausman <rayh@nbs-inc.com> wrote:
:>
:> : “Operating Systems Group” <os@qnx.com> wrote in message
:> : news:9vd4j1$qi0$1@nntp.qnx.com
:> :> “Ray Hausman” <rayh@nbs-inc.com> wrote in message
:> :> news:9v8lf8$f9f$1@inn.qnx.com
:> :>
:> :> > 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.
:> :>
:> :> What do you mean by “locks up”? Is the machine sluggish? Or you can’t
:> :> create any more threads or a call to listen() fails? The large stack
: is
:> : is
:> :> probably not the culprit, more likely io-net is - does this behaviour
:> : occur
:> :> if you use the small stack? What state is io-net in when this occurs
: (do
:> : a
:> :> pidin)
:> :>
:> :> -Adam
:>
:> : The system is still responsive.
:> : The system responds to pings.
:> : Netstat hangs and can not be killed.
:> : The problem does not occur if I use the small stack.
:> : I will get back to you with a pidin.
:> : Ray
:>
:> :>
:> :> > 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));
:> :> > }
:> :> > }
:> :> >
:> :> >
:> :> >
:> :>
:> :>
:>
:>

Okay, if you insist, we’ll test the new stack for you.

-Warren “Things that go ‘bump!’ in the night scare me” Peece



“Sean Boudreau” <seanb@qnx.com> wrote in message
news:9vdkba$85m$1@nntp.qnx.com
|
| Unfortunately, that’s the only workaround for the stack you have.
|
| -seanb
|
| Ray Hausman <rayh@nbs-inc.com> wrote:
| : So is it correct to set the ‘thread=’ argument (io-net -ptcpip threads=512)
| : to a large number
| : say 512 and hope I dont hit the limit?
| : Ray
|
| : “Sean Boudreau” <seanb@qnx.com> wrote in message
| : news:9vdj9b$7gg$1@nntp.qnx.com
| :>
| :> The problem is that the stack needs a thread to handle
| :> the unblock request. This is no longer the case for
| :> the 6.2 stack.
| :>
| :> -seanb
| :>
| :>
| :> Ray Hausman <rayh@nbs-inc.com> wrote:
| :>
| :> : “Operating Systems Group” <os@qnx.com> wrote in message
| :> : news:9vd4j1$qi0$1@nntp.qnx.com
| :> :> “Ray Hausman” <rayh@nbs-inc.com> wrote in message
| :> :> news:9v8lf8$f9f$1@inn.qnx.com
| :> :>
| :> :> > 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.
| :> :>
| :> :> What do you mean by “locks up”? Is the machine sluggish? Or you can’t
| :> :> create any more threads or a call to listen() fails? The large stack
| : is
| :> : is
| :> :> probably not the culprit, more likely io-net is - does this behaviour
| :> : occur
| :> :> if you use the small stack? What state is io-net in when this occurs
| : (do
| :> : a
| :> :> pidin)
| :> :>
| :> :> -Adam
| :>
| :> : The system is still responsive.
| :> : The system responds to pings.
| :> : Netstat hangs and can not be killed.
| :> : The problem does not occur if I use the small stack.
| :> : I will get back to you with a pidin.
| :> : Ray
| :>
| :> :>
| :> :> > 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));
| :> :> > }
| :> :> > }
| :> :> >
| :> :> >
| :> :> >
| :> :>
| :> :>
| :>
| :>
|
|