From: Eric Wong Date: Tue, 17 Oct 2023 23:37:56 +0000 (+0000) Subject: xap_helper: autodie for getsockopt X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f8cbc7c4a5b5e328c2e6adeae4f320a08c5321a;p=thirdparty%2Fpublic-inbox.git xap_helper: autodie for getsockopt Only caveat is we can't use bareword filehandles, but that's a minor inconvenience. --- diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm index c31fe9a25..eea10a443 100644 --- a/lib/PublicInbox/XapHelper.pm +++ b/lib/PublicInbox/XapHelper.pm @@ -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);