]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/lei
send and receive all 3 FDs at once
[public-inbox.git] / script / lei
index 0457adfd0204d213e6a5d6365aece13410b9c639..029881f8a70d1cdcda66b4c17c55cfb1a9e47590 100755 (executable)
@@ -1,11 +1,14 @@
 #!perl -w
-# Copyright (C) 2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
 use Socket qw(AF_UNIX SOCK_STREAM pack_sockaddr_un);
+my $send_3fds;
 if (my ($sock, $pwd) = eval {
-       require IO::FDPass; # will try to use a daemon to reduce load time
+       require PublicInbox::Spawn;
+       $send_3fds = PublicInbox::Spawn->can('send_3fds') or die
+               "Inline::C not installed/configured or IO::FDPass missing\n";
        my $path = do {
                my $runtime_dir = ($ENV{XDG_RUNTIME_DIR} // '') . '/lei';
                if ($runtime_dir eq '/lei') {
@@ -57,7 +60,7 @@ Falling back to (slow) one-shot mode
        $buf .= "\0\0";
        select $sock;
        $| = 1; # unbuffer selected $sock
-       IO::FDPass::send(fileno($sock), $_) for (0..2);
+       $send_3fds->(fileno($sock), 0, 1, 2);
        print $sock $buf or die "print(sock, buf): $!";
        while ($buf = <$sock>) {
                $buf =~ /\Aexit=([0-9]+)\n\z/ and exit($1 + 0);