Skip to contentSkip to conversation

connected: close err_fd in promisor fast-path

PATCH New Ethan via GitGitGadget 1 participant 1 message May 15

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 connected: close err_fd in promisor fast-path

From: Ethan Dickson <[email protected]>

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).

---
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(+)
connected.c +2 -0
index 6718503649..7e26976832 100644
@@ -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

Signature · 1 line
gitgitgadget