Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/ssh/PhabricatorSSHPassthruCommand.php
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | while (true) { | ||||
if (!$this->pauseIOReads) { | if (!$this->pauseIOReads) { | ||||
$in_message = $io_channel->read(); | $in_message = $io_channel->read(); | ||||
if ($in_message !== null) { | if ($in_message !== null) { | ||||
$this->writeIORead($in_message); | $this->writeIORead($in_message); | ||||
} | } | ||||
} | } | ||||
$out_message = $command_channel->read(); | $out_message = $command_channel->read(); | ||||
if (strlen($out_message)) { | if (phutil_nonempty_string($out_message)) { | ||||
$out_message = $this->willReadData($out_message); | $out_message = $this->willReadData($out_message); | ||||
if ($out_message !== null) { | if ($out_message !== null) { | ||||
$io_channel->write($out_message); | $io_channel->write($out_message); | ||||
} | } | ||||
} | } | ||||
// If we have nothing left on stdin, close stdin on the subprocess. | // If we have nothing left on stdin, close stdin on the subprocess. | ||||
if (!$io_channel->isOpenForReading()) { | if (!$io_channel->isOpenForReading()) { | ||||
Show All 21 Lines | list($err) = $this->execFuture | ||||
->setReadBufferSize(null) | ->setReadBufferSize(null) | ||||
->resolve(); | ->resolve(); | ||||
return $err; | return $err; | ||||
} | } | ||||
public function writeIORead($in_message) { | public function writeIORead($in_message) { | ||||
$in_message = $this->willWriteData($in_message); | $in_message = $this->willWriteData($in_message); | ||||
if (strlen($in_message)) { | if (phutil_nonempty_string($in_message)) { | ||||
$this->commandChannel->write($in_message); | $this->commandChannel->write($in_message); | ||||
} | } | ||||
} | } | ||||
public function willWriteData($message) { | public function willWriteData($message) { | ||||
if ($this->willWriteCallback) { | if ($this->willWriteCallback) { | ||||
return call_user_func($this->willWriteCallback, $this, $message); | return call_user_func($this->willWriteCallback, $this, $message); | ||||
} else { | } else { | ||||
if (strlen($message)) { | if (phutil_nonempty_string($message)) { | ||||
return $message; | return $message; | ||||
} else { | } else { | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public function willReadData($message) { | public function willReadData($message) { | ||||
if ($this->willReadCallback) { | if ($this->willReadCallback) { | ||||
return call_user_func($this->willReadCallback, $this, $message); | return call_user_func($this->willReadCallback, $this, $message); | ||||
} else { | } else { | ||||
if (strlen($message)) { | if (phutil_nonempty_string($message)) { | ||||
return $message; | return $message; | ||||
} else { | } else { | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |
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