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

Re: [PATCH 3/8] xread_nonblock: add functionality to read from fds without blocking

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 14, 2015, 20:59 UTC
Message-ID
<xmqqmvtciw69.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1450121838-7069-4-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
> Provide a wrapper to read(), similar to xread(), that restarts on
> EINTR but not EAGAIN (or EWOULDBLOCK). This enables the caller to
> handle polling itself, possibly polling multiple sockets or performing
> some other action.

Do you still need this (and use of this in 4/8)? The description of a4433fd4 (run-command: remove set_nonblocking(), 2015-11-05) from the previous iteration justifies the removal of set_nonblocking() this way:

    run-command: remove set_nonblocking()
    
    strbuf_read_once can also operate on blocking file descriptors if we
    are sure they are ready.  And the poll(2) we call before calling
    this ensures that this is the case.

Updated run-command in this reroll lacks set_nonblocking(), and does have the poll(2) before it calls strbuf_read_once(). Which means that xread_nonblock() introduced here and used by [4/8] would read a file descriptor that is not marked as nonblock, the read(2) in there would never error-return with EWOULDBLOCK, and would be identical to xread() updated by [2/8] in this reroll.

So it appears to me that you can lose this and call xread() in [4/8]?

Ahh, there is a difference if the file descriptor the caller feeds strbuf_read_once() happens to be marked as nonblock. read_once() wants to return without doing the poll() in such a case. Even though this series would not introduce any use of a nonblocking file descriptor, as a general API function, [4/8] must be prepared for such a future caller, hence [3/8] is needed.

OK, thanks.
Previous: Stefan BellerNext: Eric Sunshine
Message 9 of 30 in “Rerolling sb/submodule-parallel-fetch for the time after 2.7”
  1. 0/8 Rerolling sb/submodule-parallel-fetch for the time after 2.7Stefan Beller, Dec 14, 2015
  2. 1/8 submodule.c: write "Fetching submodule <foo>" to stderrStefan Beller, Dec 14, 2015
  3. 2/8 xread: poll on non blocking fdsStefan Beller, Dec 14, 2015
  4. Eric SunshineDec 14, 2015
  5. Stefan BellerDec 14, 2015
  6. Junio C HamanoDec 14, 2015
  7. Stefan BellerDec 14, 2015
  8. 3/8 xread_nonblock: add functionality to read from fds without blockingStefan Beller, Dec 14, 2015
  9. Junio C HamanoDec 14, 2015
  10. Eric SunshineDec 14, 2015
  11. Eric SunshineDec 14, 2015
  12. Junio C HamanoDec 14, 2015
  13. Jeff KingDec 14, 2015
  14. Stefan BellerDec 15, 2015
  15. Jeff KingDec 15, 2015
  16. Stefan BellerDec 15, 2015
  17. Jeff KingDec 15, 2015
  18. Johannes SixtDec 15, 2015
  19. Junio C HamanoDec 15, 2015
  20. 4/8 strbuf: add strbuf_read_once to read without blockingStefan Beller, Dec 14, 2015
  21. Eric SunshineDec 14, 2015
  22. Stefan BellerDec 14, 2015
  23. 5/8 sigchain: add command to pop all common signalsStefan Beller, Dec 14, 2015
  24. 6/8 run-command: add an asynchronous parallel child processorStefan Beller, Dec 14, 2015
  25. Johannes SixtDec 14, 2015
  26. Stefan BellerDec 14, 2015
  27. 7/8 fetch_populated_submodules: use new parallel job processingStefan Beller, Dec 14, 2015
  28. 8/8 submodules: allow parallel fetching, add tests and documentationStefan Beller, Dec 14, 2015
  29. Johannes SixtDec 14, 2015
  30. Junio C HamanoDec 14, 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.