From bf3c44337b5f3c54460b5b83f12a5c45c100f976 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 6 Nov 2020 14:14:43 +0100 Subject: [PATCH] Continued: - if "Resource temporary unavailable" occurs but there had been some read data from the socket, don't discard it but add it to the stacker - used getLastSocketErrorMessage() instead of "raw" socket_strerror() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../handler/raw_data/tcp/class_TcpRawDataHandler.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php index 02cec26e7..a2d61e6f7 100644 --- a/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php @@ -89,7 +89,7 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { $this->lastSocketError = $socketInstance->getLastSocketErrorCode(); // Is it valid? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: this->lastSocketError(%d)=%s', $this->lastSocketError, socket_strerror($this->lastSocketError))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: this->lastSocketError(%d)=%s', $this->lastSocketError, $socketInstance->getLastSocketErrorMessage())); if ($this->lastSocketError == 11) { /* * Error code 11 (Resource temporary unavailable) can be safely @@ -99,11 +99,18 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: Ignoring error 11 (Resource temporary unavailable) from socketResource=%s - CONTINUE!', $socketInstance->getSocketResource())); $socketInstance->clearLastSocketError(); + // Is there anything to add to the stacker? + if (!empty($rawData)) { + // Add it to stacker + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: Adding %d(%s) bytes to stacker ...', strlen($rawData), $rawData)); + $this->addRawDataToStacker($rawData); + } + // Skip any further processing continue; } elseif (($rawData === FALSE) || ($this->lastSocketError > 0)) { // Network error or connection lost - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: rawData[]=%s,this->lastSocketError=%s detected. - BREAK!', gettype($rawData), socket_strerror($this->lastSocketError))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-RAW-DATA-HANDLER: rawData[]=%s,this->lastSocketError=%s detected. - BREAK!', gettype($rawData), $socketInstance->getLastSocketErrorMessage())); $this->setErrorCode($this->lastSocketError); break; } elseif (empty($rawData)) { -- 2.39.5