Accept listen queue bug... anyone?

Accept listen queue bug... anyone?

Post by sl.. » Wed, 15 Nov 1995 04:00:00

I have a 486dx4-100 with 16 meg ram and a 3c509b-combo ethernet card, and
im running slackware version 1.2.8.

I have a mud that listens to an internet socket, that I set up with
ye olde 'listen' call, so that I have a queue of 3 pending connections.
Ordinarily, this isnt a problem, but every now and again, someone will try to
telnet to the mud and the 3-way handshake wont get through.  Soon, all three
pending requests in the queue are used up, and noone else can log on until
the connections either time out (which takes forever... seen it hang for an
hour at a time before) or until the connection finally gets the last ack back.
I know this problem still exists in linux 1.2.13, because I have seen it
occur on a machine with that version of linux also.

When I do a netstat, the hung sockets show as being in state '
Im willing to hack my kernel to fix this, but I need a little bit of help,
maybe a lot of help depending on what solution I have to take.  My first
thought was to make it so that when the socket is accepted, it is removed
from the queue even if the connection has not been made.  My second idea was
to make it so that if the last ACK isnt received in 45 seconds, it discards
the socket as broken.

I dont know if any of these will work, but if anyone out there could point
me in the right direction or if there is a kernel patch available, I would
appreciate it.



1. Wierd listen/connect: accept queue never fills up

[Andi, I've CC'ed you since you're listed as the author of the `new
listen' code in net/ipv4/tcp_ipv4.c]

Seen on linux 2.4.20rc2.

This program is always able to establish new connections to itself:
the accept queue never fills up and connections always succeed
(although they take quite some time after the first four):

  #include <stdio.h>
  #include <sys/types.h>
  #include <sys/socket.h>
  #include <netinet/in.h>

  int main(void)
    int fd;
    struct sockaddr_in sin;
    socklen_t sinlen;

    if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
      perror("socket"), exit(1);

    sin.sin_family      = AF_INET;
    sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
    sin.sin_port              = htons(0);
    if (bind(fd, (struct sockaddr*)&sin, sizeof(sin)) == -1)
      perror("bind"), exit(1);
    if (listen(fd, 1) == -1)
      perror("listen"), exit(1);

    sinlen = sizeof(sin);
    getsockname(fd, (struct sockaddr*)&sin, &sinlen);

    while (1)
        int fdc;

        if ((fdc = socket(PF_INET, SOCK_STREAM, 0)) == -1)
        perror("socket"), exit(1);
        printf("%c", connect(fdc, (struct sockaddr*)&sin, sinlen) == -1
             ? 'F' : '.');


I've tried enabling and disabling tcp_syncookies, without any effect.

The same program starts returning errors after two successful connects
on Solaris and one on HP-UX. Linux keeps returning new connections...

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at
Please read the FAQ at

2. help with overwriting a file

3. Shutdown listen socket without clearing listen queue.

4. "xpr" for printing "xwd" outputs??


6. Redhat 4.0 space requirements? How to move partitions?

7. asynchronous listen/accept

8. Red Hat 5.2 Install Instructions

9. Listen/Accept Problem

10. listen/accept connection on a socket

11. Sockets: bind, listen, accept

12. socket streams, listen(), accept() and connect().

13. Listen () and accept()