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.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 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 F39681F461 for ; Sun, 30 Jun 2019 22:32:32 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] t/httpd-unix.t: avoid race in between bind() and listen() Date: Sun, 30 Jun 2019 22:32:32 +0000 Message-Id: <20190630223232.73227-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 db652479..4fe2d1eb 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 } -- EW