From d075f82993a3b3365ae8196c26696f9b41e66060 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 16 Feb 2014 00:56:05 +0100 Subject: [PATCH] The chunk handler instance of the assember class is now set for avoiding expensive code + commented out debug code as the bug is not located here. Signed-off-by: Roland Haeder --- .../assembler/class_PackageAssembler.php | 18 +++++++++++------- .../hub/main/package/class_NetworkPackage.php | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/application/hub/main/package/assembler/class_PackageAssembler.php b/application/hub/main/package/assembler/class_PackageAssembler.php index 48b98f35a..e991f28d1 100644 --- a/application/hub/main/package/assembler/class_PackageAssembler.php +++ b/application/hub/main/package/assembler/class_PackageAssembler.php @@ -62,6 +62,12 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable // And set it $assemblerInstance->setInputStreamInstance($streamInstance); + // Now get a chunk handler instance + $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); + + // Set handler instance + $assemblerInstance->setHandlerInstance($handlerInstance); + // Return the prepared instance return $assemblerInstance; } @@ -145,7 +151,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable */ private function handlePackageByUnhandledPackage (array $packageContent) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); // Check for some conditions if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) { @@ -181,7 +187,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable */ public function handlePendingData () { // Debug output - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData); // Assert on condition assert(!$this->isPendingDataEmpty()); @@ -196,7 +202,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable $this->pendingData = ''; // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.'); // Make sure last CHUNK_SEPARATOR is not there if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) { @@ -211,11 +217,9 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable */ $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); - // Now get a chunk handler instance - $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); - // Add all chunks because the last final chunk is found - $handlerInstance->addAllChunksWithFinal($chunks); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Going to add ' . count($chunks) . ' to chunk handler ...'); + $this->getHandlerInstance()->addAllChunksWithFinal($chunks); } } diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 66d60be41..dbbbf98ab 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -870,7 +870,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $decodedData = $handlerInstance->getNextRawData(); // Very noisy debug message: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE)); // And push it on our stack $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $decodedData); -- 2.39.5