From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 319421F9E5 for ; Fri, 21 May 2021 10:28:33 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/8] lei: drop EOFpipe in favor of PktOp Date: Fri, 21 May 2021 10:28:26 +0000 Message-Id: <20210521102832.10784-3-e@80x24.org> In-Reply-To: <20210521102832.10784-1-e@80x24.org> References: <20210521102832.10784-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: lei already uses PktOp and SOCK_SEQPACKET throughout; whereas EOFpipe had one single use in lei. Since PktOp is a strict superset of EOFpipe functionality, we may be able to get rid of EOFpipe entirely. However, lei is considered a portability canary and I'm not sure if the stable public-inbox-* code can drop EOFpipe just yet. --- lib/PublicInbox/LEI.pm | 9 ++++----- lib/PublicInbox/LeiOverview.pm | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 98e79a76..d7768426 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1151,7 +1151,7 @@ sub lazy_start { (Socket::MsgHdr || Inline::C) missing/unconfigured (narg=$narg); require PublicInbox::Listener; - require PublicInbox::EOFpipe; + require PublicInbox::PktOp; (-p STDOUT) or die "E: stdout must be a pipe\n"; open(STDIN, '+>>', $errors_log) or die "open($errors_log): $!"; STDIN->autoflush(1); @@ -1165,13 +1165,12 @@ sub lazy_start { my $exit_code; my $pil = PublicInbox::Listener->new($listener, \&accept_dispatch); local $quit = do { - pipe(my ($eof_r, $eof_w)) or die "pipe: $!"; - PublicInbox::EOFpipe->new($eof_r, \&noop, undef); + my (undef, $eof_p) = PublicInbox::PktOp->pair; sub { $exit_code //= shift; my $lis = $pil or exit($exit_code); - # closing eof_w triggers \&noop wakeup - $listener = $eof_w = $pil = $path = undef; + # closing eof_p triggers \&noop wakeup + $listener = $eof_p = $pil = $path = undef; $lis->close; # DS::close PublicInbox::DS->SetLoopTimeout(1000); }; diff --git a/lib/PublicInbox/LeiOverview.pm b/lib/PublicInbox/LeiOverview.pm index bfb8b143..28891460 100644 --- a/lib/PublicInbox/LeiOverview.pm +++ b/lib/PublicInbox/LeiOverview.pm @@ -119,7 +119,7 @@ sub ovv_begin { } # TODO HTML/Atom/... } -# called once by parent (via PublicInbox::EOFpipe) +# called once by parent (via PublicInbox::PktOp '' => query_done) sub ovv_end { my ($self, $lei) = @_; if ($self->{fmt} eq 'json') {