summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2020-12-01 12:15:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-01 20:05:58 (GMT)
commit309a4028e72b5f6050d5cf17b5056cc3ea14c16b (patch)
tree2dffc05c7a786a49558a67214a7d14afc439ab8f /upload-pack.c
parent898f80736c75878acc02dc55672317fcc0e0a5a6 (diff)
downloadgit-309a4028e72b5f6050d5cf17b5056cc3ea14c16b.zip
git-309a4028e72b5f6050d5cf17b5056cc3ea14c16b.tar.gz
git-309a4028e72b5f6050d5cf17b5056cc3ea14c16b.tar.bz2
upload-pack: kill pack-objects helper on signal or exit
We spawn an external pack-objects process to actually send objects to the remote side. If we are killed by a signal during this process, then pack-objects may continue to run. As soon as it starts producing output for the pack, it will see a failure writing to upload-pack and exit itself. But before then, it may do significant work traversing the object graph, compressing deltas, etc, which will all be pointless. So let's make sure to kill as soon as we know that the caller will not read the result. There's no test here, since it's inherently racy, but here's an easy reproduction is on a large-ish repo like linux.git: - make sure you don't have pack bitmaps (since they make the enumerating phase go quickly). For linux.git it takes ~30s or so to walk the whole graph on my machine. - run "git clone --no-local -q . dst"; the "-q" is important because if pack-objects is writing progress to upload-pack (to get multiplexed over the sideband to the client), then it will notice pretty quickly the failure to write to stderr - kill the client-side clone process in another terminal (don't use ^C, as that will send SIGINT to all of the processes) - run "ps au | grep git" or similar to observe upload-pack dying within 5 seconds (it will send a keepalive that will notice the client has gone away) - but you'll still see pack-objects consuming 100% CPU (and 1GB+ of RAM) during the traversal and delta compression phases. It will exit as soon as it starts to write the pack (when it will notice that upload-pack went away). With this patch, pack-objects exits as soon as upload-pack does. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 3b858eb..d4f7192 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -321,6 +321,7 @@ static void create_pack_file(struct upload_pack_data *pack_data,
pack_objects.in = -1;
pack_objects.out = -1;
pack_objects.err = -1;
+ pack_objects.clean_on_exit = 1;
if (start_command(&pack_objects))
die("git upload-pack: unable to fork git-pack-objects");