]> Sergey Matveev's repositories - public-inbox.git/commitdiff
t/httpd-unix.t: avoid race in between bind() and listen()
authorEric Wong <e@80x24.org>
Sun, 30 Jun 2019 22:32:32 +0000 (22:32 +0000)
committerEric Wong <e@80x24.org>
Sun, 30 Jun 2019 22:32:57 +0000 (22:32 +0000)
We need to be able to successfully connect() to the socket
before attempting further tests.  Merely testing for the
existence of a socket isn't enough, since the server may've
only done bind(), not listen().

t/httpd-unix.t

index 758277c9d67977304663346fed62b3e1d5e984de..04f4b8fa9807e239f2224b3f31308bdc7e563127 100644 (file)
@@ -42,8 +42,9 @@ my $spawn_httpd = sub {
 
 ok(!-S $unix, 'UNIX socket does not exist, yet');
 $spawn_httpd->("-l$unix");
+my %o = (Peer => $unix, Type => SOCK_STREAM);
 for (1..1000) {
-       last if -S $unix;
+       last if -S $unix && IO::Socket::UNIX->new(%o);
        select undef, undef, undef, 0.02
 }