From e97a30e7624dfb8645aa33a94844bcf28c7e1379 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 7 Nov 2023 13:01:47 +0000 Subject: lei: fix SIGPIPE on large result sets to pager When dealing with large search results, we need to deal with EPIPE not just from the pager, but also EPIPE or ECONNRESET between lei_xsearch and lei2mail processes. Without this fix, lei_xsearch processes could linger and get stuck writing to dead lei2mail processes if a user aborts the pager early during a large result set. To ensure lei_xsearch processes don't linger around after lei2mail workers all die, we must close $l2m->{-wq_s2} before spawning lei_xsearch processes, since $l2m->{-wq_s2} is only used in lei2mail workers. For `git cat-file' processes, we also need to trigger PublicInbox::Git->close to handle unpredictable destructor ordering to avoid using uninitialized IO refs. This combines with the `git_to_mail' change to deal with process cleanup handling from premature shutdowns. To test all this, we can't just rely on a single message being large, but also need to rely on the result set being large enough to saturate the lei_xsearch -> lei2mail socket so we rely on GIANT_INBOX_DIR once again. --- lib/PublicInbox/Git.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 11712db2..292c359a 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -276,6 +276,7 @@ sub cat_async_step ($$) { sub cat_async_wait ($) { my ($self) = @_; + $self->close if !$self->{sock}; my $inflight = $self->{inflight} or return; while (scalar(@$inflight)) { cat_async_step($self, $inflight); @@ -331,6 +332,7 @@ sub check_async_wait ($) { my ($self) = @_; return cat_async_wait($self) if $self->{-bc}; my $ck = $self->{ck} or return; + $ck->close if !$ck->{sock}; my $inflight = $ck->{inflight} or return; check_async_step($ck, $inflight) while (scalar(@$inflight)); } -- cgit v1.2.3-24-ge0c7