From: Michael Wallner Date: Thu, 19 Feb 2015 20:07:03 +0000 (+0100) Subject: use a random port offset X-Git-Tag: RELEASE_2_3_0~7 X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=commitdiff_plain;h=762ce165685c677e780b87668658c939bd88c709 use a random port offset --- 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 {