Skip to content

Commit 2a4aed4

Browse files
peffgitster
authored andcommitted
fetch-pack: ignore SIGPIPE when writing to index-pack
When fetching, we send the incoming pack to index-pack (or unpack-objects) via the sideband demuxer. If index-pack hits an error (e.g., because an object fails fsck), then it will die immediately. This may cause us to get SIGPIPE on the fetch, as we're still trying to write pack contents from the sideband demuxer (which is typically a thread, and thus takes down the whole fetch process). You can see this in action with: ./t5702-protocol-v2.sh --stress --run=59 which ends with (wrapped for readability): test_must_fail: died by signal 13: git -c protocol.version=2 \ -c transfer.fsckobjects=1 -c fetch.uriprotocols=http,https \ clone http://127.0.0.1:5708/smart/http_parent http_child not ok 59 - packfile-uri with transfer.fsckobjects fails on bad object This is mostly cosmetic. The actual error of interest (in this case, the object that failed the fsck check) comes from index-pack straight to stderr, so the user still sees it. They _might_ even see fetch-pack complaining about index-pack failing, because the main thread is racing with the sideband-demuxer. But they'll definitely see the signal death in the exit code, which is what the test is complaining about. We can make this more predictable by just ignoring SIGPIPE. The sideband demuxer uses write_or_die(), so it will notice and stop (gracefully, because we hook die_routine() to exit just the thread). And during this section we're not writing anywhere else where we'd be concerned about SIGPIPE preventing us from wasting effort writing to nowhere. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fbd2fc commit 2a4aed4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fetch-pack.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "shallow.h"
2626
#include "commit-reach.h"
2727
#include "commit-graph.h"
28+
#include "sigchain.h"
2829

2930
static int transfer_unpack_limit = -1;
3031
static int fetch_unpack_limit = -1;
@@ -945,6 +946,8 @@ static int get_pack(struct fetch_pack_args *args,
945946
strvec_push(index_pack_args, cmd.args.v[i]);
946947
}
947948

949+
sigchain_push(SIGPIPE, SIG_IGN);
950+
948951
cmd.in = demux.out;
949952
cmd.git_cmd = 1;
950953
if (start_command(&cmd))
@@ -975,6 +978,8 @@ static int get_pack(struct fetch_pack_args *args,
975978
if (use_sideband && finish_async(&demux))
976979
die(_("error in sideband demultiplexer"));
977980

981+
sigchain_pop(SIGPIPE);
982+
978983
/*
979984
* Now that index-pack has succeeded, write the promisor file using the
980985
* obtained .keep filename if necessary

0 commit comments

Comments
 (0)