From 27df1a4bb9c70e4b93be06dffc860fed1cd38085 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 16 Dec 2021 15:32:09 +0100 Subject: [PATCH] Continued: - *_socket_listen_backlog is now being "cached" in static array to avoid some "expensive" invocations on configuration class - updated 'core' framework MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../classes/container/socket/class_SocketContainer.php | 5 ++++- .../handler/package/class_NetworkPackageHandler.php | 2 +- application/hub/classes/tools/hub/class_HubTools.php | 10 +++++----- application/hub/config.php | 3 +++ core | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index e574a84b8..dce21206b 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -176,6 +176,9 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $socketInstance->setPackageDataInstance($packageInstance); $socketInstance->setSocketType($socketType); + // Set more configuration entries + self::$configEntries[sprintf('%s_socket_listen_backlog', $socketInstance->getSocketType())] = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry(sprintf('%s_socket_listen_backlog', $socketInstance->getSocketProtocol())); + // Return the prepared instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketInstance=%s - EXIT!', strtoupper($socketProtocol), $socketInstance->__toString())); return $socketInstance; @@ -569,7 +572,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Try to listen on socket - $result = socket_listen($this->getSocketResource(), FrameworkBootstrap::getConfigurationInstance()->getConfigEntry(sprintf('%s_socket_listen_backlog', $this->getSocketProtocol()))); + $result = socket_listen($this->getSocketResource(), self::$configEntries[sprintf('%s_socket_listen_backlog', $this->getSocketType())]); // Return result /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result[%s]=%d,errorCode=%s - EXIT!', strtoupper($this->getSocketProtocol()), gettype($result), intval($result), $this->getLastSocketErrorCode())); diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 39730da4f..a40593e61 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -849,7 +849,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: content(%d)=%s', strlen($content), $content)); if (empty($content)) { // Abort here - throw new UnexpectedValueException('content cannot be empty.'); + throw new UnexpectedValueException('Parameter "content" is empty'); } // ... and compress it diff --git a/application/hub/classes/tools/hub/class_HubTools.php b/application/hub/classes/tools/hub/class_HubTools.php index cfe20d60b..6bd85854d 100644 --- a/application/hub/classes/tools/hub/class_HubTools.php +++ b/application/hub/classes/tools/hub/class_HubTools.php @@ -215,9 +215,10 @@ class HubTools extends BaseHubSystem { */ public static function resolveSessionIdToUnl (string $address) { // Is the parameter valid? + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: address=%s - CALLED!', $address)); if (empty($address)) { // No empty address - throw new InvalidArgumentException('Parameter "address" cannot be empty'); + throw new InvalidArgumentException('Parameter "address" is empty'); } // Get an own instance @@ -232,20 +233,19 @@ class HubTools extends BaseHubSystem { // Direct Universal Node Locator found self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Direct Universal Node Locator ' . $address . ' detected.'); } elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $address)) { - // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Using internal session id resolver.'); - // Resolve session id into an instance of a LocateableNode class + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Using internal session id resolver.'); $recipient = $selfInstance->resolveUniversalNodeLocatorBySessionId($address); // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Session id ' . $address . ' resolved to ' . $recipient); + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Session id ' . $address . ' resolved to ' . $recipient); } else { // Invalid session id/UNL throw new InvalidSessionIdException($address, self::EXCEPTION_SESSION_ID_IS_INVALID); } // Return it + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-TOOLS: recipient=%s - EXIT!', $recipient)); return $recipient; } diff --git a/application/hub/config.php b/application/hub/config.php index 645baa120..c7a5d80ee 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -802,6 +802,9 @@ $cfg->setConfigEntry('file_socket_listen_backlog', 0); // CFG: TCP-SOCKET-LISTEN-BACKLOG $cfg->setConfigEntry('tcp_socket_listen_backlog', 1000); +// CFG: UDP-SOCKET-LISTEN-BACKLOG +$cfg->setConfigEntry('udp_socket_listen_backlog', 1000); + // CFG: EXTERNAL-ADDRESS $cfg->setConfigEntry('external_address', ''); diff --git a/core b/core index 08578b5e2..d06cac435 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 08578b5e2e37e31e45d24c17c01a6b8bc0abd53b +Subproject commit d06cac435541022230e4bda9ad28cd75b41907a4 -- 2.39.5