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

RE: [PATCH] remote-curl: don't hang when a server dies before any output

From
DTDavid Turner <david.turner@twosigma.com>
Date
Nov 14, 2016, 23:25 UTC
Message-ID
<a57cc9c4a0a840baab5b8123fac9388b@exmbdft7.ad.twosigma.com>
In-Reply-To
<20161114194049.mktpsvgdhex2f4zv@sigill.intra.peff.net>
Show 29 quoted lines
> -----Original Message-----
> From: Jeff King [mailto:peff@peff.net]
> Sent: Monday, November 14, 2016 2:41 PM
> To: David Turner
> Cc: git@vger.kernel.org; spearce@spearce.org
> Subject: Re: [PATCH] remote-curl: don't hang when a server dies before any
> output
> 
> On Mon, Nov 14, 2016 at 01:24:31PM -0500, Jeff King wrote:
> 
> >   2. Have remote-curl understand enough of the protocol that it can
> >      abort rather than hang.
> >
> >      I think that's effectively the approach of your patch, but for one
> >      specific case. But could we, for example, make sure that everything
> >      we proxy is a complete set of pktlines and ends with a flush? And
> >      if not, then we hang up on fetch-pack.
> >
> >      I _think_ that would work, because even the pack is always encased
> >      in pktlines for smart-http.
> 
> So something like this. It turned out to be a lot uglier than I had hoped
> because we get fed the data from curl in odd-sized chunks, so we need a
> state machine.
> 
> But it does seem to work. At least it doesn't seem to break anything in
> the test suite, and it fixes the new tests you added. I'd worry that
> there's some obscure case where the response isn't packetized in the same
> way.
Overall, this looks good to me.  The state machine is pretty clean. I think I would have used a tiny buffer for the length field, and then I would have regretted it.  Your way looks nicer than my unwritten patch would have looked.
Show 8 quoted lines
> +#define READ_ONE_HEX(shift) do { \
> +	int val = hexval(buf[0]); \
> +	if (val < 0) { \
> +		warning("error on %d", *buf); \
> +		rpc->pktline_state = RPC_PKTLINE_ERROR; \
> +		return; \
> +	} \
> +	rpc->pktline_len |= val << shift; \
Nit: parenthesize shift here, since it is a parameter to a macro.
Previous: Jeff KingNext: Jeff King
Message 6 of 18 in “remote-curl: don't hang when a server dies before any output”
  1. remote-curl: don't hang when a server dies before any outputDavid Turner, Nov 9, 2016
  2. Jeff KingNov 14, 2016
  3. Jeff KingNov 14, 2016
  4. Junio C HamanoNov 14, 2016
  5. Jeff KingNov 14, 2016
  6. David TurnerNov 14, 2016
  7. Jeff KingNov 14, 2016
  8. David TurnerNov 15, 2016
  9. Jeff KingNov 15, 2016
  10. Junio C HamanoNov 15, 2016
  11. Jeff KingNov 15, 2016
  12. Junio C HamanoNov 15, 2016
  13. Jeff KingNov 18, 2016
  14. David TurnerNov 18, 2016
  15. Jeff KingNov 18, 2016
  16. David TurnerNov 18, 2016
  17. Junio C HamanoNov 18, 2016
  18. Jeff KingNov 15, 2016

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.