about summary refs log tree commit homepage
path: root/lib/PublicInbox/GzipFilter.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-05-01 23:29:35 +0000
committerEric Wong <e@80x24.org>2023-05-02 13:06:36 +0000
commit9f2dfa6dbec4b5e162a9f4812351f567bbc331ee (patch)
tree85a19de2e117818798de3ec4d97453c46d37a381 /lib/PublicInbox/GzipFilter.pm
parent0de8537965927d200a36363d8f776e4ca5036ed8 (diff)
downloadpublic-inbox-9f2dfa6dbec4b5e162a9f4812351f567bbc331ee.tar.gz
daemon: improve handling of Git->async_abort
The $oid arg for Git->cat_async is defined on async_abort using
the original request, so use undefined $type to distinguish that
case in caller-supplied callbacks.  async_abort isn't common, of
course, but sometimes git subprocesses can die unexpectedly.
Diffstat (limited to 'lib/PublicInbox/GzipFilter.pm')
-rw-r--r--lib/PublicInbox/GzipFilter.pm15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/PublicInbox/GzipFilter.pm b/lib/PublicInbox/GzipFilter.pm
index a37080c8..db8e8397 100644
--- a/lib/PublicInbox/GzipFilter.pm
+++ b/lib/PublicInbox/GzipFilter.pm
@@ -172,7 +172,7 @@ sub close {
         (delete($self->{http_out}) // return)->close;
 }
 
-sub bail  {
+sub bail {
         my $self = shift;
         carp @_;
         my $env = $self->{env} or return;
@@ -188,16 +188,19 @@ sub async_blob_cb { # git->cat_async callback
         my ($bref, $oid, $type, $size, $self) = @_;
         my $http = $self->{env}->{'psgix.io'}; # PublicInbox::HTTP
         $http->{forward} or return; # client aborted
-        my $smsg = $self->{smsg} or bail($self, 'BUG: no smsg');
-        if (!defined($oid)) {
+        my $smsg = $self->{smsg} or return bail($self, 'BUG: no smsg');
+        $type // return
+                bail($self, "abort: $smsg->{blob} $self->{ibx}->{inboxdir}");
+        if ($type ne 'blob') {
                 # it's possible to have TOCTOU if an admin runs
                 # public-inbox-(edit|purge), just move onto the next message
-                warn "E: $smsg->{blob} missing in $self->{ibx}->{inboxdir}\n";
+                warn "E: $smsg->{blob} $type in $self->{ibx}->{inboxdir}\n";
                 return $http->next_step($self->can('async_next'));
         }
-        $smsg->{blob} eq $oid or bail($self, "BUG: $smsg->{blob} != $oid");
+        $smsg->{blob} eq $oid or return
+                bail($self, "BUG: $smsg->{blob} != $oid");
         eval { $self->async_eml(PublicInbox::Eml->new($bref)) };
-        bail($self, "E: async_eml: $@") if $@;
+        return bail($self, "E: async_eml: $@") if $@;
         if ($self->{-low_prio}) { # run via PublicInbox::WWW::event_step
                 push(@{$self->{www}->{-low_prio_q}}, $self) == 1 and
                                 PublicInbox::DS::requeue($self->{www});