From 762ce165685c677e780b87668658c939bd88c709 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 19 Feb 2015 21:07:03 +0100 Subject: [PATCH] use a random port offset --- tests/helper/server.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/helper/server.inc b/tests/helper/server.inc index 265a861..e3b7af6 100644 --- a/tests/helper/server.inc +++ b/tests/helper/server.inc @@ -11,7 +11,11 @@ if ($php) { } function serve($cb) { - foreach (range(8000+PHP_INT_SIZE, 9000) as $port) { + /* stream_socket_server() automatically sets SO_REUSEADDR, + * which is, well, bad if the tests are run in parallel + */ + $offset = rand(0,2000); + foreach (range(8000+$offset, 9000+$offset) as $port) { if (($server = @stream_socket_server("tcp://localhost:$port"))) { fprintf(STDERR, "%s\n", $port); do { -- 2.30.2