From 00ba75eb88c259c94086c01927bd145c403efedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 9 Oct 2020 17:27:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kafka/Socket.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Kafka/Socket.php b/Kafka/Socket.php index e6c56fdd..caa8f5ab 100644 --- a/Kafka/Socket.php +++ b/Kafka/Socket.php @@ -240,8 +240,8 @@ class Socket throw new \Kafka\Exception($error); } - stream_set_blocking($this->stream, 0); - stream_set_read_buffer($this->stream, 0); +// stream_set_blocking($this->stream->getpeername(), 0); +// stream_set_read_buffer($this->stream, 0); $this->readWatcher = \Amp\onReadable($this->stream, function () { do { @@ -324,9 +324,7 @@ class Socket { \Amp\cancel($this->readWatcher); \Amp\cancel($this->writeWatcher); - if (is_resource($this->stream)) { - fclose($this->stream); - } + $this->stream->close(); $this->readBuffer = ''; $this->writeBuffer = ''; $this->readNeedLength = 0; @@ -399,14 +397,12 @@ class Socket $this->writeBuffer .= $data; } $bytesToWrite = strlen($this->writeBuffer); - $bytesWritten = @fwrite($this->stream, $this->writeBuffer); + $bytesWritten = $this->stream->send($this->writeBuffer); if ($bytesToWrite === $bytesWritten) { \Amp\disable($this->writeWatcher); } elseif ($bytesWritten >= 0) { \Amp\enable($this->writeWatcher); - } elseif ($this->isSocketDead($this->stream)) { - $this->reconnect(); } $this->writeBuffer = substr($this->writeBuffer, $bytesWritten); }