user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
			download mbox.gz: |
* [PATCH] qspawn: psgi_qx: delay callback until waitpid returns
@ 2019-10-31  5:36  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2019-10-31  5:36 UTC (permalink / raw)
  To: meta

We need to detect "git apply" failures reliably when patches
fail.  This is necessary for solving for blob 81c1164ae5 in
https://public-inbox.org/git/ when at least two messages can
solve for it (and one of them fails):

1. https://public-inbox.org/git/b9fb52b8-8168-6bf0-9a72-1e6c44a281a5@oracle.com/
2. https://public-inbox.org/git/56664222-6c29-09dc-ef78-7b380b113c4a@oracle.com/
---
 lib/PublicInbox/Qspawn.pm | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index cb3dc51..651fa39 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -106,17 +106,22 @@ sub waitpid_err ($$) {
 		}
 	}
 
-	return unless $err;
-	$self->{err} = $err;
-	if ($env && !$env->{'qspawn.quiet'}) {
-		log_err($env, join(' ', @{$self->{args}}) . ": $err");
+	if ($err) {
+		$self->{err} = $err;
+		if ($env && !$env->{'qspawn.quiet'}) {
+			log_err($env, join(' ', @{$self->{args}}) . ": $err");
+		}
+	}
+	if (my $fin_cb = delete $self->{fin_cb}) {
+		eval { $fin_cb->() }
 	}
 }
 
-sub do_waitpid ($;$) {
-	my ($self, $env) = @_;
+sub do_waitpid ($;$$) {
+	my ($self, $env, $fin_cb) = @_;
 	my $pid = $self->{pid};
 	$self->{env} = $env;
+	$self->{fin_cb} = $fin_cb;
 	# PublicInbox::DS may not be loaded
 	eval { PublicInbox::DS::dwaitpid($pid, \&waitpid_err, $self) };
 	# done if we're running in PublicInbox::DS::EventLoop
@@ -127,10 +132,12 @@ sub do_waitpid ($;$) {
 	}
 }
 
-sub finish ($;$) {
-	my ($self, $env) = @_;
+sub finish ($;$$) {
+	my ($self, $env, $fin_cb) = @_;
 	if (delete $self->{rpipe}) {
-		do_waitpid($self, $env);
+		do_waitpid($self, $env, $fin_cb);
+	} elsif ($fin_cb) {
+		eval { $fin_cb->() };
 	}
 }
 
@@ -154,9 +161,8 @@ sub psgi_qx {
 	my $end = sub {
 		my $err = $_[0]; # $!
 		log_err($env, "psgi_qx: $err") if defined($err);
-		finish($self, $env);
-		eval { $qx_cb->(\$scalar) };
-		$qx = $scalar = undef;
+		finish($self, $env, sub { $qx_cb->(\$scalar) });
+		$qx = undef;
 	};
 	my $rpipe; # comes from popen_rd
 	my $async = $env->{'pi-httpd.async'};

^ permalink raw reply	[relevance 7%]

Results 1-1 of 1 | reverse
2019-10-31  5:36  7% [PATCH] qspawn: psgi_qx: delay callback until waitpid returns Eric Wong

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git