From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 000711F5A0 for ; Fri, 10 Feb 2023 08:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1676019402; bh=F5L8Z+INrPrlciOFVVZssJwKMVhv0qopchxnM2qxg58=; h=From:To:Subject:Date:From; b=M771ZPaQ3K1eUg73il7DEHvmmbDKhN+flBGy90HK92ve3yaBZt3jZtRcxmrx32Fp2 zhzt40R1juzW5dRUfYzSck78Lcq9F1x72OhvM+GI+2sIWjdQ+Xzl4IQEl5pkKLT/kp o5CMh6p5UDwAJZcomHhkJ4452w7bOn0R/64i68Jk= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] git_async_cat: use awaitpid Date: Fri, 10 Feb 2023 08:56:41 +0000 Message-Id: <20230210085641.18154-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While awaitpid already registered a no-op callback in _bidi_pipe, we can still call it again when registering it into our event loop to ensure EPOLL_CTL_DEL fires. --- lib/PublicInbox/GitAsyncCat.pm | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm index 49a3c602..c428f6ef 100644 --- a/lib/PublicInbox/GitAsyncCat.pm +++ b/lib/PublicInbox/GitAsyncCat.pm @@ -6,6 +6,7 @@ package PublicInbox::GitAsyncCat; use v5.12; use parent qw(PublicInbox::DS Exporter); +use PublicInbox::DS qw(awaitpid); use POSIX qw(WNOHANG); use PublicInbox::Syscall qw(EPOLLIN EPOLLET); our @EXPORT = qw(ibx_async_cat ibx_async_prefetch async_check); @@ -21,6 +22,8 @@ sub close { $self->SUPER::close; # PublicInbox::DS::close } +sub aclose { $_[1]->close } # ignore PID ($_[0]) + sub event_step { my ($self) = @_; my $git = $self->{git} or return; @@ -36,12 +39,6 @@ sub event_step { # ok, more to do, requeue for fairness $self->requeue; } - } elsif ((my $pid = waitpid($git->{pid}, WNOHANG)) > 0) { - # May happen if the child process is killed by a BOFH - # (or segfaults) - delete $git->{pid}; - warn "E: git $pid exited with \$?=$?\n"; - $self->close; } } @@ -51,6 +48,7 @@ sub watch_cat { my $self = bless { git => $git }, __PACKAGE__; $git->{in}->blocking(0); $self->SUPER::new($git->{in}, EPOLLIN|EPOLLET); + awaitpid($git->{pid}, \&aclose, $self); \undef; # this is a true ref() }; } @@ -83,6 +81,7 @@ sub async_check ($$$$) { my $self = bless { git => $git }, 'PublicInbox::GitAsyncCheck'; $git->{in_c}->blocking(0); $self->SUPER::new($git->{in_c}, EPOLLIN|EPOLLET); + awaitpid($git->{pid_c}, \&aclose, $self); \undef; # this is a true ref() }; } @@ -126,12 +125,6 @@ sub event_step { # ok, more to do, requeue for fairness $self->requeue; } - } elsif ((my $pid = waitpid($git->{pid_c}, WNOHANG)) > 0) { - # May happen if the child process is killed by a BOFH - # (or segfaults) - delete $git->{pid_c}; - warn "E: git $pid exited with \$?=$?\n"; - $self->close; } }