Re: Multithread select() bug

From: Davide Libenzi (davidel_at_xmailserver.org)
Date: 05/11/04

  • Next message: Edward Falk: "[PATCH] add path-oriented proc_mkdir_path() function to /proc"
    Date:	Mon, 10 May 2004 15:09:45 -0700 (PDT)
    To: Andre Ben Hamou <andre@bluetheta.com>
    
    

    On Mon, 10 May 2004, Andre Ben Hamou wrote:

    > Davide Libenzi wrote:
    > > Try:
    > >
    > > select (socket + 1, &fds, &fds, &fds, &timeout);
    > > ^^^^^
    >
    > That does work, but only as a workaround (and not a universally
    > applicable one). Select *should* return upon the closure of either end
    > of a socket connection that is in the read-FD-set only (unless I've
    > completely misunderstood the various references).

    The standard says that select should return when the operation against the
    fd would not block *or* would return an error different from
    would-have-blocked. The following operation on a closed fd would be an
    EBADF, that fits the standard description. OTOH, MT is messy. Consider a
    thread that closes the fd and immediately after open another one having
    the same fd#. Bottom line is, don't do it.

    - Davide

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Edward Falk: "[PATCH] add path-oriented proc_mkdir_path() function to /proc"

    Relevant Pages

    • Re: WINE + NX (No eXecute) support for x86, 2.6.7-rc2-bk2
      ... if there is no standard, ... > If you don't care about binary compatability, ... At least some people out there seem to care about it. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Was bedeutet [[ expression ]]
      ... die Nutzung von unportablen Konstruken, ... funktionieren als dieser Workaround, zumindest ist das meine ... Siehe ISO/IEC Standard 9945 sowie IEEE Standard 1003.1-2001 aka Single ... UNIX Specification Version 3 Shell & Utilities -> test ...
      (de.comp.os.unix.shell)
    • Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt
      ... > If we are following the standard and trying to set up a timer, ... Yes, adding *LATCH to xtime in each timer interrupt, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: 2.6.{9,10}: C3 not working once USB driver gets loaded (ThinkPad T40p)
      ... > Is the USB driver setting some kinda flag in the ACPI subsystem to ... It is not a Linux bug -- it is a system hardware architecture flaw. ... There is a workaround for this issue called ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: new PCI quirk for Toshiba Satellite?
      ... everything of the workaround can be done there. ... > could be cross compiling, and I'd like to avoid an ifdef altogether. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)

    Loading