From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E4DBF1F723 for ; Tue, 17 Oct 2023 23:38:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1697585897; bh=D43O3Hbr7iSqGjJj0SdR42z3uKMJVUtTms/tHSvYubM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q4JBTGAd2Sld/5j1nWeOnS34nX7Lehf46wY3RBwpYIdD42Wc85gM+sgQR7iS7f+GB 0slXyOr30+n95VMmQWVv6FASfHbkHGrqLZJyWhF8+XDdFw3YKhE8qr8KnhbtibhO4/ 2jDfgBAoTUxqyh+j8Voadcnqd+kCXgzqTCh+hNSY= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 11/30] xap_helper: autodie for getsockopt Date: Tue, 17 Oct 2023 23:37:56 +0000 Message-ID: <20231017233815.1637932-12-e@80x24.org> In-Reply-To: <20231017233815.1637932-1-e@80x24.org> References: <20231017233815.1637932-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Only caveat is we can't use bareword filehandles, but that's a minor inconvenience. --- lib/PublicInbox/XapHelper.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm index c31fe9a2..eea10a44 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);