From 0233e74f4fddaceb47036cc8d7e232d6f3b3a773 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 8 Jan 2023 19:45:14 +0000 Subject: [PATCH] NetworkSession: micro optimisation - do not check if a debugger is active unless the packet limit is exceeded --- src/network/mcpe/NetworkSession.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 3faf24720..ee95d6122 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -360,12 +360,16 @@ class NetworkSession{ return; } - if(!function_exists('xdebug_is_debugger_active') || !xdebug_is_debugger_active()){ - if($this->incomingPacketBatchBudget <= 0){ + if($this->incomingPacketBatchBudget <= 0){ + if(!function_exists('xdebug_is_debugger_active') || !xdebug_is_debugger_active()){ throw new PacketHandlingException("Receiving packets too fast"); + }else{ + //when a debugging session is active, the server may halt at any point for an indefinite length of time, + //in which time the client will continue to send packets + $this->incomingPacketBatchBudget = self::INCOMING_PACKET_BATCH_MAX_BUDGET; } - $this->incomingPacketBatchBudget--; } + $this->incomingPacketBatchBudget--; if($this->cipher !== null){ Timings::$playerNetworkReceiveDecrypt->startTiming();