From 15f98820ca5434f40410a6fceed1e37e50ab68a7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 30 Jun 2019 22:32:32 +0000 Subject: t/httpd-unix.t: avoid race in between bind() and listen() 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/httpd-unix.t b/t/httpd-unix.t index 758277c9..04f4b8fa 100644 --- a/t/httpd-unix.t +++ b/t/httpd-unix.t @@ -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 } -- cgit v1.2.3-24-ge0c7