summaryrefslogtreecommitdiff
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2022-01-12 15:11:43 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2022-01-12 15:11:43 -0800
commit12f82b0dd70aaefdb9363a96403d41d13b97e5b0 (patch)
treed2de6d99648f1901c8b72c1fbbe7744aeade71f4 /builtin/fetch.c
parentMerge branch 'ma/header-dup-cleanup' (diff)
parentfetch: fix deadlock when cleaning up lockfiles in async signals (diff)
downloadtgif-12f82b0dd70aaefdb9363a96403d41d13b97e5b0.tar.xz
Merge branch 'ps/lockfile-cleanup-fix'
Some lockfile code called free() in signal-death code path, which has been corrected. * ps/lockfile-cleanup-fix: fetch: fix deadlock when cleaning up lockfiles in async signals
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index eaab8056bf..5f06b21f8e 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -223,17 +223,22 @@ static struct option builtin_fetch_options[] = {
OPT_END()
};
-static void unlock_pack(void)
+static void unlock_pack(unsigned int flags)
{
if (gtransport)
- transport_unlock_pack(gtransport);
+ transport_unlock_pack(gtransport, flags);
if (gsecondary)
- transport_unlock_pack(gsecondary);
+ transport_unlock_pack(gsecondary, flags);
+}
+
+static void unlock_pack_atexit(void)
+{
+ unlock_pack(0);
}
static void unlock_pack_on_signal(int signo)
{
- unlock_pack();
+ unlock_pack(TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER);
sigchain_pop(signo);
raise(signo);
}
@@ -1329,7 +1334,7 @@ static int fetch_and_consume_refs(struct transport *transport,
trace2_region_leave("fetch", "consume_refs", the_repository);
out:
- transport_unlock_pack(transport);
+ transport_unlock_pack(transport, 0);
return ret;
}
@@ -1978,7 +1983,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
gtransport->server_options = &server_options;
sigchain_push_common(unlock_pack_on_signal);
- atexit(unlock_pack);
+ atexit(unlock_pack_atexit);
sigchain_push(SIGPIPE, SIG_IGN);
exit_code = do_fetch(gtransport, &rs);
sigchain_pop(SIGPIPE);