NetworkSession: micro optimisation - do not check if a debugger is active unless the packet limit is exceeded

This commit is contained in:
Dylan K. Taylor 2023-01-08 19:45:14 +00:00
parent dd355c58d8
commit 0233e74f4f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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();