git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Cc: Force Charlie via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Force Charlie <charlieio@outlook.com>,
	Jeff King <peff@peff.net>
Subject: Re: [PATCH] Correctly initialize 'installed_handlers'
Date: Fri, 08 May 2020 08:36:36 -0700	[thread overview]
Message-ID: <xmqqy2q2zbej.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20200508083340.GA36538@Carlos-MBP> ("Carlo Marcelo Arenas =?utf-8?Q?Bel=C3=B3n=22's?= message of "Fri, 8 May 2020 01:33:40 -0700")

Carlo Marcelo Arenas Belón <carenas@gmail.com> writes:

> the way this is handled would seem to indicate otherwise
>
> if (!installed_handlers) {
>                 atexit(remove_tmp_objdir);
>                 sigchain_push_common(remove_tmp_objdir_on_signal);
>                 installed_handlers++;
> }

It is a curious piece of code.  

The "prepare a file-scope static and do something and increment it
when it is 0" pattern expects the function to be called many times
and do the guarded thing only once.  However, there is this code:

	if (the_tmp_objdir)
		BUG(...);

before we do anything else, and then before that "arrange to clean
up, but do so just once" block, there is

	the_tmp_objdir = t;

where t is the pointer to a "struct tmp_objdir" instance.  So one
part of the function expects to be called at most once, while
another part is prepared to be called more than once.

Almost all of this function is attributed to 2564d994 (tmp-objdir:
introduce API for temporary object directories, 2016-10-03), so
let's see if Peff remembers anything about this curiosity.

Thanks.

  reply	other threads:[~2020-05-08 15:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08  7:05 [PATCH] Correctly initialize 'installed_handlers' Force Charlie via GitGitGadget
2020-05-08  8:33 ` Carlo Marcelo Arenas Belón
2020-05-08 15:36   ` Junio C Hamano [this message]
2020-05-08 17:24     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy2q2zbej.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=carenas@gmail.com \
    --cc=charlieio@outlook.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).