summaryrefslogtreecommitdiff
path: root/shallow.c
diff options
context:
space:
mode:
authorEtienne Buira <etienne.buira@gmail.com>2014-10-18 14:31:15 +0200
committerJunio C Hamano <gitster@pobox.com>2014-10-19 15:38:30 -0700
commit0f4b6db3baeff8de53769b38f439408abd5a42f7 (patch)
treed39a29a7792df19e576e67c8cee9f68d4f54e2ea /shallow.c
parent0c45d258ec35c1ef51523dd45e4518bd8a09258c (diff)
downloadgit-0f4b6db3baeff8de53769b38f439408abd5a42f7.tar.gz
Handle atexit list internaly for unthreaded buildseb/no-pthreads
Wrap atexit()s calls on unthreaded builds to handle callback list internally. This is needed because on unthreaded builds, asyncs inherits parent's atexit() list, that gets run as soon as the async exit()s (and again at the end of async's parent process). That led to remove temporary files too early. Also remove a by-atexit-callback guard against this kind of issue in clone.c, as this patch makes it redundant. Fixes test 5537 (temporary shallow file vanished before unpack-objects could open it) BTW remove an unused variable in shallow.c. Helped-by: Duy Nguyen <pclouds@gmail.com> Helped-by: Andreas Schwab <schwab@linux-m68k.org> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Etienne Buira <etienne.buira@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'shallow.c')
-rw-r--r--shallow.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/shallow.c b/shallow.c
index 57f4afa6b4..0cc3d47634 100644
--- a/shallow.c
+++ b/shallow.c
@@ -226,7 +226,6 @@ static void remove_temporary_shallow_on_signal(int signo)
const char *setup_temporary_shallow(const struct sha1_array *extra)
{
- static int installed_handler;
struct strbuf sb = STRBUF_INIT;
int fd;
@@ -237,10 +236,8 @@ const char *setup_temporary_shallow(const struct sha1_array *extra)
strbuf_addstr(&temporary_shallow, git_path("shallow_XXXXXX"));
fd = xmkstemp(temporary_shallow.buf);
- if (!installed_handler) {
- atexit(remove_temporary_shallow);
- sigchain_push_common(remove_temporary_shallow_on_signal);
- }
+ atexit(remove_temporary_shallow);
+ sigchain_push_common(remove_temporary_shallow_on_signal);
if (write_in_full(fd, sb.buf, sb.len) != sb.len)
die_errno("failed to write to %s",