From 7b7cd2e8f2f45ea12654b2c2768408db50046198 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 19 Apr 2011 01:26:58 +0000 Subject: [PATCH] Removed old-lost comments, moved two class instances around: - Removed old-lost comments about the application selector - Moved class instances around to have the pool listener available in the method which checks for newly arrived raw data --- application/hub/config.php | 3 ++ application/hub/data.php | 8 ----- application/hub/exceptions.php | 1 - .../class_HubAlreadyAnnouncedException.php | 5 ++-- .../lists/class_InvalidListHashException.php | 3 +- .../class_ListGroupAlreadyAddedException.php | 3 +- .../lists/class_NoListGroupException.php | 3 +- .../class_PeerAlreadyRegisteredException.php | 3 +- .../state/class_InvalidStateException.php | 5 ++-- .../tags/class_InvalidTagException.php | 3 +- .../tasks/class_InvalidTaskException.php | 5 ++-- application/hub/init.php | 8 ----- .../interfaces/package/class_Receivable.php | 3 +- application/hub/main/class_BaseHubSystem.php | 24 +++++++++++++++ .../query/local/class_LocalQueryConnector.php | 9 ++++++ ...class_NodeTaskHandlerInitializerFilter.php | 8 ++--- .../class_BaseNetworkPackageHandler.php | 29 +++++++++++++------ .../tcp/class_TcpNetworkPackageHandler.php | 4 +-- .../main/listener/tcp/class_TcpListener.php | 6 ++-- .../main/lists/groups/class_ListGroupList.php | 1 + .../main/lists/pool/class_PoolEntriesList.php | 4 +-- .../hub/main/nodes/class_BaseHubNode.php | 24 --------------- .../hub/main/package/class_NetworkPackage.php | 6 ++-- application/hub/main/pools/class_BasePool.php | 2 +- .../main/pools/peer/class_DefaultPeerPool.php | 2 +- .../network/class_NetworkStateResolver.php | 4 +-- .../class_NetworkPackageReaderTask.php | 8 +++-- 27 files changed, 103 insertions(+), 81 deletions(-) diff --git a/application/hub/config.php b/application/hub/config.php index d650da5b6..311ea3594 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -279,6 +279,9 @@ $cfg->setConfigEntry('stacker_outgoing_queue_max_size', 100000); // CFG: STACKER-INCOMING-QUEUE-MAX-SIZE $cfg->setConfigEntry('stacker_incoming_queue_max_size', 100000); +// CFG: STACKER-RAW-DATA-MAX-SIZE +$cfg->setConfigEntry('stacker_raw_data_max_size', 100); + // CFG: NEWS-MAIN-LIMIT $cfg->setConfigEntry('news_main_limit', 5); diff --git a/application/hub/data.php b/application/hub/data.php index 6e8b67cc0..b023dc256 100644 --- a/application/hub/data.php +++ b/application/hub/data.php @@ -5,14 +5,6 @@ * Please remember that this include file is being loaded *before* the class * loader is loading classes from "exceptions", "interfaces" and "main"! * - * You can prevent adding this application to the selector by uncommenting the - * following line: - * - * if ((isset($this)) && (is_object($this)) && ($this->isClass("ApplicationSelector"))) { return; } - * - * isset() is required to prevent a warning and is_object() is highly required - * when the application itself is requested in URL (hint: index.php?app=your_app) - * * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team diff --git a/application/hub/exceptions.php b/application/hub/exceptions.php index ca9ebde5e..fa54a9a20 100644 --- a/application/hub/exceptions.php +++ b/application/hub/exceptions.php @@ -2,7 +2,6 @@ /** * An include file for setting up the exception handler of the hub * - * * @author Roland Haeder * @version 0.0 * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2011 Hub Developer Team diff --git a/application/hub/exceptions/hub/class_HubAlreadyAnnouncedException.php b/application/hub/exceptions/hub/class_HubAlreadyAnnouncedException.php index 481e8c229..8e4e45d82 100644 --- a/application/hub/exceptions/hub/class_HubAlreadyAnnouncedException.php +++ b/application/hub/exceptions/hub/class_HubAlreadyAnnouncedException.php @@ -31,8 +31,9 @@ class HubAlreadyAnnouncedException extends FrameworkException { */ public function __construct (NodeHelper $nodeInstance, $code) { // Construct the message - $message = sprintf("[%s] This hub is already announced. Please fix this.", - $nodeInstance->__toString() + $message = sprintf("[%s:%d] This hub is already announced. Please fix this.", + $nodeInstance->__toString(), + $this->getLine() ); // Call parent exception constructor diff --git a/application/hub/exceptions/lists/class_InvalidListHashException.php b/application/hub/exceptions/lists/class_InvalidListHashException.php index 9b48ec464..8b9006cd8 100644 --- a/application/hub/exceptions/lists/class_InvalidListHashException.php +++ b/application/hub/exceptions/lists/class_InvalidListHashException.php @@ -31,8 +31,9 @@ class InvalidListHashException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf("[%s] Hash %s with key %s is invalid.", + $message = sprintf("[%s:%d] Hash %s with key %s is invalid.", $messageArray[0]->__toString(), + $this->getLine(), $messageArray[1], $messageArray[2] ); diff --git a/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php b/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php index d47ef3571..7308c9e49 100644 --- a/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php +++ b/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php @@ -31,8 +31,9 @@ class ListGroupAlreadyAddedException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf("[%s] List group %s has already been added.", + $message = sprintf("[%s:%d] List group %s has already been added.", $messageArray[0]->__toString(), + $this->getLine(), $messageArray[1] ); diff --git a/application/hub/exceptions/lists/class_NoListGroupException.php b/application/hub/exceptions/lists/class_NoListGroupException.php index db33a0800..3c666b51e 100644 --- a/application/hub/exceptions/lists/class_NoListGroupException.php +++ b/application/hub/exceptions/lists/class_NoListGroupException.php @@ -31,8 +31,9 @@ class NoListGroupException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf("[%s] List group %s was not found.", + $message = sprintf("[%s:%d] List group %s was not found.", $messageArray[0]->__toString(), + $this->getLine(), $messageArray[1] ); diff --git a/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php b/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php index 55d7df8d2..c33c9db2c 100644 --- a/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php +++ b/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php @@ -31,8 +31,9 @@ class PeerAlreadyRegisteredException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf("[%s] Sender %s is already registered.", + $message = sprintf("[%s:%d] Sender %s is already registered.", $messageArray[0]->__toString(), + $this->getLine(), $messageArray[NetworkPackage::INDEX_PACKAGE_SENDER] ); diff --git a/application/hub/exceptions/state/class_InvalidStateException.php b/application/hub/exceptions/state/class_InvalidStateException.php index 8e0a33936..b89d74f6c 100644 --- a/application/hub/exceptions/state/class_InvalidStateException.php +++ b/application/hub/exceptions/state/class_InvalidStateException.php @@ -31,8 +31,9 @@ class InvalidStateException extends FrameworkException { */ public function __construct (Stateable $stateInstance, $code) { // Construct the message - $message = sprintf("[%s] Unexpected state detected.", - $nodeSateInstance->__toString() + $message = sprintf("[%s:%d] Unexpected state detected.", + $nodeSateInstance->__toString(), + $this->getLine() ); // Call parent exception constructor diff --git a/application/hub/exceptions/tags/class_InvalidTagException.php b/application/hub/exceptions/tags/class_InvalidTagException.php index 6a1237440..3efba6a87 100644 --- a/application/hub/exceptions/tags/class_InvalidTagException.php +++ b/application/hub/exceptions/tags/class_InvalidTagException.php @@ -31,8 +31,9 @@ class InvalidTagException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf("[%s] Tag %s is invalid.", + $message = sprintf("[%s:%d] Tag %s is invalid.", $messageArray[0]->__toString(), + $this->getLine(), $messageArray[1] ); diff --git a/application/hub/exceptions/tasks/class_InvalidTaskException.php b/application/hub/exceptions/tasks/class_InvalidTaskException.php index 5725e7340..e4e3d8b92 100644 --- a/application/hub/exceptions/tasks/class_InvalidTaskException.php +++ b/application/hub/exceptions/tasks/class_InvalidTaskException.php @@ -31,8 +31,9 @@ class InvalidTaskException extends FrameworkException { */ public function __construct (array $messageArray, $code) { // Construct the message - $message = sprintf("[%s] Current task is invalid which should not happen.", - $messageArray[0]->__toString() + $message = sprintf("[%s:%d] Current task is invalid which should not happen.", + $messageArray[0]->__toString(), + $this->getLine() ); // Call parent exception constructor diff --git a/application/hub/init.php b/application/hub/init.php index b6e439545..8ecef8e7b 100644 --- a/application/hub/init.php +++ b/application/hub/init.php @@ -5,14 +5,6 @@ * Please remember that this include file is being loaded *before* the class * loader is loading classes from "exceptions", "interfaces" and "main"! * - * You can prevent adding this application to the selector by uncommenting the - * following line: - * - * if ((isset($this)) && (is_object($this)) && ($this->isClass("ApplicationSelector"))) { return; } - * - * isset() is required to prevent a warning and is_object() is highly required - * when the application itself is requested in URL (hint: index.php?app=your_app) - * * @author Roland Haeder * @version 0.0 * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2011 Hub Developer Team diff --git a/application/hub/interfaces/package/class_Receivable.php b/application/hub/interfaces/package/class_Receivable.php index 9f52f77dd..e8156d2ae 100644 --- a/application/hub/interfaces/package/class_Receivable.php +++ b/application/hub/interfaces/package/class_Receivable.php @@ -25,9 +25,10 @@ interface Receivable extends FrameworkInterface { /** * Checks wether new raw data from the socket has arrived * + * @param $poolInstance An instance of a PoolableListener class * @return $hasArrived Wether raw package data has arrived at a socket */ - function isNewRawDataPending (); + function isNewRawDataPending (PoolableListener $poolInstance); /** * Checks wether a new package has arrived diff --git a/application/hub/main/class_BaseHubSystem.php b/application/hub/main/class_BaseHubSystem.php index 9e61ae2b3..d9f33239b 100644 --- a/application/hub/main/class_BaseHubSystem.php +++ b/application/hub/main/class_BaseHubSystem.php @@ -52,6 +52,11 @@ class BaseHubSystem extends BaseFrameworkSystem { */ private $stateInstance = null; + /** + * Listener pool instance + */ + private $listenerPoolInstance = null; + /** * Protected constructor * @@ -158,6 +163,25 @@ class BaseHubSystem extends BaseFrameworkSystem { return $this->stateInstance; } + /** + * Setter for listener pool instance + * + * @param $listenerPoolInstance Our new listener pool instance + * @return void + */ + protected final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) { + $this->listenerPoolInstance = $listenerPoolInstance; + } + + /** + * Getter for listener pool instance + * + * @return $listenerPoolInstance Our current listener pool instance + */ + public final function getListenerPoolInstance () { + return $this->listenerPoolInstance; + } + /** * Shuts down a given socket resource. This method does only ease calling * the right visitor. diff --git a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php index d9e826827..f77945448 100644 --- a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php +++ b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php @@ -117,6 +117,15 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Vis if (!$this->getIteratorInstance()->valid()) { // Rewind to the beginning for next loop $this->getIteratorInstance()->rewind(); + + // Still not valid? + if ($this->getIteratorInstance()->valid()) { + /* + * Then silently abort here because the queue is empty and to + * save some calls. + */ + return; + } // END - if } // END - if // Try to execute the task diff --git a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php b/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php index ac4ffff0d..34dff9338 100644 --- a/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php +++ b/application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php @@ -58,6 +58,9 @@ class NodeTaskHandlerInitializerFilter extends BaseFilter implements Filterable // Get node instance $nodeInstance = Registry::getRegistry()->getInstance('node'); + // Get the list instance here + $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); + // Get a new task handler instance $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); @@ -68,7 +71,7 @@ class NodeTaskHandlerInitializerFilter extends BaseFilter implements Filterable $handlerInstance->registerTask('socket_listener', $taskInstance); // Generate package reader task - $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_package_reader_task_class'); + $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_package_reader_task_class', array($nodeInstance->getListenerPoolInstance())); // Network package reader, needs to be delayed a little $handlerInstance->registerTask('network_package_reader', $taskInstance); @@ -97,9 +100,6 @@ class NodeTaskHandlerInitializerFilter extends BaseFilter implements Filterable // Register it $handlerInstance->registerTask('update_check', $taskInstance); - // Get the list instance here - $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); - // Prepare a ping task $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_ping_task_class', array($listInstance)); diff --git a/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php b/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php index 2cd9d1661..c563faca7 100644 --- a/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php +++ b/application/hub/main/handler/network/class_BaseNetworkPackageHandler.php @@ -32,11 +32,15 @@ class BaseNetworkPackageHandler extends BaseHandler { const SOCKET_ERROR_UNHANDLED = 'unhandled_package'; // Unhandled raw data (not bad) // - Package errors - const PACKAGE_ERROR_INVALID_DATA = 'invalid_data'; // Invalid data in package found - const PACKAGE_ERROR_INCOMPLETE_DATA = 'incomplete_data'; // Incomplete data sent (e.g. field is missing) - const PACKAGE_ERROR_INVALID_CONTENT = 'invalid_content'; // Content is invalid (e.g. not well-formed) - const PACKAGE_ERROR_RECIPIENT_MISMATCH = 'recipient_error'; // Recipient is not us - const PACKAGE_LEVEL_CHECK_OKAY = 'checked_package'; // Package is fine + const PACKAGE_ERROR_INVALID_DATA = 'invalid_data'; // Invalid data in package found + const PACKAGE_ERROR_INCOMPLETE_DATA = 'incomplete_data'; // Incomplete data sent (e.g. field is missing) + const PACKAGE_ERROR_INVALID_CONTENT = 'invalid_content'; // Content is invalid (e.g. not well-formed) + const PACKAGE_ERROR_RECIPIENT_MISMATCH = 'recipient_error'; // Recipient is not us + const PACKAGE_LEVEL_CHECK_OKAY = 'checked_package'; // Package is fine + + // Package data + const PACKAGE_DECODED_DATA = 'decoded_data'; + const PACKAGE_ERROR_CODE = 'error_code'; /** * Error code from socket @@ -53,6 +57,9 @@ class BaseNetworkPackageHandler extends BaseHandler { // Call parent constructor parent::__construct($className); + // Set error code to 'unknown' + $this->setErrorCode(self::SOCKET_ERROR_UNKNOWN); + // Get an input stream instance $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_input_stream_class', array($this)); @@ -85,10 +92,13 @@ class BaseNetworkPackageHandler extends BaseHandler { * @return void */ protected function addDecodedDataToStacker ($decodedData) { - // Add it + /* + * Add the deocoded data and error code to the stacker so other classes + * (e.g. NetworkPackage) can "pop" it from the stacker. + */ $this->getStackerInstance()->pushNamed('raw_data', array( - 'decoded_data' => $decodedData, - 'error_code' => $this->getErrorCode() + self::PACKAGE_DECODED_DATA => $decodedData, + self::PACKAGE_ERROR_CODE => $this->getErrorCode() )); } @@ -98,9 +108,10 @@ class BaseNetworkPackageHandler extends BaseHandler { * * @param $packageData Raw package data * @return $matches Wether it matches + * @todo This method will be moved to a better place */ protected function ifRecipientMatchesOwnAddress (array $packageData) { - // Construct own address first, + // Construct own address first $ownAddress = Registry::getRegistry()->getInstance('node')->getAddressPort($this); // Does it match? diff --git a/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php b/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php index ab841180d..56a6fe5bc 100644 --- a/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php +++ b/application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php @@ -97,8 +97,8 @@ class TcpNetworkPackageHandler extends BaseNetworkPackageHandler implements Netw $decodedData = $this->getInputStreamInstance()->streamData($rawData); } - // Add the (maybe above decoded) data and error code to the stacker - $this->addRawDataToStacker($decodedData); + // Add the (maybe above decoded) data to the stacker + $this->addDecodedDataToStacker($decodedData); } } diff --git a/application/hub/main/listener/tcp/class_TcpListener.php b/application/hub/main/listener/tcp/class_TcpListener.php index 005831ffc..355019c50 100644 --- a/application/hub/main/listener/tcp/class_TcpListener.php +++ b/application/hub/main/listener/tcp/class_TcpListener.php @@ -162,10 +162,10 @@ class TcpListener extends BaseListener implements Listenable { $this->setIteratorInstance($iteratorInstance); // Initialize the network package handler - $packageInstance = ObjectFactory::createObjectByConfiguredName('tcp_network_package_handler_class'); + $handlerInstance = ObjectFactory::createObjectByConfiguredName('tcp_network_package_handler_class'); // Set it in this class - $this->setPackageInstance($packageInstance); + $this->setHandlerInstance($handlerInstance); // Output message $this->debugOutput('LISTENER: TCP listener now ready on IP ' . $this->getListenAddress() . ', port ' . $this->getListenPort() . ' for service.'); @@ -236,7 +236,7 @@ class TcpListener extends BaseListener implements Listenable { if ($currentSocket != $this->getSocketResource()) { // ... or else it will raise warnings like 'Transport endpoint is not connected' //* NOISY-DEBUG: */ $this->debugOutput('LISTENER: currentSocket=' . $currentSocket); - $this->getPackageInstance()->processResourceRawData($currentSocket); + $this->getHandlerInstance()->processResourceRawData($currentSocket); } // END - if // Advance to next entry. This should be the last line diff --git a/application/hub/main/lists/groups/class_ListGroupList.php b/application/hub/main/lists/groups/class_ListGroupList.php index 045569349..9499afe58 100644 --- a/application/hub/main/lists/groups/class_ListGroupList.php +++ b/application/hub/main/lists/groups/class_ListGroupList.php @@ -54,6 +54,7 @@ class ListGroupList extends BaseList implements Listable { public function getListIterator () { $this->partialStub('Please implement this method.'); } +} // [EOF] ?> diff --git a/application/hub/main/lists/pool/class_PoolEntriesList.php b/application/hub/main/lists/pool/class_PoolEntriesList.php index 4c2208373..485f2cd84 100644 --- a/application/hub/main/lists/pool/class_PoolEntriesList.php +++ b/application/hub/main/lists/pool/class_PoolEntriesList.php @@ -41,8 +41,8 @@ class PoolEntriesList extends BaseList implements Listable { // Get new instance $listInstance = new PoolEntriesList(); - // Add generic group - $listInstance->addGroup('generic'); + // Add 'pool' group + $listInstance->addGroup('pool'); // Return the prepared instance return $listInstance; diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 286fc0051..c312de2bc 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -48,11 +48,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable { */ private $queueConnectorInstance = null; - /** - * Listener pool instance - */ - private $listenerPoolInstance = null; - /** * Wether this node is anncounced (KEEP ON false!) * @deprecated @@ -110,25 +105,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable { return $this->getConfigInstance()->getConfigEntry('node_id'); } - /** - * Setter for listener pool instance - * - * @param $listenerPoolInstance Our new listener pool instance - * @return void - */ - private final function setListenerPoolInstance (PoolableListener $listenerPoolInstance) { - $this->listenerPoolInstance = $listenerPoolInstance; - } - - /** - * Getter for listener pool instance - * - * @return $listenerPoolInstance Our current listener pool instance - */ - public final function getListenerPoolInstance () { - return $this->listenerPoolInstance; - } - /** * Setter for session id * diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 1f9b5d3ba..bdadfa7f8 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -435,7 +435,7 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Receiva // Sanity check if we have packages waiting for delivery if (!$this->isPackageWaitingForDelivery()) { // This is not fatal but should be avoided - $this->debugOutput('PACKAGE: No package is waiting for delivery, but ' . __FUNCTION__ . ' was called.'); + $this->debugOutput('PACKAGE: No package is waiting for delivery, but ' . __METHOD__ . ' was called.'); return; } // END - if @@ -461,10 +461,12 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Receiva /** * Checks wether new raw package data has arrived at a socket * + * @param $poolInstance An instance of a PoolableListener class * @return $hasArrived Wether new raw package data has arrived for processing */ - public function isNewRawDataPending () { + public function isNewRawDataPending (PoolableListener $poolInstance) { // @TODO Add some content here + $this->partialStub('Do something here. poolInstance=' . $poolInstance->__toString()); } /** diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php index 458dc656d..462d3ad1f 100644 --- a/application/hub/main/pools/class_BasePool.php +++ b/application/hub/main/pools/class_BasePool.php @@ -76,7 +76,7 @@ class BasePool extends BaseHubSystem implements Visitable { * @return void */ protected final function addPoolEntry ($poolEntry) { - $this->getPoolEntriesInstance()->addEntry('generic', $poolEntry); + $this->getPoolEntriesInstance()->addEntry('pool', $poolEntry); } /** diff --git a/application/hub/main/pools/peer/class_DefaultPeerPool.php b/application/hub/main/pools/peer/class_DefaultPeerPool.php index daab465ee..11c91f508 100644 --- a/application/hub/main/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/main/pools/peer/class_DefaultPeerPool.php @@ -121,7 +121,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ public final function getAllSockets () { // Get the list - $sockets = $this->getArrayFromList('generic'); + $sockets = $this->getArrayFromList('pool'); // Return it return $sockets; diff --git a/application/hub/main/resolver/state/network/class_NetworkStateResolver.php b/application/hub/main/resolver/state/network/class_NetworkStateResolver.php index fc9ed7507..8fcdbccaa 100644 --- a/application/hub/main/resolver/state/network/class_NetworkStateResolver.php +++ b/application/hub/main/resolver/state/network/class_NetworkStateResolver.php @@ -80,8 +80,8 @@ class NetworkStateResolver extends BaseStateResolver implements StateResolver { // @TODO On some systems it is 134, on some 107? $errorCode = BaseNetworkPackageHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT; } elseif (is_int($errorCode)) { - // Debug output (because we might want to handle it like the above(s) - $this->debugOutput(__METHOD__ . ': UNKNOWN ERROR CODE = ' . $errorCode, ', MESSAGE = ' . socket_strerror($errorCode)); + // Unhandled error code detected, so first debug it because we may want to handle it like the others + $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] UNKNOWN ERROR CODE = ' . $errorCode, ', MESSAGE = ' . socket_strerror($errorCode)); // Change it only in this class $errorCode = BaseNetworkPackageHandler::SOCKET_ERROR_UNKNOWN; diff --git a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php index 3f847aa83..18b730ff0 100644 --- a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php +++ b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php @@ -35,12 +35,16 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { /** * Creates an instance of this class * + * @param $poolInstance An instance of a PoolableListener class * @return $taskInstance An instance of a Taskable/Visitable class */ - public static final function createNetworkPackageReaderTask () { + public static final function createNetworkPackageReaderTask (PoolableListener $poolInstance) { // Get new instance $taskInstance = new NetworkPackageReaderTask(); + // Set the listener instance here + $taskInstance->setListenerPoolInstance($poolInstance); + // Return the prepared instance return $taskInstance; } @@ -66,7 +70,7 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); // Do we have something to handle? - if ($packageInstance->isNewRawDataPending()) { + if ($packageInstance->isNewRawDataPending($this->getListenerPoolInstance())) { // We have to handle raw data from the socket $packageInstance->handleIncomingSocketRawData(); } elseif ($packageInstance->isNewPackageArrived()) { -- 2.39.5