]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: drop EOFpipe in favor of PktOp
authorEric Wong <e@80x24.org>
Fri, 21 May 2021 10:28:26 +0000 (10:28 +0000)
committerEric Wong <e@80x24.org>
Sun, 23 May 2021 01:33:02 +0000 (01:33 +0000)
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
lib/PublicInbox/LeiOverview.pm

index 98e79a76f75f6d9af88f5c288ee98673f20ca345..d77684265972e1bb0696fdb2fb341309ba06ef8a 100644 (file)
@@ -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);
                };
index bfb8b1435ff25f21e5ea603138d8138c5eab964b..28891460e49a1ed70bbb44beff75c1161e8b0456 100644 (file)
@@ -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') {