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

Re: [PATCH 1/2] run-command: Remove set_nonblocking

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 5, 2015, 18:45 UTC
Message-ID
<xmqqpozo5lqg.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1446747439-30349-2-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 6 quoted lines
> strbuf_read_once can also operate on blocking file descriptors if we are
> sure they are ready. The poll (2) command however makes sure this is the
> case.
>
> Reading the manual for poll (2), there may be spurious returns indicating
> readiness but that is for network sockets only. Pipes should be unaffected.

Given the presence of "for example" in that bug section, I wouldn't say "only" or "should be unaffected".

> By having this patch, we rely on the correctness of poll to return
> only pipes ready to read.

We rely on two things. One is for poll to return only pipes that are non-empty. The other is for read from a non-empty pipe not to block.

Show 5 quoted lines
>
> This fixes compilation in Windows.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---

Thanks. Let's apply these fixes on sb/submodule-parallel-fetch, merge the result to 'next' and have people play with it.

Show 34 quoted lines
>  run-command.c | 13 -------------
>  1 file changed, 13 deletions(-)
>
> diff --git a/run-command.c b/run-command.c
> index 0a3c24e..51d078c 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -1006,17 +1006,6 @@ static void pp_cleanup(struct parallel_processes *pp)
>  	sigchain_pop_common();
>  }
>  
> -static void set_nonblocking(int fd)
> -{
> -	int flags = fcntl(fd, F_GETFL);
> -	if (flags < 0)
> -		warning("Could not get file status flags, "
> -			"output will be degraded");
> -	else if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
> -		warning("Could not set file status flags, "
> -			"output will be degraded");
> -}
> -
>  /* returns
>   *  0 if a new task was started.
>   *  1 if no new jobs was started (get_next_task ran out of work, non critical
> @@ -1052,8 +1041,6 @@ static int pp_start_one(struct parallel_processes *pp)
>  		return code ? -1 : 1;
>  	}
>  
> -	set_nonblocking(pp->children[i].process.err);
> -
>  	pp->nr_processes++;
>  	pp->children[i].in_use = 1;
>  	pp->pfd[i].fd = pp->children[i].process.err;
Previous: Stefan BellerNext: Stefan Beller
Message 3 of 12 in “Remove non-blocking fds from run-command.”
  1. 0/2 Remove non-blocking fds from run-command.Stefan Beller, Nov 5, 2015
  2. 1/2 run-command: Remove set_nonblockingStefan Beller, Nov 5, 2015
  3. Junio C HamanoNov 5, 2015
  4. Stefan BellerNov 5, 2015
  5. Junio C HamanoNov 5, 2015
  6. Johannes SixtNov 5, 2015
  7. Junio C HamanoNov 5, 2015
  8. Stefan BellerNov 5, 2015
  9. Johannes SixtNov 6, 2015
  10. Stefan BellerNov 6, 2015
  11. Johannes SixtNov 6, 2015
  12. 2/2 strbuf: Correct documentation for strbuf_read_onceStefan Beller, Nov 5, 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.