]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/GitAsyncCat.pm
imap+nntp: share COMPRESS implementation
[public-inbox.git] / lib / PublicInbox / GitAsyncCat.pm
index 7d1a13dbb48bb11fa1b68f97a4f32a1a65ccd6e0..cea3f539234ab2cb3864865c2798c5e073a4ba8d 100644 (file)
@@ -8,7 +8,7 @@ use strict;
 use parent qw(PublicInbox::DS Exporter);
 use POSIX qw(WNOHANG);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
-our @EXPORT = qw(git_async_cat git_async_prefetch);
+our @EXPORT = qw(ibx_async_cat ibx_async_prefetch);
 use PublicInbox::Git ();
 
 our $GCF2C; # singleton PublicInbox::Gcf2Client
@@ -16,7 +16,7 @@ our $GCF2C; # singleton PublicInbox::Gcf2Client
 sub close {
        my ($self) = @_;
        if (my $git = delete $self->{git}) {
-               $git->cat_async_abort;
+               $git->async_abort;
        }
        $self->SUPER::close; # PublicInbox::DS::close
 }
@@ -32,7 +32,7 @@ sub event_step {
                # child death?
                if (($git->{in} // 0) != ($self->{sock} // 1)) {
                        $self->close;
-               } elsif (@$inflight || exists $git->{cat_rbuf}) {
+               } elsif (@$inflight || exists $git->{rbuf}) {
                        # ok, more to do, requeue for fairness
                        $self->requeue;
                }
@@ -45,12 +45,16 @@ sub event_step {
        }
 }
 
-sub git_async_cat ($$$$) {
-       my ($git, $oid, $cb, $arg) = @_;
-       if ($GCF2C //= eval {
+sub ibx_async_cat ($$$$) {
+       my ($ibx, $oid, $cb, $arg) = @_;
+       my $git = $ibx->git;
+       # {topdir} means ExtSearch (likely [extindex "all"]) with potentially
+       # 100K alternates.  git(1) has a proposed patch for 100K alternates:
+       # <https://lore.kernel.org/git/20210624005806.12079-1-e@80x24.org/>
+       if (!defined($ibx->{topdir}) && ($GCF2C //= eval {
                require PublicInbox::Gcf2Client;
                PublicInbox::Gcf2Client::new();
-       } // 0) { # 0: do not retry if libgit2 or Inline::C are missing
+       } // 0)) { # 0: do not retry if libgit2 or Inline::C are missing
                $GCF2C->gcf2_async(\"$oid $git->{git_dir}\n", $cb, $arg);
                \undef;
        } else { # read-only end of git-cat-file pipe
@@ -66,9 +70,10 @@ sub git_async_cat ($$$$) {
 
 # this is safe to call inside $cb, but not guaranteed to enqueue
 # returns true if successful, undef if not.
-sub git_async_prefetch {
-       my ($git, $oid, $cb, $arg) = @_;
-       if ($GCF2C) {
+sub ibx_async_prefetch {
+       my ($ibx, $oid, $cb, $arg) = @_;
+       my $git = $ibx->git;
+       if (!defined($ibx->{topdir}) && $GCF2C) {
                if (!$GCF2C->{wbuf}) {
                        $oid .= " $git->{git_dir}\n";
                        return $GCF2C->gcf2_async(\$oid, $cb, $arg); # true