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

[PATCH] fetch-pack: close output channel after sideband demultiplexer terminates

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Jun 8, 2009, 08:51 UTC
Message-ID
<4A2CD10A.3000703@viscovery.net>
In-Reply-To
<4A28D2EF.8040704@viscovery.net>
From: Johannes Sixt <j6t@kdbg.org>

fetch-pack runs the sideband demultiplexer using start_async(). This facility requires that the asynchronously executed function closes the output file descriptor (see Documentation/technical/api-run-command.txt). But the sideband demultiplexer did not do that. This fixes it.

In certain error situations this could lock up a fetch operation on Windows because the asynchronous function is run in a thread; by not closing the output fd the reading end never got EOF and waited for more data indefinitely. On Unix this is not a problem because the asynchronous function is run in a separate process, which exits after the function ends and so implicitly closes the output.

Since the pack that is sent over the wire encodes the number of objects in the stream, during normal operation the reading end knows when the stream ends and terminates by itself, and does not lock up.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 Johannes Sixt schrieb:
 > FYI, with this patch MinGW git hangs in t5530.8; the test-case exercises
 > the new code path.
 This fixes the lockup.
 -- Hannes
 builtin-fetch-pack.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 2eb7a22..b11d799 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -487,7 +487,9 @@ static int sideband_demux(int fd, void *data)
 {
 	int *xd = data;

-	return recv_sideband("fetch-pack", xd[0], fd);
+	int ret = recv_sideband("fetch-pack", xd[0], fd);
+	close(fd);
+	return ret;
 }

 static int get_pack(int xd[2], char **pack_lockfile)
-- 
1.6.3.1.1141.gcf6b0.dirty
Previous: Johannes SixtNext: Nicolas Pitre
Message 4 of 15 in “[WIP] Shift rev-list enumeration from upload-pack to pack-objects”
  1. sam@vilain.netJun 5, 2009
  2. Sam VilainJun 5, 2009
  3. Johannes SixtJun 5, 2009
  4. fetch-pack: close output channel after sideband demultiplexer terminatesJohannes Sixt, Jun 8, 2009
  5. Nicolas PitreJun 5, 2009
  6. Nick EdelenJun 7, 2009
  7. Nick EdelenJun 7, 2009
  8. Nicolas PitreJun 7, 2009
  9. Nick EdelenJun 7, 2009
  10. Nick EdelenJun 7, 2009
  11. Sam VilainJun 7, 2009
  12. Nicolas PitreJun 7, 2009
  13. Nick EdelenJun 7, 2009
  14. Nicolas PitreJun 8, 2009
  15. Junio C HamanoJun 8, 2009

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.