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

Re: [PATCH 4/4] remote-curl: read in the push report even if we fail to finish sending data

From
Jeff King <peff@peff.net>
Date
Jun 13, 2024, 09:55 UTC
Message-ID
<20240613095542.GA817573@coredump.intra.peff.net>
In-Reply-To
<20240612115028.1169183-5-cmn@dwim.me>
On Wed, Jun 12, 2024 at 01:50:28PM +0200, Carlos Martín Nieto wrote:
> If we just consume send-pack's output and don't send anything to
> remote-helper, it will not update any of its structures and will report
> "Everything up-to-date" next to the error message.

OK, consuming the output at the helper level makes some sense to me. But...

Show 30 quoted lines
> diff --git a/remote-curl.c b/remote-curl.c
> index 0b6d7815fdd..9e45e14afec 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -1114,15 +1114,25 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads,
>  
>  	close(client.in);
>  	client.in = -1;
> -	if (!err) {
> -		strbuf_read(rpc_result, client.out, 0);
> -	} else {
> -		char buf[4096];
> -		for (;;)
> -			if (xread(client.out, buf, sizeof(buf)) <= 0)
> -				break;
> +
> +	/*
> +	 * If we encountered an error, we might still get a report. Consume the
> +	 * rest of the packfile and an extra flush and then we can copy
> +	 * over the report the same way as in the success case.
> +	 */
> +	if (err) {
> +		int n;
> +		do {
> +			n = packet_read(rpc->out, rpc->buf, rpc->alloc, 0);
> +		} while (n > 0);
> +
> +		/* Read the final flush separating the payload from the report */
> +		packet_read(rpc->out, rpc->buf, rpc->alloc, 0);
>  	}

Isn't this existing code already trying to read everything? I think rpc->out and client.out are synonyms.

So now instead of reading to EOF, we are reading some set number of packets. This function is used for both fetches and pushes, isn't it? Is the expected number of packets the same for both? What about stateless-connect mode?

> +	/* Copy the report of successes/failures */
> +	strbuf_read(rpc_result, client.out, 0);

OK, so this is where we read the result. Which again, only makes sense for send-pack. And in theory we've synchronized the protocol through the packet reads above (are we sure that we always enter the read loop above from a predictable synchronization point in the protocol, given that we saw an error?).

What if send-pack doesn't send us anything useful (e.g., it hangs up without sending the report). Shouldn't we take the presence of "err" being non-zero as an indication that things are not well, even if we never get to the send-pack report?

-Peff
Previous: Carlos Martín NietoNext: Carlos Martín Nieto
Message 5 of 14 in “Report rejections over HTTP when the remote rejects during the transfer”
  1. 0/4 Report rejections over HTTP when the remote rejects during the transferCarlos Martín Nieto, Jun 12, 2024
  2. 1/4 t/lib-http: add serve-git.pyCarlos Martín Nieto, Jun 12, 2024
  3. Junio C HamanoJun 12, 2024
  4. 4/4 remote-curl: read in the push report even if we fail to finish sending dataCarlos Martín Nieto, Jun 12, 2024
  5. Jeff KingJun 13, 2024
  6. Carlos Martín NietoJul 23, 2024
  7. 3/4 t5541: add test for rejecting a push due to packfile sizeCarlos Martín Nieto, Jun 12, 2024
  8. Taylor BlauJun 12, 2024
  9. Jeff KingJun 13, 2024
  10. Jeff KingJun 13, 2024
  11. 2/4 t/lib-http.sh: add functions related to serve-git.pyCarlos Martín Nieto, Jun 12, 2024
  12. Jeff KingJun 13, 2024
  13. Jeff KingJun 13, 2024
  14. Carlos Martín NietoJul 23, 2024

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.