From 4431adb2ce113fac0f37b14a07a73f805a38f0d3 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 25 Mar 2024 18:04:30 +0800 Subject: [PATCH] Fix error with uninitialized connectionStatistics object --- src/Server/Connection/TcpConnection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Server/Connection/TcpConnection.php b/src/Server/Connection/TcpConnection.php index 15cf373..1bef224 100644 --- a/src/Server/Connection/TcpConnection.php +++ b/src/Server/Connection/TcpConnection.php @@ -50,6 +50,7 @@ public function __construct( private readonly \Closure|null $onClose = null, private readonly \Closure|null $onError = null, ) { + $this->connectionStatistics = new ConnectionStatistics(); $clientSocket = \stream_socket_accept($socket, 0, $remoteAddress); if ($clientSocket === false) { if ($this->onError) { @@ -73,7 +74,6 @@ public function __construct( \stream_set_blocking($this->socket, false); $this->onReadableCallbackId = $this->eventLoop->onReadable($this->socket, $this->baseRead(...)); - $this->connectionStatistics = new ConnectionStatistics(); ActiveConnection::addConnection($this); if ($this->onConnect !== null) {