From: Roland Häder Date: Fri, 6 Nov 2020 13:14:43 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bf3c44337b5f3c54460b5b83f12a5c45c100f976;p=hub.git 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() Signed-off-by: Roland Häder --- 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)) {