X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fhelper%2Fpipeline.inc;h=a6b16999c373b3835396edd44f17e5e4428e554f;hb=b07c0c2ee31a9061674c2d4e941769129b6e0e86;hp=b7175c109fac1b24d4f4a31e000e08cda288ae4d;hpb=e867316f1364f589eec67cc684703c874984430b;p=m6w6%2Fext-http diff --git a/tests/helper/pipeline.inc b/tests/helper/pipeline.inc index b7175c1..a6b1699 100644 --- a/tests/helper/pipeline.inc +++ b/tests/helper/pipeline.inc @@ -10,17 +10,24 @@ function respond($client, $msg) { } serve(function($client) { + $R = array(STDIN); $W = $E = array(); + if (!stream_select($R, $W, $E, 10, 0)) { + logger("Client %d timed out", (int) $client); + return; + } $count = trim(fgets(STDIN)); - + logger("Expecting %d messages from client %d", $count, (int) $client); /* the peek message */ respond($client, new http\Message($client, false)); - + logger("Handled the peek request of client %d", (int) $client); /* pipelined messages */ $req = array(); for ($i=0; $i < $count; ++ $i) { $req[] = new http\Message($client, false); + logger("Read request no. %d from client %d", $i+1, (int) $client); } - foreach ($req as $msg) { + foreach ($req as $i => $msg) { respond($client, $msg); + logger("Sent response no. %d to client %d", $i+1, (int) $client); } });