Differential D18857 Diff 45233 src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/ssh/DiffusionMercurialWireClientSSHProtocolChannel.php
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | while (true) { | ||||
$this->expectBytes = $size; | $this->expectBytes = $size; | ||||
$this->argumentName = $arg; | $this->argumentName = $arg; | ||||
$this->state = 'argv-value'; | $this->state = 'argv-value'; | ||||
$this->expectArgumentCount--; | $this->expectArgumentCount--; | ||||
} else { | } else { | ||||
$this->state = 'arguments'; | $this->state = 'arguments'; | ||||
} | } | ||||
} else if ($this->state == 'data-length') { | } else if ($this->state == 'data-length') { | ||||
amckinley: Not a huge deal, but for consistency with the other branches in this function, it would be nice… | |||||
$line = $this->readProtocolLine(); | $line = $this->readProtocolLine(); | ||||
if ($line === null) { | if ($line === null) { | ||||
break; | break; | ||||
} | } | ||||
$this->expectBytes = (int)$line; | $this->expectBytes = (int)$line; | ||||
if (!$this->expectBytes) { | if (!$this->expectBytes) { | ||||
$messages[] = $this->newDataMessage(''); | $messages[] = $this->newDataMessage(''); | ||||
$this->initializeState(); | $this->initializeState(); | ||||
} else { | } else { | ||||
$this->state = 'data-bytes'; | $this->state = 'data-bytes'; | ||||
} | } | ||||
} else if ($this->state == 'data-bytes') { | } else if ($this->state == 'data-bytes') { | ||||
// If we don't have any more bytes on the buffer yet, just bail: | |||||
// otherwise, we'll emit a pointless and possibly harmful 0-byte data | |||||
// frame. See T13036 for discussion. | |||||
if (!strlen($this->buffer)) { | |||||
break; | |||||
} | |||||
$bytes = substr($this->buffer, 0, $this->expectBytes); | $bytes = substr($this->buffer, 0, $this->expectBytes); | ||||
$this->buffer = substr($this->buffer, strlen($bytes)); | $this->buffer = substr($this->buffer, strlen($bytes)); | ||||
$this->expectBytes -= strlen($bytes); | $this->expectBytes -= strlen($bytes); | ||||
$messages[] = $this->newDataMessage($bytes); | $messages[] = $this->newDataMessage($bytes); | ||||
if (!$this->expectBytes) { | if (!$this->expectBytes) { | ||||
// We've finished reading this chunk, so go read the next chunk. | // We've finished reading this chunk, so go read the next chunk. | ||||
Show All 15 Lines |
Not a huge deal, but for consistency with the other branches in this function, it would be nice to have a comment block here.