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

Re: [RFC PATCH] http-backend: write error packet if backend command fails

From
Jeff King <peff@peff.net>
Date
Mar 28, 2020, 14:57 UTC
Message-ID
<20200328145741.GA1209174@coredump.intra.peff.net>
In-Reply-To
<b5f8b81498e1d152014acab92fa1b6e9701b3a0e.1585363771.git.liu.denton@gmail.com>
On Fri, Mar 27, 2020 at 10:50:32PM -0400, Denton Liu wrote:
Show 6 quoted lines
> If one tries to fetch packs with an incorrectly formatted parameter
> while using the smart HTTP protocol v2, the client will block forever.
> This is seen with the following command which does not terminate:
> 
> 	$ git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012
> 	Cloning into 'git'...

That can't possibly be fixed by a change to http-backend.c, because github.com does not use git-http-backend. :)

We have a custom proxy layer that terminates the http connection, and speaks to "upload-pack --stateless-rpc" on the backend. There may be a bug in that proxy layer, but it's usually pretty robust to upload-pack hanging up the connection.

But since it works for v1 (which also dies!), and since you were able to reproduce the problem locally, I suspect it may be an issue in upload-pack itself.

Show 5 quoted lines
> This happens because when upload-pack detects invalid parameters, it
> will die(). When http-backend calls finish_command() and detects a
> non-zero exit code, it will simply call exit(1). Since there is no way
> in a CGI script to force a connection to terminate, the client keeps
> blocking on the read(), expecting more output.

When the CGI exits, that should close the descriptor it holds. If the webserver hands off the socket to the CGI, that would be sufficient. If it doesn't, then it should notice the CGI exiting and close the socket itself.

> Write an error packet if the backend command fails to start or finishes
> with an error so that the client can terminate the connection.

This is probably not a good idea; we don't know what state the protocol was in when the child died.

-Peff
Previous: Denton LiuNext: Jeff King
Message 2 of 5 in “http-backend: write error packet if backend command fails”
  1. http-backend: write error packet if backend command failsDenton Liu, Mar 28, 2020
  2. Jeff KingMar 28, 2020
  3. Jeff KingMar 28, 2020
  4. Jeff KingMar 28, 2020
  5. Denton LiuMar 29, 2020

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.