diff options
author | Eric Wong <e@80x24.org> | 2020-12-31 13:51:49 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-01 05:00:40 +0000 |
commit | d59a9cb667f106b29363795539b55116077bcd80 (patch) | |
tree | 759a3964b8f74a5a6a99c6c2545f467e465813e8 /lib/PublicInbox/Gcf2Client.pm | |
parent | 2b5d41f3a1b55ae513e9d5510d830074234fda37 (diff) | |
download | public-inbox-d59a9cb667f106b29363795539b55116077bcd80.tar.gz |
This simplifies our code and provides a more consistent API for error handling. PublicInbox::DS can be loaded nowadays on all *BSDs and Linux distros easily without extra packages to install. The downside is possibly increased startup time, but it's probably not as a big problem with lei being a daemon (and -mda possibly following suite).
Diffstat (limited to 'lib/PublicInbox/Gcf2Client.pm')
-rw-r--r-- | lib/PublicInbox/Gcf2Client.pm | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/PublicInbox/Gcf2Client.pm b/lib/PublicInbox/Gcf2Client.pm index 4bda5520..10820852 100644 --- a/lib/PublicInbox/Gcf2Client.pm +++ b/lib/PublicInbox/Gcf2Client.pm @@ -9,6 +9,7 @@ use PublicInbox::Git; use PublicInbox::Spawn qw(popen_rd); use IO::Handle (); use PublicInbox::Syscall qw(EPOLLONESHOT); +use PublicInbox::DS qw(dwaitpid); # fields: # async_cat => GitAsyncCat ref (read-only pipe) # sock => writable pipe to Gcf2::loop @@ -65,18 +66,11 @@ no warnings 'once'; sub DESTROY { my ($self) = @_; - my $pid = delete $self->{pid}; delete $self->{in}; - return unless $pid; - eval { - PublicInbox::DS::dwaitpid($pid, undef, undef); - $self->close; # we're still in the event loop - }; - if ($@) { # wait synchronously if not in event loop - my $sock = delete $self->{sock}; - close $sock if $sock; - waitpid($pid, 0); - } + # GitAsyncCat::event_step may reap us with WNOHANG, too + my $pid = delete $self->{pid} or return; + PublicInbox::DS->in_loop ? $self->close : delete($self->{sock}); + dwaitpid $pid; } # used by GitAsyncCat |