git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] run-parallel: rename set_nonblocking to set_nonblocking_or_die

From
Jeff King <peff@peff.net>
Date
Nov 5, 2015, 06:58 UTC
Message-ID
<20151105065801.GB4725@sigill.intra.peff.net>
In-Reply-To
<xmqq8u6d7ytc.fsf@gitster.mtv.corp.google.com>
On Wed, Nov 04, 2015 at 10:19:43PM -0800, Junio C Hamano wrote:
Show 25 quoted lines
> Having read your message, I notice these disturbing passages in my
> copy of manual pages.
> 
> poll(2) has
> 
>     BUGS
>            See the discussion of spurious readiness notifications under
>            the BUGS section of select(2).
> 
> and then select(2) has
> 
>        Under Linux, select() may report a socket file descriptor as
>        "ready for read‐ ing", while nevertheless a subsequent read
>        blocks.  This could for example happen when data has arrived
>        but upon examination has wrong checksum and is discarded.
>        There may be other circumstances in which a file descriptor
>        is spuriously reported as ready.  Thus it may be safer to use
>        O_NONBLOCK on sock‐ ets that should not block.
> 
> The world is not all Linux, so there may be systems that we do not
> have to worry about the bug described here, but there still are some
> Linux systems in use in the world, so we cannot assume the bug
> described above will not matter, either.
> 
> So I am not convinced that set_nonblocking() is unnecessary X-<.

Yes, I've heard of this bug, and I wouldn't be surprised if it is present on many systems. But notice that it is talking about sockets, whereas here I think we are dealing only with pipes. Pipes generally have much simpler and more predictable behavior, and their behaviors are more closely mandated by POSIX.

Of course that's all hearsay, and I can't quite you chapter and verse of POSIX (as if that would be enough, anyway) to prove it. But personally, I would be comfortable dropping the non-blocking bits completely from Stefan's series and adding them back in later if anybody can actually find a real-world example that doesn't conform.

Of course, simply omitting the O_NONBLOCK bits on Windows would also work if we can guarantee the Windows behavior. It means we're carrying around extra code that may or may not be doing anything useful, but it's not _that_ much code.

-Peff
Previous: Junio C HamanoNext: Stefan Beller
Message 17 of 18 in “git.git as of tonight”
  1. Junio C HamanoNov 2, 2015
  2. Johannes SixtNov 2, 2015
  3. Junio C HamanoNov 2, 2015
  4. Stefan BellerNov 2, 2015
  5. Johannes SixtNov 3, 2015
  6. Junio C HamanoNov 3, 2015
  7. Stefan BellerNov 3, 2015
  8. Johannes SixtNov 3, 2015
  9. Stefan BellerNov 3, 2015
  10. Torsten BögershausenNov 4, 2015
  11. Stefan BellerNov 4, 2015
  12. 0/2 Missing O_NONBLOCK under Windows (was: git.git as of tonight)Stefan Beller, Nov 4, 2015
  13. 1/2 run-parallel: rename set_nonblocking to set_nonblocking_or_dieStefan Beller, Nov 4, 2015
  14. Torsten BögershausenNov 5, 2015
  15. Junio C HamanoNov 5, 2015
  16. Junio C HamanoNov 5, 2015
  17. Jeff KingNov 5, 2015
  18. 2/2 run-parallel: Run sequential if nonblocking I/O is unavailableStefan Beller, Nov 4, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.