git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Robin Jarry <robin@jarry.cc>
To: Junio C Hamano <gitster@pobox.com>
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>, "Robin Jarry" <robin@jarry.cc>
Subject: [PATCH v3] receive-pack: ignore SIGPIPE while reporting status to client
Date: Wed, 10 Nov 2021 10:29:42 +0100	[thread overview]
Message-ID: <20211110092942.1648429-1-robin@jarry.cc> (raw)
In-Reply-To: <20211106220358.144886-1-robin@jarry.cc>

Before running the post-receive hook, status info is reported back to
the client. If a remote client exits before or during the status report,
receive-pack is killed by SIGPIPE and post-receive is never executed.

The post-receive hook is often used to send email notifications (see
contrib/hooks/post-receive-email), update bug trackers, start automatic
builds, etc. Not executing it after an interrupted yet "successful" push
can lead to inconsistencies.

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.

Signed-off-by: Robin Jarry <robin@jarry.cc>
---
Changes since v2:

* Updated commit log with more pertinent info.
* Only ignore SIGPIPE while reporting status, *after* removing the lock
  file.

 builtin/receive-pack.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 49b846d96052..2f4a38adfe2c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -2566,10 +2566,12 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 				 &push_options);
 		if (pack_lockfile)
 			unlink_or_warn(pack_lockfile);
+		sigchain_push(SIGPIPE, SIG_IGN);
 		if (report_status_v2)
 			report_v2(commands, unpack_status);
 		else if (report_status)
 			report(commands, unpack_status);
+		sigchain_pop(SIGPIPE);
 		run_receive_hook(commands, "post-receive", 1,
 				 &push_options);
 		run_update_post_hook(commands);
-- 
2.34.0.rc2.2.gbcf7eca935e4


  parent reply	other threads:[~2021-11-10  9:30 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
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   ` Robin Jarry [this message]
2021-11-18  9:36     ` [PATCH v3] receive-pack: ignore SIGPIPE while reporting status to client 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20211110092942.1648429-1-robin@jarry.cc \
    --to=robin@jarry.cc \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jan.smets@nokia.com \
    --cc=nicolas.dichtel@6wind.com \
    --cc=peff@peff.net \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).