git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: Re: [PATCH 1/2] run-command: provide in_async query function
Date: Tue, 1 Sep 2015 16:26:10 -0400	[thread overview]
Message-ID: <20150901202609.GA8063@sigill.intra.peff.net> (raw)
In-Reply-To: <20150901202243.GA6931@sigill.intra.peff.net>

On Tue, Sep 01, 2015 at 04:22:43PM -0400, Jeff King wrote:

> diff --git a/run-command.c b/run-command.c
> index 3277cf7..c8029f2 100644
> --- a/run-command.c
> +++ b/run-command.c

This diff is a little funny to read because the interesting context is
far away, and it is not immediately obvious why we are defining the
function twice. This:

> @@ -595,7 +595,7 @@ static NORETURN void die_async(const char *err, va_list params)
>  {
>  	vreportf("fatal: ", err, params);
>  
> -	if (!pthread_equal(main_thread, pthread_self())) {
> +	if (in_async()) {
>  		struct async *async = pthread_getspecific(async_key);
>  		if (async->proc_in >= 0)
>  			close(async->proc_in);
> @@ -614,6 +614,13 @@ static int async_die_is_recursing(void)
>  	return ret != NULL;
>  }
>  
> +int in_async(void)
> +{
> +	if (!main_thread_set)
> +		return 0; /* no asyncs started yet */
> +	return !pthread_equal(main_thread, pthread_self());
> +}
> +
>  #else

is all inside #ifndef NO_PTHREADS, and this:

> @@ -653,6 +660,12 @@ int git_atexit(void (*handler)(void))
>  }
>  #define atexit git_atexit
>  
> +static int process_is_async;
> +int in_async(void)
> +{
> +	return process_is_async;
> +}
> +
>  #endif

is the "#else" case where we fork.

-Peff

  reply	other threads:[~2015-09-01 20:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 20:22 [PATCH 0/2] clarify sideband muxing in GIT_TRACE_PACKET Jeff King
2015-09-01 20:22 ` [PATCH 1/2] run-command: provide in_async query function Jeff King
2015-09-01 20:26   ` Jeff King [this message]
2015-09-01 22:09   ` Junio C Hamano
2015-09-01 22:17     ` Jeff King
2015-09-01 20:24 ` [PATCH 2/2] pkt-line: show packets in async processes as "sideband" Jeff King
2015-09-01 22:13   ` Junio C Hamano
2015-09-01 22:22     ` Jeff King
2015-09-01 22:23     ` Stefan Beller
2015-09-01 22:26       ` Jeff King
2015-09-01 22:31         ` Stefan Beller
2015-09-01 22:38           ` 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=20150901202609.GA8063@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    /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).