NetworkSession: fixed some segments of recv/send logic not being covered by their respective network timingsÂ

This commit is contained in:
Dylan K. Taylor 2023-02-19 17:21:10 +00:00
parent d5e92b4ae6
commit 4dbcd714bd
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -376,6 +376,8 @@ class NetworkSession{
return;
}
Timings::$playerNetworkReceive->startTiming();
try{
if($this->incomingPacketBatchBudget <= 0){
$this->updatePacketBudget();
if($this->incomingPacketBatchBudget <= 0){
@ -433,6 +435,9 @@ class NetworkSession{
$this->logger->logException($e);
throw PacketHandlingException::wrap($e, "Packet batch decode error");
}
}finally{
Timings::$playerNetworkReceive->stopTiming();
}
}
/**
@ -519,6 +524,8 @@ class NetworkSession{
private function flushSendBuffer(bool $immediate = false) : void{
if(count($this->sendBuffer) > 0){
Timings::$playerNetworkSend->startTiming();
try{
$syncMode = null; //automatic
if($immediate){
$syncMode = true;
@ -537,6 +544,9 @@ class NetworkSession{
}
$this->sendBuffer = [];
$this->queueCompressedNoBufferFlush($promise, $immediate);
}finally{
Timings::$playerNetworkSend->stopTiming();
}
}
}
@ -549,11 +559,18 @@ class NetworkSession{
}
public function queueCompressed(CompressBatchPromise $payload, bool $immediate = false) : void{
Timings::$playerNetworkSend->startTiming();
try{
$this->flushSendBuffer($immediate); //Maintain ordering if possible
$this->queueCompressedNoBufferFlush($payload, $immediate);
}finally{
Timings::$playerNetworkSend->stopTiming();
}
}
private function queueCompressedNoBufferFlush(CompressBatchPromise $payload, bool $immediate = false) : void{
Timings::$playerNetworkSend->startTiming();
try{
if($immediate){
//Skips all queues
$this->sendEncoded($payload->getResult(), true);
@ -579,6 +596,9 @@ class NetworkSession{
}
});
}
}finally{
Timings::$playerNetworkSend->stopTiming();
}
}
private function sendEncoded(string $payload, bool $immediate = false) : void{