From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 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.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 631201FAF3; Sat, 10 Dec 2022 10:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1670666504; bh=odsJvhj6a2mnJXUVJjQ+PTC0bAoGFiDS+76gzRapVs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iBsUuIY5Kpl0a/S1S/sGAtWO+gws8TO67DXAl6jGG1D7zfnPhP+EyW43Xw0aF/n6q +jGZwlk0qMUPi8V9+iEmJUS+Kx3NWT9xjPv8/P6QrP8MDEnOhoL2eXtXsxVGZSoEk/ tkoel5bUXPbooK+g91dU53rhyy06s8pWbBMrwTE4= From: Eric Wong To: mwrap-perl@80x24.org Cc: Eric Wong Subject: [PATCH 2/4] t/mwrap-httpd: better errors for local socket failures Date: Sat, 10 Dec 2022 10:01:42 +0000 Message-Id: <20221210100144.19796-3-e@80x24.org> In-Reply-To: <20221210100144.19796-1-e@80x24.org> References: <20221210100144.19796-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: From: Eric Wong The syswrite() needs to be replaced by send(.*MSG_NOSIGNAL), but I'm ignoring SIGPIPE anyways in case connect() somehow triggers it. In any case, I'm noticing the local socket created in Perl (not curl) sometimes fails the first send/write and/or fails the second send/write syscall. Maybe this can help diagnose things... --- t/mwrap-httpd.t | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/t/mwrap-httpd.t b/t/mwrap-httpd.t index a1bf333..b7076de 100644 --- a/t/mwrap-httpd.t +++ b/t/mwrap-httpd.t @@ -37,16 +37,16 @@ my $cleanup = sub { END { $cleanup->() } my $sock = "$mwrap_tmp/$pid.sock"; -my $n = 10000; -my $c; my %o = (Peer => $sock , Type => SOCK_STREAM); -while (!$c && --$n > 0) { - $c = IO::Socket::UNIX->new(%o) or - select undef, undef, undef, 0.011; +local $SIG{PIPE} = 'IGNORE'; +my $c; +for (1..10000) { + last if -S $sock && ($c = IO::Socket::UNIX->new(%o)); + select undef, undef, undef, 0.011; } ok(-S $sock, 'socket created'); ok($c, 'socket connected'); -is(syswrite($c, 'GET'), 3, 'trickled 3 bytes'); +is(send($c, 'GET', MSG_NOSIGNAL), 3, 'trickled 3 bytes') or diag "send: $!"; my $cout = "$mwrap_tmp/cout"; my $rc = system(qw(curl -vsSf --unix-socket), $sock, '-o', $cout, @@ -67,12 +67,11 @@ SKIP: { is($rc, 0, 'curl /reset'); }; -local $SIG{PIPE} = 'IGNORE'; { my $req = " /$pid/each/20000 HTTP/1.0\r\n\r\n"; - is(syswrite($c, $req), length($req), 'wrote rest of response') or - diag "syswrite: $!"; - my $x = do { local $/; <$c> } or diag "read: $!"; + is(send($c, $req, MSG_NOSIGNAL), length($req), + 'wrote rest of response') or diag "send: $!"; + my $x = do { local $/; <$c> } or diag "readline: $!"; like($x, qr!\n?\z!s, 'got complete HTML response'); }