]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper: autodie for getsockopt
authorEric Wong <e@80x24.org>
Tue, 17 Oct 2023 23:37:56 +0000 (23:37 +0000)
committerEric Wong <e@80x24.org>
Wed, 18 Oct 2023 20:50:27 +0000 (20:50 +0000)
Only caveat is we can't use bareword filehandles, but that's
a minor inconvenience.

lib/PublicInbox/XapHelper.pm

index c31fe9a25bbba9de90e8034e2b8750251b75a754..eea10a44342f77b0f0898d5ad8fc516772f567ef 100644 (file)
@@ -13,11 +13,11 @@ use PublicInbox::IPC;
 use PublicInbox::Git qw(read_all);
 use Socket qw(SOL_SOCKET SO_TYPE SOCK_SEQPACKET AF_UNIX);
 use PublicInbox::DS qw(awaitpid);
-use autodie qw(open);
+use autodie qw(open getsockopt);
 use POSIX qw(:signal_h);
 use Fcntl qw(LOCK_UN LOCK_EX);
 my $X = \%PublicInbox::Search::X;
-our (%SRCH, %WORKERS, $alive, $nworker, $workerset);
+our (%SRCH, %WORKERS, $alive, $nworker, $workerset, $in);
 our $stderr = \*STDERR;
 
 # only short options for portability in C++ implementation
@@ -176,7 +176,6 @@ sub dispatch {
 sub recv_loop {
        local $SIG{__WARN__} = sub { print $stderr @_ };
        my $rbuf;
-       my $in = \*STDIN;
        local $SIG{TERM} = sub { undef $in };
        while (defined($in)) {
                PublicInbox::DS::sig_setmask($workerset);
@@ -247,7 +246,7 @@ sub xh_alive { $alive || scalar(keys %WORKERS) }
 
 sub start (@) {
        my (@argv) = @_;
-       my $c = getsockopt(STDIN, SOL_SOCKET, SO_TYPE) or die "getsockopt: $!";
+       my $c = getsockopt($in = \*STDIN, SOL_SOCKET, SO_TYPE);
        unpack('i', $c) == SOCK_SEQPACKET or die 'stdin is not SOCK_SEQPACKET';
 
        local (%SRCH, %WORKERS);