Re: Should O_NONBLOCK be copied from listening socket to accepting socket?
Chris Evans <[EMAIL PROTECTED]> wrote: > Well, in our own manpages > man 7 socket >It is possible to do non-blocking IO on sockets by setting >the O_NONBLOCK flag on a socket file descriptor using >fcntl(2). O_NONBLOCK is inherited through an accept. Although accept(2) states the opposite: original socket s is unaffected by this call. Note that any per file descriptor flags (everything that can be set with the F_SETFL fcntl, like non blocking or async state) are not inherited across a accept. -- Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ ) Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: Should O_NONBLOCK be copied from listening socket to accepting socket?
David S. Miller wrote: > Alexey tried to do this "fix" and when I tested his change we spotted > this issue and thus did not put the "fix" in what we sent to Linus. Is this patch available somewhere on the net? I really need it. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: Should O_NONBLOCK be copied from listening socket to accepting socket?
Chris Evans [EMAIL PROTECTED] wrote: Well, in our own manpages man 7 socket It is possible to do non-blocking IO on sockets by setting the O_NONBLOCK flag on a socket file descriptor using fcntl(2). O_NONBLOCK is inherited through an accept. Although accept(2) states the opposite: original socket s is unaffected by this call. Note that any per file descriptor flags (everything that can be set with the F_SETFL fcntl, like non blocking or async state) are not inherited across a accept. -- Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ ) Email: Herbert Xu ~{PmVHI~} [EMAIL PROTECTED] Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: Should O_NONBLOCK be copied from listening socket to accepting socket?
From: Michael Shields <[EMAIL PROTECTED]> Date:04 Sep 2000 20:27:53 + Is it required that the O_NONBLOCK flag be copied from a listening socket to an accepted socket? Dan Bernstein believes this is a bug. If we "fixed" this every inetd on every Linux system would unfortunately stop working. So we have to remain bug compatible. Alexey tried to do this "fix" and when I tested his change we spotted this issue and thus did not put the "fix" in what we sent to Linus. Later, David S. Miller [EMAIL PROTECTED] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Re: Should O_NONBLOCK be copied from listening socket to accepting socket?
> Is it required that the O_NONBLOCK flag be copied from a listening > socket to an accepted socket? Dan Bernstein believes this is a bug. My posix 1003.1g draft leaves it undefined. It is possible that SuS clarifies this. Unless he can cite a SuS version that has clarified this I believe its like the SIGIO case - inheritance is platform specific. On the other hand we don't inherit CLOSEONEXEC so why should we inherit NDELAY ? Alan - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/
Should O_NONBLOCK be copied from listening socket to accepting socket?
Is it required that the O_NONBLOCK flag be copied from a listening socket to an accepted socket? Dan Bernstein believes this is a bug. Pavel Kankovsky writes: > What happens when x->tcpstate == 1 (i.e. waiting for the first byte of TCP > request length), x->io->revents == 0 (i.e. not ready for i/o), and > !taia_less(stamp, >timeout) (i.e. the timeout has expired)? What happens on working kernels is that the read() returns -1/35, because that descriptor is nonblocking. For example, under OpenBSD: % time telnet 127.0.0.1 53 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Connection closed by foreign host. 0.0u 0.0s 0:10.02 0.0% 0+0k 0+3io 0pf+0w Apparently Linux 2.2 fails to copy O_NONBLOCK from the listening socket to the accepted socket, so the same test will block dnscache after 10 seconds; you'll have to close the connection manually. I'd appreciate hearing exactly which kernel versions have this bug. Obvious workaround #1: add if (ndelay_on(x->tcp) == -1) { close(x->tcp); return; } /* Linux bug */ two lines after the accept4() in dnscache.c. Obvious workaround #2: use a system with the BSD networking stack. (Can't beat the Real Thing.) Thanks to Pavel for tracking this down. No thanks to Ray for giving us a bogus diagnosis instead of the crucial logs. ---Dan -- Shields.
Should O_NONBLOCK be copied from listening socket to accepting socket?
Is it required that the O_NONBLOCK flag be copied from a listening socket to an accepted socket? Dan Bernstein believes this is a bug. Pavel Kankovsky writes: What happens when x-tcpstate == 1 (i.e. waiting for the first byte of TCP request length), x-io-revents == 0 (i.e. not ready for i/o), and !taia_less(stamp, x-timeout) (i.e. the timeout has expired)? What happens on working kernels is that the read() returns -1/35, because that descriptor is nonblocking. For example, under OpenBSD: % time telnet 127.0.0.1 53 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Connection closed by foreign host. 0.0u 0.0s 0:10.02 0.0% 0+0k 0+3io 0pf+0w Apparently Linux 2.2 fails to copy O_NONBLOCK from the listening socket to the accepted socket, so the same test will block dnscache after 10 seconds; you'll have to close the connection manually. I'd appreciate hearing exactly which kernel versions have this bug. Obvious workaround #1: add if (ndelay_on(x-tcp) == -1) { close(x-tcp); return; } /* Linux bug */ two lines after the accept4() in dnscache.c. Obvious workaround #2: use a system with the BSD networking stack. (Can't beat the Real Thing.) Thanks to Pavel for tracking this down. No thanks to Ray for giving us a bogus diagnosis instead of the crucial logs. ---Dan -- Shields.
Re: Should O_NONBLOCK be copied from listening socket to accepting socket?
From: Michael Shields [EMAIL PROTECTED] Date:04 Sep 2000 20:27:53 + Is it required that the O_NONBLOCK flag be copied from a listening socket to an accepted socket? Dan Bernstein believes this is a bug. If we "fixed" this every inetd on every Linux system would unfortunately stop working. So we have to remain bug compatible. Alexey tried to do this "fix" and when I tested his change we spotted this issue and thus did not put the "fix" in what we sent to Linus. Later, David S. Miller [EMAIL PROTECTED] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] Please read the FAQ at http://www.tux.org/lkml/