From 4cb8e8831a5e6740bfde2d3b44519d2868d672d5 Mon Sep 17 00:00:00 2001 From: telan Date: Thu, 24 Oct 2019 17:23:12 +0800 Subject: [PATCH] [fix] client close --- src/Server/Manager.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Server/Manager.php b/src/Server/Manager.php index 20067ce..d49ed7b 100644 --- a/src/Server/Manager.php +++ b/src/Server/Manager.php @@ -99,15 +99,19 @@ public function signalHandler($signal) case SIGUSR2: case SIGTERM: $this->exit = true; - $this->client->close(); + $this->client->close(true); file_put_contents(Configure::getPosFile(), $pidFileContent); - exit(0); } } protected function consume(): void { - $binaryDataReader = new EventBinaryData($this->client->read()); + $recvData = $this->client->read(); + if (empty($recvData)) { + return; + } + + $binaryDataReader = new EventBinaryData($recvData); // check EOF_Packet -> https://dev.mysql.com/doc/internals/en/packet-EOF_Packet.html if (self::EOF_HEADER_VALUE === $binaryDataReader->readUInt8()) { @@ -118,7 +122,7 @@ protected function consume(): void $eventInfo = $this->getEventInfo($binaryDataReader); $eventBuilder = new EventBuilder($binaryDataReader, $eventInfo, $this->cache); - switch($eventInfo->getType()) + switch ($eventInfo->getType()) { case EventTypeConst::TABLE_MAP_EVENT: $event = $eventBuilder->makeTableMap();