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 */
$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;
}
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];