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

[PATCH 5/6] send-pack: read "unpack" status even on pack-objects failure

From
Jeff King <peff@peff.net>
Date
Mar 7, 2017, 13:38 UTC
Message-ID
<20170307133850.aaykcpuzlzqecz7x@sigill.intra.peff.net>
In-Reply-To
<20170307133437.qee2jtynbiwf6uzr@sigill.intra.peff.net>

If the local pack-objects of a push fails, we'll tell the user about it. But one likely cause is that the remote index-pack stopped reading for some reason (because it didn't like our input, or encountered another error). In that case we'd expect the remote to report more details to us via the "unpack ..." status line. However, the current code just hangs up completely, and the user never sees it.

Instead, let's call receive_unpack_status(), which will complain on stderr with whatever reason the remote told us. Note that if our pack-objects fails because the connection was severed or the remote just crashed entirely, then our packet_read_line() call may fail with "the remote end hung up unexpectedly". That's OK. It's a more accurate description than what we get now (which is just "some refs failed to push").

This should be safe from any deadlocks. At the point we make this call we'll have closed the writing end of the connection to the server (either by handing it off to a pack-objects which exited, explicitly in the stateless_rpc case, or by doing a half-duplex shutdown for a socket). So there should be no chance that the other side is waiting for the rest of our pack-objects input.

Signed-off-by: Jeff King <peff@peff.net>
---
 send-pack.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/send-pack.c b/send-pack.c
index 83c23aef6..e15232739 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -562,6 +562,14 @@ int send_pack(struct send_pack_args *args,
 				close(out);
 			if (git_connection_is_socket(conn))
 				shutdown(fd[0], SHUT_WR);
+
+			/*
+			 * Do not even bother with the return value; we know we
+			 * are failing, and just want the error() side effects.
+			 */
+			if (status_report)
+				receive_unpack_status(in);
+
 			if (use_sideband) {
 				close(demux.out);
 				finish_async(&demux);
-- 
2.12.0.429.gde83c8049
Previous: Jeff KingNext: Jeff King
Message 5 of 12 in “deadlock regression in v2.11.0 with failed mkdtemp”
  1. 0/6 deadlock regression in v2.11.0 with failed mkdtempJeff King, Mar 7, 2017
  2. 1/6 receive-pack: fix deadlock when we cannot create tmpdirJeff King, Mar 7, 2017
  3. 2/6 send-pack: extract parsing of "unpack" responseJeff King, Mar 7, 2017
  4. 6/6 send-pack: report signal death of pack-objectsJeff King, Mar 7, 2017
  5. 5/6 send-pack: read "unpack" status even on pack-objects failureJeff King, Mar 7, 2017
  6. 4/6 send-pack: improve unpack-status error messagesJeff King, Mar 7, 2017
  7. Junio C HamanoMar 7, 2017
  8. Jeff KingMar 8, 2017
  9. Junio C HamanoMar 8, 2017
  10. Jeff KingMar 7, 2017
  11. 3/6 send-pack: use skip_prefix for parsing unpack statusJeff King, Mar 7, 2017
  12. Horst SchirmeierMar 8, 2017

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.