about summary refs log tree commit homepage
path: root/lib/PublicInbox/GitAsyncCat.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-11-29 10:52:29 +0000
committerEric Wong <e@80x24.org>2020-11-30 00:47:32 +0000
commitf68c45d33656a4602c2d8b8c1a8be813f8a9a70d (patch)
tree3aad75a457a7a65c092528a48316cc2cf54a9585 /lib/PublicInbox/GitAsyncCat.pm
parentea885bf0f76dc1795dc771667be721ec0fed5482 (diff)
downloadpublic-inbox-f68c45d33656a4602c2d8b8c1a8be813f8a9a70d.tar.gz
This makes GitAsyncCat more resilient to bugs in Gcf2 or even
git-cat-file itself.  I noticed -imapd stuck on read(2) from
the Gcf2 pipe, so there may be a bug somewhere in Gcf2 or
PublicInbox::Git.  This should make us more resilient to them
and hopefully help us notice and fix them.
Diffstat (limited to 'lib/PublicInbox/GitAsyncCat.pm')
-rw-r--r--lib/PublicInbox/GitAsyncCat.pm6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm
index be51f673..dc97af16 100644
--- a/lib/PublicInbox/GitAsyncCat.pm
+++ b/lib/PublicInbox/GitAsyncCat.pm
@@ -3,11 +3,6 @@
 #
 # internal class used by PublicInbox::Git + PublicInbox::DS
 # This parses the output pipe of "git cat-file --batch"
-#
-# Note: this does NOT set the non-blocking flag, we expect `git cat-file'
-# to be a local process, and git won't start writing a blob until it's
-# fully read.  So minimize context switching and read as much as possible
-# and avoid holding a buffer in our heap any longer than it has to live.
 package PublicInbox::GitAsyncCat;
 use strict;
 use parent qw(PublicInbox::DS Exporter);
@@ -69,6 +64,7 @@ sub git_async_cat ($$$$) {
         $gitish->{async_cat} //= do {
                 # read-only end of pipe (Gcf2Client is write-only end)
                 my $self = bless { gitish => $gitish }, __PACKAGE__;
+                $gitish->{in}->blocking(0);
                 $self->SUPER::new($gitish->{in}, EPOLLIN|EPOLLET);
                 \undef; # this is a true ref()
         };