From 35961eab3fcbe05c3dbc812e0f8eac5b3ff520b9 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 16 Feb 2014 00:09:00 +0100 Subject: [PATCH] This needs to be copied to a local variable or else with debug lines the code won't work. :-( Signed-off-by: Roland Haeder --- .../handler/network/tcp/class_TcpRawDataHandler.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php index 828d5d1ea..aedbb2693 100644 --- a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php +++ b/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php @@ -75,12 +75,15 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { */ $rawData = socket_read($socketArray[BasePool::SOCKET_ARRAY_RESOURCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ); + // Get socket error code back + $socketError = socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); + // Debug output of read data length - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',error=' . socket_strerror($socketError)); /* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: rawData=' . $rawData); // Is it valid? - if (socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]) == 11) { + if ($socketError == 11) { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER[' . __LINE__ . ']: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE]); @@ -93,9 +96,9 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable { // Skip any further processing return; - } elseif (($rawData === FALSE) || (socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE]) > 0)) { + } elseif (($rawData === FALSE) || ($socketError > 0)) { // Network error or connection lost - $this->setErrorCode(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])); + $this->setErrorCode($socketError); } elseif (empty($rawData)) { // The peer did send nothing to us which is now being ignored return; -- 2.39.5