X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=tests%2Fhelper%2Fserver.inc;h=af71a0e2a66f2244ed350f0801e46fa5cb1e6aed;hp=091ff5cd483834d5c88d7e6304b42270bad9fe91;hb=71f54fe93cc20ac23c317fd6c7aa93732e9aa766;hpb=e57370d1f00da9e12de0917a9f907281ab8e84b5 diff --git a/tests/helper/server.inc b/tests/helper/server.inc index 091ff5c..af71a0e 100644 --- a/tests/helper/server.inc +++ b/tests/helper/server.inc @@ -55,11 +55,12 @@ function serve($cb) { stream_socket_enable_crypto($client, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER); } try { - while (!feof($client)) { + $R = array($client); + while (!feof($client) && stream_select($R, $W, $E, 1, 0)) { logger("serve: Handle client %d", (int) $client); $cb($client); } - logger("serve: EOF on client %d", (int) $client); + logger("serve: EOF/timeout on client %d", (int) $client); } catch (Exception $ex) { logger("serve: Exception on client %d: %s", (int) $client, $ex->getMessage()); /* ignore disconnect */ @@ -94,9 +95,9 @@ function nghttpd($cb) { $stdout = $pipes[1]; $stderr = $pipes[2]; - usleep(50000); + sleep(1); $status = proc_get_status($proc); - + logger("nghttpd: %s", new http\Params($status)); if (!$status["running"]) { continue; } @@ -120,6 +121,7 @@ function nghttpd($cb) { function proc($bin, $args, $cb) { $spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w")); $comm = escapeshellcmd($bin) . " ". implode(" ", array_map("escapeshellarg", $args)); + logger("proc: %s %s", $bin, implode(" ", $args)); if (($proc = proc_open($comm, $spec, $pipes, __DIR__))) { $stdin = $pipes[0]; $stdout = $pipes[1];