改名
This commit is contained in:
+4
-8
@@ -240,8 +240,8 @@ class Socket
|
|||||||
throw new \Kafka\Exception($error);
|
throw new \Kafka\Exception($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_set_blocking($this->stream, 0);
|
// stream_set_blocking($this->stream->getpeername(), 0);
|
||||||
stream_set_read_buffer($this->stream, 0);
|
// stream_set_read_buffer($this->stream, 0);
|
||||||
|
|
||||||
$this->readWatcher = \Amp\onReadable($this->stream, function () {
|
$this->readWatcher = \Amp\onReadable($this->stream, function () {
|
||||||
do {
|
do {
|
||||||
@@ -324,9 +324,7 @@ class Socket
|
|||||||
{
|
{
|
||||||
\Amp\cancel($this->readWatcher);
|
\Amp\cancel($this->readWatcher);
|
||||||
\Amp\cancel($this->writeWatcher);
|
\Amp\cancel($this->writeWatcher);
|
||||||
if (is_resource($this->stream)) {
|
$this->stream->close();
|
||||||
fclose($this->stream);
|
|
||||||
}
|
|
||||||
$this->readBuffer = '';
|
$this->readBuffer = '';
|
||||||
$this->writeBuffer = '';
|
$this->writeBuffer = '';
|
||||||
$this->readNeedLength = 0;
|
$this->readNeedLength = 0;
|
||||||
@@ -399,14 +397,12 @@ class Socket
|
|||||||
$this->writeBuffer .= $data;
|
$this->writeBuffer .= $data;
|
||||||
}
|
}
|
||||||
$bytesToWrite = strlen($this->writeBuffer);
|
$bytesToWrite = strlen($this->writeBuffer);
|
||||||
$bytesWritten = @fwrite($this->stream, $this->writeBuffer);
|
$bytesWritten = $this->stream->send($this->writeBuffer);
|
||||||
|
|
||||||
if ($bytesToWrite === $bytesWritten) {
|
if ($bytesToWrite === $bytesWritten) {
|
||||||
\Amp\disable($this->writeWatcher);
|
\Amp\disable($this->writeWatcher);
|
||||||
} elseif ($bytesWritten >= 0) {
|
} elseif ($bytesWritten >= 0) {
|
||||||
\Amp\enable($this->writeWatcher);
|
\Amp\enable($this->writeWatcher);
|
||||||
} elseif ($this->isSocketDead($this->stream)) {
|
|
||||||
$this->reconnect();
|
|
||||||
}
|
}
|
||||||
$this->writeBuffer = substr($this->writeBuffer, $bytesWritten);
|
$this->writeBuffer = substr($this->writeBuffer, $bytesWritten);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user