]> git.mxchange.org Git - hub.git/commitdiff
Use array_push() instead of [] as array_push() checks if parameter 1 is really an...
authorRoland Häder <roland@mxchange.org>
Sun, 3 Mar 2013 22:35:39 +0000 (22:35 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 3 Mar 2013 22:35:39 +0000 (22:35 +0000)
16 files changed:
application/hub/config.php
application/hub/interfaces/distributable/class_Distributable.php
application/hub/main/dht/class_BaseDht.php
application/hub/main/dht/node/class_NodeDhtFacade.php
application/hub/main/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php
application/hub/main/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php
application/hub/main/handler/tasks/class_TaskHandler.php
application/hub/main/listener/class_BaseListener.php
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/listener/udp/class_UdpListener.php
application/hub/main/lists/class_BaseList.php
application/hub/main/package/fragmenter/class_PackageFragmenter.php
application/hub/main/pools/peer/class_DefaultPeerPool.php
application/hub/main/tasks/node/chunks/class_NodeChunkAssemblerTask.php
application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php
application/hub/main/tasks/node/dht/class_NodeDhtQueryTask.php

index d63a50b4c5af09ee9293e9ca93f4922b6467ed62..8c9e480604c14449d6eaaea01f375f2c94423175 100644 (file)
@@ -273,6 +273,9 @@ $cfg->setConfigEntry('node_request_node_list_answer_stacker_class', 'FiLoStacker
 // CFG: NODE-REQUEST-NODE-LIST-ENTRY-STACKER-CLASS
 $cfg->setConfigEntry('node_request_node_list_entry_stacker_class', 'FiLoStacker');
 
+// CFG: DHT-STACKER-CLASS
+$cfg->setConfigEntry('dht_stacker_class', 'FiLoStacker');
+
 // CFG: NODE-ANNOUNCEMENT-ANSWER-TEMPLATE-TYPE
 $cfg->setConfigEntry('node_announcement_answer_template_type', 'xml/answer/announcement');
 
@@ -402,6 +405,9 @@ $cfg->setConfigEntry('stacker_decoded_package_max_size', 100);
 // CFG: STACKER-DHT-BOOTSTRAP-MAX-SIZE
 $cfg->setConfigEntry('stacker_dht_bootstrap_max_size', 10);
 
+// CFG: STACKER-DHT-INSERT-NODE-MAX-SIZE
+$cfg->setConfigEntry('stacker_dht_insert_node_max_size', 100);
+
 // CFG: NEWS-MAIN-LIMIT
 $cfg->setConfigEntry('news_main_limit', 5);
 
index dc828071d27f532228fd2e62c3b5f46b1c61f95d..94d2f4ab33ac42bc9188207ffa24e153acde7c1f 100644 (file)
@@ -90,6 +90,20 @@ interface Distributable extends FrameworkInterface {
         * @return      void
         */
        function updateDhtData ();
+
+       /**
+        * Checks whether there are entries in "INSERT" node data stack
+        *
+        * @return      $isPending      Whether there are pending entries
+        */
+       function ifInsertNodeDataPending ();
+
+       /**
+        * Inserts a single entry of node data into the DHT
+        *
+        * @return      void
+        */
+       function insertSingleNodeData ();
 }
 
 // [EOF]
index 597cc209ae649e3b7a2da49be79f9632fd44a6c2..9b94558b0baae1b86b6be44f6694dcf0be0d4315 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseDht extends BaseHubSystem {
+       /**
+        * Stacker name for "INSERT" node data
+        */
+       const STACKER_NAME_INSERT_NODE = 'dht_insert_node';
+
        /**
         * Protected constructor
         *
@@ -32,6 +37,15 @@ class BaseDht extends BaseHubSystem {
                // Call parent constructor
                parent::__construct($className);
 
+               // Get a stacker instance for this DHT
+               $stackerInstance = ObjectFactory::createObjectByConfiguredName('dht_stacker_class');
+
+               // Set it in this class
+               $this->setStackerInstance($stackerInstance);
+
+               // Init all stackers
+               $this->initStackers();
+
                /*
                 * Get the state factory and create the initial state, we don't need
                 * the state instance here
@@ -39,6 +53,22 @@ class BaseDht extends BaseHubSystem {
                DhtStateFactory::createDhtStateInstanceByName('init', $this);
        }
 
+       /**
+        * Initializes all stackers
+        *
+        * @return      void
+        */
+       private function initStackers () {
+               // "Walk" through all (more will be added as needed
+               foreach (
+                       array(
+                               self::STACKER_NAME_INSERT_NODE,
+                       ) as $stackerName) {
+                               // Init this stack
+                               $this->getStackerInstance()->initStacker($stackerName);
+               } // END - foreach
+       }
+
        /**
         * Updates/refreshes DHT data (e.g. status).
         *
@@ -49,6 +79,31 @@ class BaseDht extends BaseHubSystem {
                // Set some dummy configuration entries, e.g. dht_status
                $this->getConfigInstance()->setConfigEntry('dht_status', $this->getStateInstance()->getStateName());
        }
+
+       /**
+        * Checks whether there are entries in "INSERT" node data stack
+        *
+        * @return      $isPending      Whether there are pending entries
+        */
+       public function ifInsertNodeDataPending () {
+               // Determine it if it is not empty
+               $isPending = ($this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_INSERT_NODE) === FALSE);
+
+               // Return status
+               return $isPending;
+       }
+
+       /**
+        * Inserts a single entry of node data into the DHT
+        *
+        * @return      void
+        */
+       public function insertSingleNodeData () {
+               // Get next node data from stack
+               $nodeData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_INSERT_NODE);
+
+               die(__METHOD__ . ':nodeData=' . print_r($nodeData, TRUE));
+       }
 }
 
 // [EOF]
index f78bca4e27a0a21fd00a13dd4de1e21af6974be7..794c38f09ee72957b0b1d494d20e84e06746f755 100644 (file)
@@ -255,7 +255,6 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable {
         *
         * @param       $nodeList       An array from an earlier database result instance
         * @return      void
-        * @todo        ~10% done
         */
        public function insertNodeList (array $nodeList) {
                // If no node is in the list (array), skip the rest of this method
@@ -267,8 +266,11 @@ class NodeDhtFacade extends BaseDht implements Distributable, Registerable {
                        return;
                } // END - if
 
-               // @TODO Not finish yet
-               $this->partialStub('DHT: Needs implementing to insert ' . count($nodeList) . ' entry(-ies) into DHT.');
+               // Put them all into a stack
+               foreach ($nodeList as $nodeData) {
+                       // Insert all entries
+                       $this->getStackerInstance()->pushNamed(self::STACKER_NAME_INSERT_NODE, $nodeData);
+               } // END - foreach
        }
 }
 
index 30c65ac259f83c8356c84d43f9cae50063290076..c50970d5184e47d6e3b2ef0c22a737dd70ff1e7e 100644 (file)
@@ -85,7 +85,7 @@ class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements
                $this->getDhtInstance()->registerNodeByMessageData($messageData, $this, TRUE);
 
                // Prepare next message ("hello" message to all returned nodes)
-               $this->prepareNextMessage($messageData, $packageInstance);
+               //$this->prepareNextMessage($messageData, $packageInstance);
        }
 
        /**
index 143afbd22945f3d02bd738fb592ebf6c73141f4f..fe39ae8491a05d2adeff80d2f06caf70520282c2 100644 (file)
@@ -119,7 +119,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
         */
        protected function initMessageConfigurationData (array $messageData) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(' REQUEST-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: messageData=' . print_r($messageData, true));
 
                // "Walk" throught the config-copy array
                foreach ($this->configCopy as $targetKey => $sourceKey) {
@@ -130,8 +130,17 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha
                        $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
                } // END - foreach
 
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('REQUEST-HANDLER[' . __LINE__ . ']: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
+
                // Query local DHT for nodes except given session id
-               $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData($messageData, $this, XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, BaseHubNode::OBJECT_LIST_SEPARATOR);
+               $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData(
+                       $messageData,
+                       $this,
+                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
+                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
+                       BaseHubNode::OBJECT_LIST_SEPARATOR
+               );
 
                // Set it serialized in configuration (temporarily)
                $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(serialize($nodeList)));
index 0467df236bf2790bbd1519137bee7668cb70ae4f..d09646d851b64bae5d829349dd8ba8fecb6aaf27 100644 (file)
@@ -285,7 +285,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                        $currentTask['task_instance']->accept($this->getVisitorInstance());
 
                        // Remember this task
-                       $tasks[] = $currentTask;
+                       array_push($tasks, $currentTask);
 
                        // Advance to next one
                        $this->getListInstance()->getIterator()->next();
index 558ba1f35f02990551defd9a00e7b0a90f80fa02..6651198a5b7e7ad6144b3beabad770c3c547b54a 100644 (file)
@@ -272,7 +272,7 @@ class BaseListener extends BaseHubSystem implements Visitable {
         */
        public function accept (Visitor $visitorInstance) {
                // Debug message
-               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - START');
 
                // Visit this listener
                $visitorInstance->visitListener($this);
@@ -283,7 +283,7 @@ class BaseListener extends BaseHubSystem implements Visitable {
                } // END - if
 
                // Debug message
-               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
+               //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($this->getProtocol()) . '-LISTENER[' . __LINE__ . ']: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - FINISHED');
        }
 
        /**
index bebe4e1e50f64490ca6fe1e09b736ad10041f281..680ab86b5e45b492f15e3bcebb5fa74124255f7b 100644 (file)
@@ -105,7 +105,7 @@ class TcpListener extends BaseListener implements Listenable {
                 * that all connections on this port are now our resposibility to
                 * send/recv data, disconnect, etc..
                 */
-               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
+               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
                if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
                        // Handle this socket error with a faked recipientData array
                        $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
@@ -125,7 +125,7 @@ class TcpListener extends BaseListener implements Listenable {
                } // END - if
 
                // Start listen for connections
-               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: Listening for connections.');
+               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Listening for connections.');
                if (!socket_listen($mainSocket)) {
                        // Handle this socket error with a faked recipientData array
                        $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
@@ -145,7 +145,7 @@ class TcpListener extends BaseListener implements Listenable {
                } // END - if
 
                // Now, we want non-blocking mode
-               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: Setting non-blocking mode.');
+               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: Setting non-blocking mode.');
                if (!socket_set_nonblock($mainSocket)) {
                        // Handle this socket error with a faked recipientData array
                        $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
@@ -190,7 +190,7 @@ class TcpListener extends BaseListener implements Listenable {
                $this->setHandlerInstance($handlerInstance);
 
                // Output message
-               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
+               self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
        }
 
        /**
@@ -217,14 +217,14 @@ class TcpListener extends BaseListener implements Listenable {
                // Some new peers found?
                if ($left < 1) {
                        // Debug message
-                       //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
+                       //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: left=' . $left . ',serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
 
                        // Nothing new found
                        return;
                } // END - if
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true));
 
                // Do we have changed peers?
                if (in_array($this->getSocketResource(), $readers)) {
@@ -307,7 +307,7 @@ class TcpListener extends BaseListener implements Listenable {
                $currentSocket = $this->getIteratorInstance()->current();
 
                // Handle it here, if not main server socket
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource());
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-LISTENER[' . __LINE__ . ']: currentSocket=' . $currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketResource());
                if (($currentSocket[BasePool::SOCKET_ARRAY_CONN_TYPE] != BaseConnectionHelper::CONNECTION_TYPE_SERVER) && ($currentSocket[BasePool::SOCKET_ARRAY_RESOURCE] != $this->getSocketResource())) {
                        // ... or else it will raise warnings like 'Transport endpoint is not connected'
                        $this->getHandlerInstance()->processRawDataFromResource($currentSocket);
index b20f838c69a896f1dc2c59b22ae43b28bdb7a1f5..3c7127f48cd830b57714fb070cf3f2115de54e6f 100644 (file)
@@ -74,7 +74,7 @@ class UdpListener extends BaseListener implements Listenable {
                 * that all connections on this port are now our resposibility to
                 * send/recv data, disconnect, etc..
                 */
-               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
+               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Binding to address ' . $this->getListenAddress() . ':' . $this->getListenPort());
                if (!socket_bind($mainSocket, $this->getListenAddress(), $this->getListenPort())) {
                        // Handle the socket error with a faked recipientData array
                        $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
@@ -94,7 +94,7 @@ class UdpListener extends BaseListener implements Listenable {
                } // END - if
 
                // Now, we want non-blocking mode
-               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Setting non-blocking mode.');
+               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Setting non-blocking mode.');
                if (!socket_set_nonblock($mainSocket)) {
                        // Handle the socket error with a faked recipientData array
                        $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
@@ -114,7 +114,7 @@ class UdpListener extends BaseListener implements Listenable {
                } // END - if
 
                // Set the option to reuse the port
-               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Setting re-use address option.');
+               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Setting re-use address option.');
                if (!socket_set_option($mainSocket, SOL_SOCKET, SO_REUSEADDR, 1)) {
                        // Handle the socket error with a faked recipientData array
                        $this->handleSocketError(__METHOD__, __LINE__, $mainSocket, array('0.0.0.0', '0'));
@@ -143,7 +143,7 @@ class UdpListener extends BaseListener implements Listenable {
                $this->setHandlerInstance($handlerInstance);
 
                // Output message
-               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
+               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: UDP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.');
        }
 
        /**
@@ -173,7 +173,7 @@ class UdpListener extends BaseListener implements Listenable {
                        return;
                } elseif ($lastError > 0) {
                        // Other error detected
-                       self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Error detected: ' . socket_strerror($lastError));
+                       self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Error detected: ' . socket_strerror($lastError));
 
                        // Skip further processing
                        return;
@@ -183,7 +183,7 @@ class UdpListener extends BaseListener implements Listenable {
                } // END - if
 
                // Debug only
-               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port);
+               self::createDebugInstance(__CLASS__)->debugOutput('UDP-LISTENER[' . __LINE__ . ']: Handling UDP package with size ' . strlen($rawData) . ' from peer ' . $peer . ':' . $port);
        }
 
        /**
index c4d18376846e9e10567102343be1795440c73a0a..3add9145878e16edbc819b2b8338ad668e6a45c7 100644 (file)
@@ -136,7 +136,7 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable {
                $this->listGroups[$groupName]->addEntry($subGroup, $hash);
 
                // Add the hash to the index
-               $this->listIndex[] = $hash;
+               array_push($this->listIndex, $hash);
 
                // Add the instance itself to the list
                $this->listEntries[$hash] = $instance;
@@ -172,7 +172,7 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable {
                        // Is the list entry set?
                        if ($this->isHashValid($hash)) {
                                // Add it
-                               $array[] = $this->listEntries[$hash];
+                               array_push($array, $this->listEntries[$hash]);
                                //* DEBUG: */ print __METHOD__.": ADDED!\n";
                        } // END - if
                } // END - foreach
@@ -202,7 +202,7 @@ class BaseList extends BaseHubSystem implements IteratorAggregate, Countable {
                //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:  groupName=' . $groupName . ', entry=' . $entry . ', hash=' . $hash);
 
                // Add the hash to the index
-               $this->listIndex[] = $hash;
+               array_push($this->listIndex, $hash);
                //* DEBUG: */ print $groupName.'/'.$this->count().chr(10);
 
                // Now add the entry to the list
index 3a9adc3edee46c04181e77e40805c845fdbf5bd4..277083d6e3966ea831a84ab4eb5be034ca5f62d1 100644 (file)
@@ -379,7 +379,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera
                        // Debug message
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ': Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...');
                        $this->chunks[$finalHash][]      = $rawData;
-                       $this->chunkHashes[$finalHash][] = $rawDataHash;
+                       array_push($this->chunkHashes[$finalHash], $rawDataHash);
                }
        }
 
index e2fce1b11fbb3f3b4a73543ea85126e0872a10be..c7ee45d91438a640194a4cbf9fa1717b76cf1ce9 100644 (file)
@@ -168,7 +168,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                // "Walk" through all socket arrays
                foreach ($socketArrays as $socketArray) {
                        // Add the socket
-                       $sockets[] = $socketArray[self::SOCKET_ARRAY_RESOURCE];
+                       array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]);
                } // END - foreach
 
                // Return it
@@ -200,7 +200,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                        // Does it match?
                        if ($socketArray[self::SOCKET_ARRAY_CONN_TYPE] === $connectionType) {
                                // Add the socket
-                               $sockets[] = $socketArray[self::SOCKET_ARRAY_RESOURCE];
+                               array_push($sockets, $socketArray[self::SOCKET_ARRAY_RESOURCE]);
                        } // END - if
                } // END - foreach
 
index 2220c2b9b5662fffc1648a36c88949cf7ef83921..5a436dd55de302e84041711824d6c72e7ae4cfa3 100644 (file)
@@ -69,8 +69,11 @@ class NodeChunkAssemblerTask extends BaseTask implements Taskable, Visitable {
         * @return      void
         */
        public function executeTask () {
+               // "Cache" handler instance
+               $handlerInstance = $this->getHandlerInstance();
+
                // Are there chunks to handle or a final array to assemble?
-               if ($this->getHandlerInstance()->ifUnassembledChunksAvailable()) {
+               if ($handlerInstance->ifUnassembledChunksAvailable()) {
                        /*
                         * Then do the final steps:
                         *
@@ -82,19 +85,19 @@ class NodeChunkAssemblerTask extends BaseTask implements Taskable, Visitable {
                         * 4) If the package is assembled back together, hash it again for
                         *    the very final verification.
                         */
-                       $this->getHandlerInstance()->assembleChunksFromFinalArray();
-               } elseif ($this->getHandlerInstance()->ifUnhandledChunksWithFinalAvailable()) {
+                       $handlerInstance->assembleChunksFromFinalArray();
+               } elseif ($handlerInstance->ifUnhandledChunksWithFinalAvailable()) {
                        /*
                         * Then handle them (not all!). This should push all chunks into a
                         * 'final array' for last verification.
                         */
-                       $this->getHandlerInstance()->handleAvailableChunksWithFinal();
-               } elseif ($this->getHandlerInstance()->ifRawPackageDataIsAvailable()) {
+                       $handlerInstance->handleAvailableChunksWithFinal();
+               } elseif ($handlerInstance->ifRawPackageDataIsAvailable()) {
                        /*
                         * The final raw package data is back together again. So feed it
                         * into the next stack for further decoding/processing
                         */
-                       $this->getHandlerInstance()->handledAssembledRawPackageData();
+                       $handlerInstance->handledAssembledRawPackageData();
                }
        }
 }
index 44f717e5e0707104a169baa007dcfffd473b560e..0d3393a426ef893130b73dedaccc9a603da74178 100644 (file)
@@ -74,13 +74,16 @@ class NodePackageDecoderTask extends BaseTask implements Taskable, Visitable {
         * @return      void
         */
        public function executeTask () {
+               // "Cache" decoder instance
+               $decoderInstance = $this->getDecoderInstance();
+
                // Check if the stacker has some entries left
-               if ($this->getDecoderInstance()->ifUnhandledRawPackageDataLeft()) {
+               if ($decoderInstance->ifUnhandledRawPackageDataLeft()) {
                        // Then handle it
-                       $this->getDecoderInstance()->handleRawPackageData();
-               } elseif ($this->getDecoderInstance()->ifDeocedPackagesLeft()) {
+                       $decoderInstance->handleRawPackageData();
+               } elseif ($decoderInstance->ifDeocedPackagesLeft()) {
                        // Some decoded packages have arrived (for this peer)
-                       $this->getDecoderInstance()->handleDecodedPackage();
+                       $decoderInstance->handleDecodedPackage();
                }
        }
 }
index ffbaec9a2831d90af0fc83402cd02e4d28459e3a..0ae14beb956d2ce45bda1174c466ff137ab2cf17 100644 (file)
@@ -71,6 +71,12 @@ class NodeDhtQueryTask extends BaseTask implements Taskable, Visitable {
        public function executeTask () {
                // "Cache" the DHT instance
                $dhtInstance = $this->getDhtInstance();
+
+               // Are there "INSERT" node data entries?
+               if ($dhtInstance->ifInsertNodeDataPending()) {
+                       // Then insert a single entry
+                       $dhtInstance->insertSingleNodeData();
+               } // END - if
        }
 }