Git development
 help / color / mirror / Atom feed
* [PATCH] connected: close err_fd in promisor fast-path
@ 2026-05-15  6:39 Ethan via GitGitGadget
  0 siblings, 0 replies; only message in thread
From: Ethan via GitGitGadget @ 2026-05-15  6:39 UTC (permalink / raw)
  To: git; +Cc: Ethan, Ethan Dickson

From: Ethan Dickson <ethanndickson@gmail.com>

connected.h documents that err_fd is closed before check_connected()
returns. It is, on three of four exit paths. The promisor-pack fast
path added in 50033772d (connected: verify promisor-ness of partial
clone, 2020-01-30) returns 0 without closing it.

receive-pack uses err_fd as the write end of an async sideband
muxer's pipe, and the muxer thread waits for EOF. The same omission
has caused deadlocks there twice before: 49ecfa13f (receive-pack:
close sideband fd on early pack errors, 2013-04-19) and 6cdad1f13
(receive-pack: fix deadlock when we cannot create tmpdir,
2017-03-07).

Signed-off-by: Ethan Dickson <ethanndickson@gmail.com>
---
    connected: close err_fd in promisor fast-path

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2303%2Fethanndickson%2Fconnected-close-err-fd-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2303/ethanndickson/connected-close-err-fd-v1
Pull-Request: https://github.com/git/git/pull/2303

 connected.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/connected.c b/connected.c
index 6718503649..7e26976832 100644
--- a/connected.c
+++ b/connected.c
@@ -76,6 +76,8 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
 promisor_pack_found:
 			;
 		} while ((oid = fn(cb_data)) != NULL);
+		if (opt->err_fd)
+			close(opt->err_fd);
 		return 0;
 	}
 

base-commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-15  6:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15  6:39 [PATCH] connected: close err_fd in promisor fast-path Ethan via GitGitGadget

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox