about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-09-26 08:08:37 +0000
committerEric Wong <e@80x24.org>2020-09-26 21:05:53 +0000
commit34880bc83077eac5739deca69f66df7685965064 (patch)
tree76cd1cf724f2b3bf01c3cf217a0061179cfecc72
parentf4728a1ef16593305956c4dada424353f57b3879 (diff)
downloadpublic-inbox-34880bc83077eac5739deca69f66df7685965064.tar.gz
This ought to save a few cycles if a client disconnects while
in the middle of a (UID) FETCH.  This avoids:

  Can't call method "git" on an undefined value at .../PublicInbox/IMAP.pm

errors in stderr.
-rw-r--r--lib/PublicInbox/IMAP.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index a861282f..37001da4 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -615,18 +615,19 @@ sub fetch_run_ops {
 sub fetch_blob_cb { # called by git->cat_async via git_async_cat
         my ($bref, $oid, $type, $size, $fetch_arg) = @_;
         my ($self, undef, $msgs, $range_info, $ops, $partial) = @$fetch_arg;
+        my $ibx = $self->{ibx} or return $self->close; # client disconnected
         my $smsg = shift @$msgs or die 'BUG: no smsg';
         if (!defined($oid)) {
                 # 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} missing in $ibx->{inboxdir}\n";
                 return requeue_once($self);
         } else {
                 $smsg->{blob} eq $oid or die "BUG: $smsg->{blob} != $oid";
         }
         my $pre;
         if (!$self->{wbuf} && (my $nxt = $msgs->[0])) {
-                $pre = git_async_prefetch($self->{ibx}->git, $nxt->{blob},
+                $pre = git_async_prefetch($ibx->git, $nxt->{blob},
                                                 \&fetch_blob_cb, $fetch_arg);
         }
         fetch_run_ops($self, $smsg, $bref, $ops, $partial);