diff options
author | Eric Wong <e@80x24.org> | 2020-09-27 22:12:48 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-09-28 05:48:14 +0000 |
commit | 8ba04f214bbadcbe106c94281a0c4c21dd50adb8 (patch) | |
tree | a225cd4a836ead39d6b1f2dc4a72f81409684db6 /lib/PublicInbox/GitAsyncCat.pm | |
parent | 28dec3a76687617a3a697058964dc0bd1351eb6b (diff) | |
download | public-inbox-8ba04f214bbadcbe106c94281a0c4c21dd50adb8.tar.gz |
gcf2: improve error handling and do not ->fail on wbuf
For historical reasons, both Danga::Socket::write and PublicInbox::DS::write will return 0 when data is buffered; so Gcf2Client must not call ->fail when DS::write returns 0. We'll also improve robustness by recreating the entire Gcf2Client object if it does die for other reasons, instead of risking mismatched fields due to deferred close. We also need to ensure we only get one EPOLLERR wakeup and issue EPOLL_CTL_DEL if ->event_step is triggered by a dying Gcf2 process, so always register the FD with EPOLLONESHOT.
Diffstat (limited to 'lib/PublicInbox/GitAsyncCat.pm')
-rw-r--r-- | lib/PublicInbox/GitAsyncCat.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm index b9dbe0cc..be51f673 100644 --- a/lib/PublicInbox/GitAsyncCat.pm +++ b/lib/PublicInbox/GitAsyncCat.pm @@ -53,14 +53,21 @@ sub event_step { sub git_async_cat ($$$$) { my ($git, $oid, $cb, $arg) = @_; - my $gitish = $GCF2C; - if ($gitish) { + my $gitish = $GCF2C //= eval { + require PublicInbox::Gcf2; + require PublicInbox::Gcf2Client; + PublicInbox::Gcf2Client::new(); + } // 0; # 0: do not retry if libgit2 or Inline::C are missing + if ($gitish) { # Gcf2 active, {inflight} may be unset due to errors + $GCF2C->{inflight} or + $gitish = $GCF2C = PublicInbox::Gcf2Client::new(); $oid .= " $git->{git_dir}"; } else { $gitish = $git; } $gitish->cat_async($oid, $cb, $arg); $gitish->{async_cat} //= do { + # read-only end of pipe (Gcf2Client is write-only end) my $self = bless { gitish => $gitish }, __PACKAGE__; $self->SUPER::new($gitish->{in}, EPOLLIN|EPOLLET); \undef; # this is a true ref() |