Changeset View
Changeset View
Standalone View
Standalone View
src/hgdaemon/ArcanistHgProxyServer.php
| Show First 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | while (true) { | ||||
| PhutilChannel::waitForAny( | PhutilChannel::waitForAny( | ||||
| array_merge($clients, array($hg)), | array_merge($clients, array($hg)), | ||||
| array( | array( | ||||
| 'read' => $socket ? array($socket) : array(), | 'read' => $socket ? array($socket) : array(), | ||||
| 'except' => $socket ? array($socket) : array() | 'except' => $socket ? array($socket) : array() | ||||
| )); | )); | ||||
| if (!$hg->update()) { | if (!$hg->update()) { | ||||
| throw new Exception("Server exited unexpectedly!"); | throw new Exception('Server exited unexpectedly!'); | ||||
| } | } | ||||
| // Accept any new clients. | // Accept any new clients. | ||||
| while ($socket && ($client = $this->acceptNewClient($socket))) { | while ($socket && ($client = $this->acceptNewClient($socket))) { | ||||
| $clients[] = $client; | $clients[] = $client; | ||||
| $key = last_key($clients); | $key = last_key($clients); | ||||
| $client->setName($key); | $client->setName($key); | ||||
| ▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | private function startWorkingCopySocket() { | ||||
| if ($errno || !$socket) { | if ($errno || !$socket) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "Unable to start socket! Error #{$errno}: {$errstr}"); | "Unable to start socket! Error #{$errno}: {$errstr}"); | ||||
| } | } | ||||
| $ok = stream_set_blocking($socket, 0); | $ok = stream_set_blocking($socket, 0); | ||||
| if ($ok === false) { | if ($ok === false) { | ||||
| throw new Exception("Unable to set socket nonblocking!"); | throw new Exception('Unable to set socket nonblocking!'); | ||||
| } | } | ||||
| return $socket; | return $socket; | ||||
| } | } | ||||
| /** | /** | ||||
| * @task client | * @task client | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | if (function_exists('posix_isatty')) { | ||||
| } | } | ||||
| if (!posix_isatty(STDERR)) { | if (!posix_isatty(STDERR)) { | ||||
| $keep_stderr = true; | $keep_stderr = true; | ||||
| } | } | ||||
| } | } | ||||
| $pid = pcntl_fork(); | $pid = pcntl_fork(); | ||||
| if ($pid === -1) { | if ($pid === -1) { | ||||
| throw new Exception("Unable to fork!"); | throw new Exception('Unable to fork!'); | ||||
| } else if ($pid) { | } else if ($pid) { | ||||
| // We're the parent; exit. First, drop our reference to the socket so | // We're the parent; exit. First, drop our reference to the socket so | ||||
| // our __destruct() doesn't tear it down; the child will tear it down | // our __destruct() doesn't tear it down; the child will tear it down | ||||
| // later. | // later. | ||||
| $this->socket = null; | $this->socket = null; | ||||
| exit(0); | exit(0); | ||||
| } | } | ||||
| Show All 15 Lines | |||||