Changeset View
Changeset View
Standalone View
Standalone View
src/hgdaemon/ArcanistHgClientChannel.php
Context not available. | |||||
$channel = head($argv); | $channel = head($argv); | ||||
$data = last($argv); | $data = last($argv); | ||||
$len = strlen($data); | $len = @strlen($data); | ||||
$len = pack('N', $len); | $len = pack('N', $len); | ||||
return "{$channel}{$len}{$data}"; | return "{$channel}{$len}{$data}"; | ||||
Context not available. | |||||
// We're looking for "\n", which indicates the end of the command | // We're looking for "\n", which indicates the end of the command | ||||
// name, like "runcommand". Next, we'll expect a length. | // name, like "runcommand". Next, we'll expect a length. | ||||
$pos = strpos($this->buf, "\n"); | $pos = @strpos($this->buf, "\n"); | ||||
if ($pos === false) { | if ($pos === false) { | ||||
break; | break; | ||||
} | } | ||||
$this->command = substr($this->buf, 0, $pos); | $this->command = @substr($this->buf, 0, $pos); | ||||
$this->buf = substr($this->buf, $pos + 1); | $this->buf = @substr($this->buf, $pos + 1); | ||||
$this->mode = self::MODE_LENGTH; | $this->mode = self::MODE_LENGTH; | ||||
$continue_parsing = true; | $continue_parsing = true; | ||||
Context not available. | |||||
// We're looking for a byte length, as a 4-byte big-endian unsigned | // We're looking for a byte length, as a 4-byte big-endian unsigned | ||||
// integer. Next, we'll expect that many bytes of data. | // integer. Next, we'll expect that many bytes of data. | ||||
if (strlen($this->buf) < 4) { | if (@strlen($this->buf) < 4) { | ||||
break; | break; | ||||
} | } | ||||
$len = substr($this->buf, 0, 4); | $len = @substr($this->buf, 0, 4); | ||||
$len = unpack('N', $len); | $len = unpack('N', $len); | ||||
$len = head($len); | $len = head($len); | ||||
$this->buf = substr($this->buf, 4); | $this->buf = @substr($this->buf, 4); | ||||
$this->mode = self::MODE_ARGUMENTS; | $this->mode = self::MODE_ARGUMENTS; | ||||
$this->byteLengthOfNextChunk = $len; | $this->byteLengthOfNextChunk = $len; | ||||
Context not available. | |||||
// of the given length. These are arguments delimited by "\0". Next | // of the given length. These are arguments delimited by "\0". Next | ||||
// we'll expect another command. | // we'll expect another command. | ||||
if (strlen($this->buf) < $this->byteLengthOfNextChunk) { | if (@strlen($this->buf) < $this->byteLengthOfNextChunk) { | ||||
break; | break; | ||||
} | } | ||||
$data = substr($this->buf, 0, $this->byteLengthOfNextChunk); | $data = @substr($this->buf, 0, $this->byteLengthOfNextChunk); | ||||
$this->buf = substr($this->buf, $this->byteLengthOfNextChunk); | $this->buf = @substr($this->buf, $this->byteLengthOfNextChunk); | ||||
$message = array_merge(array($this->command), explode("\0", $data)); | $message = array_merge(array($this->command), @explode("\0", $data)); | ||||
$this->mode = self::MODE_COMMAND; | $this->mode = self::MODE_COMMAND; | ||||
$this->command = null; | $this->command = null; | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0