]> git.mxchange.org Git - hub.git/commitdiff
More debugging, ignore *.serialized in node_list
authorRoland Häder <roland@mxchange.org>
Fri, 18 May 2012 21:27:29 +0000 (21:27 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 18 May 2012 21:27:29 +0000 (21:27 +0000)
.gitignore
application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php
application/hub/main/handler/network/class_BaseRawDataHandler.php
application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php
application/hub/main/helper/connection/class_BaseConnectionHelper.php
application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/listener/udp/class_UdpListener.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/pools/peer/class_DefaultPeerPool.php

index 0b7f63a199bfab4009091fa75e59a9d991b458b3..dff3b99066858c29b2993f1f7e44b831acf9cae5 100644 (file)
@@ -3,6 +3,7 @@
 /.settings
 application/hub/config-local.php
 db/node_data/*.serialized
+db/node_list/*.serialized
 db/node_states/*.serialized
 db/peer_states/*.serialized
 docs/warn.log
index 4c9f2f4990ab6a22d45c03cce8c0852888d83aff..4a1a6b21a9b63679388bcfdc9fae5a643b5ac78e 100644 (file)
@@ -147,7 +147,7 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look
                $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::PACKAGE_DATA_SENDER]);
 
                // Get peer name
-               if (!@socket_getpeername($socketResource, $peerName, $peerPort)) {
+               if (!socket_getpeername($socketResource, $peerName, $peerPort)) {
                        // Get last error
                        $lastError = socket_last_error($socketResource);
 
@@ -220,7 +220,7 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look
         */
        public function purgeOldEntriesBySocketResource ($socketResource) {
                // Get peer name
-               if (!@socket_getpeername($socketResource, $peerName, $peerPort)) {
+               if (!socket_getpeername($socketResource, $peerName, $peerPort)) {
                        // Get last error
                        $lastError = socket_last_error($socketResource);
 
index 16c7c15e335393b91c2228b2cf0f65c0533279f6..9a3cc31b8c6ea582174244a1acda6f0126aacf6b 100644 (file)
@@ -153,7 +153,6 @@ class BaseRawDataHandler extends BaseHandler {
                $ownAddress = Registry::getRegistry()->getInstance('node')->getAddressPort($this);
 
                // Does it match?
-               // @TODO Numeric or alpha-numeric index?
                $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
 
                // Return result
index 6c6e5ff4a6a2d5b29b5b652e6c51709ef1996a67..36b883d6bed4246e364c83a1109f797308d9fd7a 100644 (file)
@@ -69,17 +69,17 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable {
                $decodedData = false;
 
                // Debug message
-               //* NOISY-DEBUG: */ $this->debugOutput('HANDLER: Handling TCP package from peer ' . $resource);
+               /* NOISY-DEBUG: */ $this->debugOutput('TCP-HANDLER: Handling TCP package from peer ' . $resource . ',last error=' . socket_strerror(socket_last_error($resource)));
 
                /*
                 * Read the raw data from socket. If you change PHP_BINARY_READ to
-                * PHP_NORMAL_READ, this line will endless block. We only have
-                * simultanous threads and no real threads.
+                * PHP_NORMAL_READ, this line will endless block. This script does only
+                * provide simultanous threads, not real.
                 */
                $rawData = socket_read($resource, $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ);
 
                // Debug output of read data length
-               //* NOISY-DEBUG: */ $this->debugOutput('TCP-HANDLER: rawData[]=' . strlen($rawData));
+               /* NOISY-DEBUG: */ $this->debugOutput('TCP-HANDLER: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',resource=' . $resource . ',error=' . socket_strerror(socket_last_error($resource)));
 
                // Is it valid?
                if (($rawData === false) || (socket_last_error($resource) > 0)) {
@@ -90,9 +90,8 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable {
                        $this->setErrorCode(self::SOCKET_ERROR_EMPTY_DATA);
                } else {
                        /*
-                        * Low-level checks of the raw data went all fine, we can now
-                        * decode the raw data. This may still fail because of invalid
-                        * encoded data.
+                        * Low-level checks of the raw data went all fine, now decode the
+                        * raw data. This may still fail because of invalid encoded data.
                         */
                        $decodedData = $this->getInputStreamInstance()->streamData($rawData);
                }
index d180499e505c6b3c900a070fee2f594bfbbb4a69..6fa2861b0b7fb1df194655895a8daba8bec729b3 100644 (file)
@@ -406,10 +406,10 @@ class BaseConnectionHelper extends BaseHubHelper implements Registerable, Protoc
                        //* NOISY-DEBUG: */ $this->debugOutput('CONNECTION: Sending out ' . strlen($encodedData) . ' bytes,bufferSize=' . $bufferSize . ',diff=' . $this->diff);
                        if ($this->diff >= 0) {
                                // Send all out (encodedData is smaller than or equal buffer size)
-                               $sentBytes = @socket_write($socketResource, $encodedData, ($bufferSize - $this->diff));
+                               $sentBytes = socket_write($socketResource, $encodedData, ($bufferSize - $this->diff));
                        } else {
                                // Send buffer size out
-                               $sentBytes = @socket_write($socketResource, $encodedData, $bufferSize);
+                               $sentBytes = socket_write($socketResource, $encodedData, $bufferSize);
                        }
 
                        // If there was an error, we don't continue here
index f7efa68d6e81d1680ad3925fb556ed11e329f2f9..8603b693cd07e0deaffb68a3b324bc0d9fbc80c7 100644 (file)
@@ -149,7 +149,7 @@ class TcpConnectionHelper extends BaseConnectionHelper implements ConnectionHelp
                socket_clear_error($this->getSocketResource());
 
                // Call the shutdown function on the currently set socket
-               if (!@socket_shutdown($this->getSocketResource())) {
+               if (!socket_shutdown($this->getSocketResource())) {
                        // Could not shutdown socket, this is fine if e.g. the other side is not connected, so analyse it
                        if (socket_last_error($this->getSocketResource()) != 107) {
                                // Something bad happened while we shutdown a socket
index 1a579736666f4d6787bd2e51e14404e987ad6b7b..2f6a3224a5eac209b85184faf92872870f463d0b 100644 (file)
@@ -259,7 +259,7 @@ class TcpListener extends BaseListener implements Listenable {
                // Handle it here, if not main socket
                if ($currentSocket != $this->getSocketResource()) {
                        // ... or else it will raise warnings like 'Transport endpoint is not connected'
-                       //* NOISY-DEBUG: */ $this->debugOutput('TCP-LISTENER: currentSocket=' . $currentSocket);
+                       //* NOISY-DEBUG: */ $this->debugOutput('TCP-LISTENER: currentSocket=' . $currentSocket . ',server=' . $this->getSocketResource());
                        $this->getHandlerInstance()->processRawDataFromResource($currentSocket);
                } // END - if
 
index 47dd7f9cf88049c28743e8bd512ef65ff21a5695..5a26b7f3d44b0680f524e13ca848e4e95ac55646 100644 (file)
@@ -152,7 +152,7 @@ class UdpListener extends BaseListener implements Listenable {
         */
        public function doListen() {
                // Read a package and determine the peer
-               $amount = @socket_recvfrom($this->getSocketResource(), $pkt, 1500, 0, $peer, $port);
+               $amount = @socket_recvfrom($this->getSocketResource(), $rawData, $this->getConfigInstance()->getConfigEntry('udp_buffer_length'), MSG_DONTWAIT, $peer, $port);
 
                // Get last error
                $lastError = socket_last_error($this->getSocketResource());
@@ -163,7 +163,7 @@ class UdpListener extends BaseListener implements Listenable {
                         * This (resource temporary unavailable) can be safely ignored on
                         * "listening" UDP ports. If we don't clear the error here, our UDP
                         * "listener" won't read any packages except if the UDP sender
-                        * starts the transmission before this "listener came up...
+                        * starts the transmission before this "listener" came up...
                         */
                        socket_clear_error($this->getSocketResource());
 
@@ -175,13 +175,13 @@ class UdpListener extends BaseListener implements Listenable {
 
                        // Skip further processing
                        return;
-               } elseif ((empty($pkt)) || (trim($peer) == '')) {
+               } elseif ((empty($rawData)) || (trim($peer) == '')) {
                        // Zero sized packages/peer names are usual in non-blocking mode
                        return;
                } // END - if
 
                // Debug only
-               $this->debugOutput('UDP-LISTENER: Handling UDP package with size ' . strlen($pkt) . ' from peer ' . $peer . ':' . $port);
+               $this->debugOutput('UDP-LISTENER: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port);
        }
 
        /**
index 5312769198e78a3f2ed764128ceaa29b59e7d12c..dbb598c01f0ae6a6c4e0456762586260aa22203f 100644 (file)
@@ -824,7 +824,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                 * Also make sure the error code is SOCKET_ERROR_UNHANDLED because we
                 * only want to handle unhandled packages here.
                 */
-               /* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE]);
+               /* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . BaseRawDataHandler::SOCKET_ERROR_UNHANDLED . ')');
                assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED);
 
                // Remove the last chunk SEPARATOR (because it is being added and we don't need it)
index 8261a28863ed0883d7bdb408ca6a525b52bc020c..6722bfe56cf9678caf95b9ab313f68a877a75336 100644 (file)
@@ -100,7 +100,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                // The socket resource should not match server socket
                if ($socketResource != $this->getListenerInstance()->getSocketResource()) {
                        // Try to determine the peer's IP number
-                       if (!@socket_getpeername($socketResource, $peerName)) {
+                       if (!socket_getpeername($socketResource, $peerName)) {
                                // Handle the socket error with a faked recipientData array
                                $this->handleSocketError($socketResource, array('0.0.0.0', '0'));
                                /*
@@ -117,7 +117,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                }
 
                // Output error message
-               $this->debugOutput('POOL: Adding peer ' . $peerName . ', socketResource=' . $socketResource);
+               $this->debugOutput('POOL: Adding peer ' . $peerName . ',socketResource=' . $socketResource);
 
                // Add it finally to the pool
                $this->addPoolEntry($socketResource);
@@ -165,7 +165,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                        } // END - if
 
                        // Try to get the "peer"'s name
-                       if (!@socket_getpeername($socket, $peerIp)) {
+                       if (!socket_getpeername($socket, $peerIp)) {
                                // Handle the socket error with given package data
                                $this->handleSocketError($socket, explode(':', $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
                        } // END - if