]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 6 Nov 2020 13:14:43 +0000 (14:14 +0100)
committerRoland Häder <roland@mxchange.org>
Fri, 6 Nov 2020 13:14:43 +0000 (14:14 +0100)
- 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 <roland@mxchange.org>
application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php

index 02cec26e7b0011686f246db85d7747c6d2cacf39..a2d61e6f7d9032a72649c8629202dcfc5d2e9e32 100644 (file)
@@ -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)) {