All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Robin Jarry <robin@jarry.cc>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	git@vger.kernel.org,
	"Nicolas Dichtel" <nicolas.dichtel@6wind.com>,
	"Jan Smets" <jan.smets@nokia.com>,
	"Stephen Morton" <stephen.morton@nokia.com>,
	"Jeff King" <peff@peff.net>
Subject: Re: [PATCH v2] receive-pack: ignore SIGPIPE while reporting status to client
Date: Tue, 09 Nov 2021 13:10:26 -0800	[thread overview]
Message-ID: <xmqqzgqd11dp.fsf@gitster.g> (raw)
In-Reply-To: <20211106220358.144886-1-robin@jarry.cc> (Robin Jarry's message of "Sat, 6 Nov 2021 23:03:59 +0100")

Robin Jarry <robin@jarry.cc> writes:

> When a remote client exits while the pre-receive hook is running,
> receive-pack is not killed by SIGPIPE because the signal is ignored.
> This is a side effect of commit ec7dbd145bd8 (receive-pack: allow hooks
> to ignore its standard input stream, 2014-09-12).
>
> The pre-receive hook itself is not interrupted and does not receive any
> error since its stdout is a pipe which is read in an async thread and
> output back to the client socket in a side band channel.
>
> After the pre-receive has exited the SIGPIPE default handler is restored
> and if the hook did not report any error, objects are migrated from
> temporary to permanent storage.

All of the above talks about the pre-receive hook, but it is unclear
how that is relevant to this change.  The first paragraph says
"... is not killed", and if that was a bad thing (in other words, it
should be killed but is not, and that is a bug worth fixing), and if
this patch changes the behaviour, then that paragraph is worth
saying.  Similarly for the other two.

> Before running the post-receive hook, status info is reported back to
> the client. Since the client has died, receive-pack is killed by SIGPIPE
> and post-receive is never executed.

In other words, regardless of what happens (or does not happen) to
the pre-receive hook, which may not even exist, if "git push" dies
before the post-receive hook runs, this paragraph applies, no?  

What I am getting at is that this can (and should) be the first
paragraph of the description without losing clarity.

> Ignore SIGPIPE before reporting status to the client to increase the
> chances of post-receive running if pre-receive was successful. This does
> not guarantee 100% consistency but it should resist early disconnection
> by the client.

OK.

> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> index 49b846d96052..5fe7992028d4 100644
> --- a/builtin/receive-pack.c
> +++ b/builtin/receive-pack.c
> @@ -2564,12 +2564,14 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
>  		use_keepalive = KEEPALIVE_ALWAYS;
>  		execute_commands(commands, unpack_status, &si,
>  				 &push_options);
> +		sigchain_push(SIGPIPE, SIG_IGN);
>  		if (pack_lockfile)
>  			unlink_or_warn(pack_lockfile);

Shouldn't we start ignoring SIGPIPE here, not before we try to
unlink the lockfile?

>  		if (report_status_v2)
>  			report_v2(commands, unpack_status);
>  		else if (report_status)
>  			report(commands, unpack_status);
> +		sigchain_pop(SIGPIPE);

In other words, push/pop pair should surround the part that reports
the status, as the proposed commit log message said.

>  		run_receive_hook(commands, "post-receive", 1,
>  				 &push_options);
>  		run_update_post_hook(commands);

Other than these, looks good to me.

Thanks.

  reply	other threads:[~2021-11-09 21:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04 13:35 [RFC PATCH] receive-pack: run post-receive before reporting status Robin Jarry
2021-11-06  5:03 ` Ævar Arnfjörð Bjarmason
2021-11-06 21:32   ` Robin Jarry
2021-11-06 22:03 ` [PATCH v2] receive-pack: ignore SIGPIPE while reporting status to client Robin Jarry
2021-11-09 21:10   ` Junio C Hamano [this message]
2021-11-09 21:38     ` Robin Jarry
2021-11-09 23:03       ` Junio C Hamano
2021-11-10 10:35     ` [RFC PATCH] receive-pack: interrupt pre-receive when client disconnects Robin Jarry
2021-12-29 14:21       ` Robin Jarry
2021-11-10  9:29   ` [PATCH v3] receive-pack: ignore SIGPIPE while reporting status to client Robin Jarry
2021-11-18  9:36     ` Robin Jarry

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=xmqqzgqd11dp.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jan.smets@nokia.com \
    --cc=nicolas.dichtel@6wind.com \
    --cc=peff@peff.net \
    --cc=robin@jarry.cc \
    --cc=stephen.morton@nokia.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.