diff options
author | Eric Wong <normalperson@yhbt.net> | 2022-12-10 10:01:42 +0000 |
---|---|---|
committer | Eric Wong <mwrap-perl@80x24.org> | 2022-12-10 20:24:54 +0000 |
commit | 730f10e5e652fca4f4d142af8c0bb5c99053a0ae (patch) | |
tree | 2a7f2745f828e7f7c7b6ecbfc80614ef935fcef1 | |
parent | 3aa81154d7363e30de61025a6d1bb661682ae08a (diff) | |
download | mwrap-730f10e5e652fca4f4d142af8c0bb5c99053a0ae.tar.gz |
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...
-rw-r--r-- | t/mwrap-httpd.t | 19 |
1 files 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!</html>\n?\z!s, 'got complete HTML response'); } |