Please mind the To: and Cc: headers. If there are relevant followups,
please send me a Cc: as I'm only subscribed to the linux-kernel and dns
mailing lists.

In some debugging, Pavel Kankovsky and Daniel J. Bernstein have tracked
down a Linux Kernel bug that I can confirm for 2.2.17 and 2.4.0-test8 (I
did not try 2.0.38, don't have gcc 2.7.2.3 installed). I have copies of
their mail (without Received: headers) available (see below).

BUG DESCRIPTION:
  (This is for IPv4, someone would have to check IPv6 as well).
  The socket flag O_NONBLOCK is _NOT_ properly inherited through an
  accept(2) call, in spite of what socket(7) documents. This is a bug.
  accept(2) must copy the file descriptor's flag of the socket.

SOCKET(7) EXCERPT: (from man pages 1.31)
  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.  Then  all  operations
  that would normally block will (usu­ ally) return  with  EAGAIN;
  connect(2)  returns  an  EIN­ PROGRESS  error  in this case.  The user
  can then wait for various events via poll(2) or select(2).

EXAMPLE:
  At http://home.pages.de/~mandree/socktest.c, there is a small test
  program (3 kB) that is not really portable, and that relies on
  dnscache for library functions (it's a quick hack). 
  
  Build it on Linux 2.2 or Linux 2.4.0-test8 and see this: (I'm running
  ./socktest 1234 & telnet localhost 1234)

  options on socket (fd=3): O_NONBLOCK 
  options after accept (fd=6): 
  accepted from 127.0.0.1:1068

  It SHOULD be: (FreeBSD 4.0 gets it right):
  options on socket (fd=3): O_NONBLOCK 
  options after accept (fd=4): O_NONBLOCK 
  accepted from 127.0.0.1:1053

  To compile the program on FreeBSD 4, comment out the line with O_SYNC
  and insert #include <poll.h>; compilation instructions are at the head
  of that file.

REFERENCES:
  test program is at
    http://home.pages.de/~mandree/socktest.c
  dnscache source code is at
    http://cr.yp.to/djbdns/dnscache-1.00.tar.gz (78 kB).
  Pavel's mail is at
    http://home.pages.de/~mandree/20000904102753.2572.0%40argo.troja.mff.cuni.cz
  Dan's mail is at
    http://home.pages.de/~mandree/20000904193940.20671.qmail%40cr.yp.to

-- 
Matthias Andree
-
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/

Reply via email to