Re: Linux tcp/ip code has trouble with async network I/O notificati

Wim ten Have (wtenhave@sybase.com)
Thu, 3 Sep 1998 14:48:46 +0200 (MET DST)


On 3 Sep, Alan Cox wrote:
>> There is a patch hanging somewhere for 2.0.3x. The problem was said to be fixed in
>> 2.1.xx (which obviously isn't). I will look for the patch if I can still find it.
>
> 2.0.36pre7

I may be an idiot, but the problem is *not* fixed in 2.0.36pre7.
The provided re-pro does still show (see the attachment below my
signature).

local client
[wtenhave@snippy]$ ./linux_srv &
[1] 728
[wtenhave@snippy]$ telnet `uname -n` 6543
Trying 158.76.120.251...
Received descr = 1[0] SUCCEEDED
Connected to snippy.sybase.com.
Escape character is '^]'.
Connection closed by foreign host.

remote client (telnet done from an other host via eth0)
[wtenhave@snippy]$ ./linux_srv
Received descr = 0[0] FAILED

I verified and found that the patch 2.0.36pre7 was correctly
applied on top of linux-2.0.35.

-- Wim ten Have.

/*
** Repro to proof that there is some problem in the Linux kernels
** with SIGIO driven netio notification.
**
** Author: Wim ten Have. <wtenhave@sybase.com>
** Date: Mon Aug 24 18:14:26 MET DST 1998
**
** Disclaimer: This example was quick and dirty programmed.
**
** Usage:
** start the server program and use telnet from an other window
** to the programmed port 6543
**
** $ cc -o linux_srv linux_src.c
** $ ./linux_srv &
** $ telnet `uname -n` 6543
** Received descr = 1[0] SUCCEEDED
**
** Do the same from an other machine, ie make the connection work
** +- via the ethernet interface.
** |
** | $ ./linux_srv &
** +-> othermachine $ telnet <the-ip-address-running-the-srv-program> 6543
** Received descr = 0[0] FAILED
*/

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#if !defined(linux)
#include <sys/sockio.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>

#include <signal.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/time.h>

extern int errno;
void sig();

int sd, nsd, pid;
int testing = 1;

int service ()
{
int n;
fd_set rset;
struct timeval *timo; /* timeout arg to select */
struct timeval timeout; /* struct for timeout if polling */
timo = &timeout;
timo->tv_sec = 0;
timo->tv_usec = 0;

FD_ZERO (&rset);
FD_SET (sd, &rset);

if ((n = select(sd+1, &rset, NULL, NULL, timo)) < 0)
perror("select"), exit(1);

printf ("Received descr = %d[%d] %s\n",
n, errno, n ? "SUCCEEDED" : "FAILED");

testing = 0;
}

main(ac, app)
int ac;
char **app;
{
int pgrp;
int opt = 1;
struct sockaddr_in saddr;

if (signal (SIGIO, service))
perror("signal"), exit(1);

if ((sd=socket(AF_INET, SOCK_STREAM, 0)) == -1)
perror("socket"), exit(1);

bzero((char *)&saddr, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
saddr.sin_port = htons(6543);

pgrp = getpid();
if (ioctl (sd, SIOCSPGRP, (char *)&(pgrp)) < 0)
perror("ioctl"), exit(1);
if (fcntl (sd, F_SETOWN, pgrp) < 0)
perror("F_SETOWN"), exit(1);
if (fcntl (sd, F_SETFL, FNDELAY|FASYNC) < 0)
perror("fcntl"), exit(1);
if ((setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0)
|| (setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt)) < 0))
perror("setsockopt"), exit(1);

if (bind(sd, (struct sockaddr_in *)&saddr, sizeof(saddr)) == -1)
perror("bind"), exit(1);

listen(sd, 5);

while (testing) {
sleep (1);
}
close (nsd);
close (sd);
exit (errno);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html