From 63bed8c8d376d13cb3a86f78966884c649745ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Dupuis?= Date: Tue, 20 Aug 2024 16:51:58 +0200 Subject: [PATCH] Use Int64 for TcpServerDispatcher::totalConnections(), to prevent overflow --- Net/include/Poco/Net/TCPServer.h | 2 +- Net/include/Poco/Net/TCPServerDispatcher.h | 14 +++++++------- Net/src/TCPServer.cpp | 2 +- Net/src/TCPServerDispatcher.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Net/include/Poco/Net/TCPServer.h b/Net/include/Poco/Net/TCPServer.h index 8c22964d5..efc8c6f35 100644 --- a/Net/include/Poco/Net/TCPServer.h +++ b/Net/include/Poco/Net/TCPServer.h @@ -175,7 +175,7 @@ public: int maxThreads() const; /// Returns the maximum number of threads available. - int totalConnections() const; + Int64 totalConnections() const; /// Returns the total number of handled connections. int currentConnections() const; diff --git a/Net/include/Poco/Net/TCPServerDispatcher.h b/Net/include/Poco/Net/TCPServerDispatcher.h index 9965e1ace..3088fa265 100644 --- a/Net/include/Poco/Net/TCPServerDispatcher.h +++ b/Net/include/Poco/Net/TCPServerDispatcher.h @@ -68,7 +68,7 @@ public: int maxThreads() const; /// Returns the maximum number of threads available. - int totalConnections() const; + Int64 totalConnections() const; /// Returns the total number of handled connections. int currentConnections() const; @@ -103,12 +103,12 @@ private: std::atomic _rc; TCPServerParams::Ptr _pParams; - std::atomic _currentThreads; - std::atomic _totalConnections; - std::atomic _currentConnections; - std::atomic _maxConcurrentConnections; - std::atomic _refusedConnections; - std::atomic _stopped; + std::atomic _currentThreads; + std::atomic _totalConnections; + std::atomic _currentConnections; + std::atomic _maxConcurrentConnections; + std::atomic _refusedConnections; + std::atomic _stopped; Poco::NotificationQueue _queue; TCPServerConnectionFactory::Ptr _pConnectionFactory; Poco::ThreadPool& _threadPool; diff --git a/Net/src/TCPServer.cpp b/Net/src/TCPServer.cpp index ea307b399..ebf48a7e6 100644 --- a/Net/src/TCPServer.cpp +++ b/Net/src/TCPServer.cpp @@ -185,7 +185,7 @@ int TCPServer::maxThreads() const } -int TCPServer::totalConnections() const +Int64 TCPServer::totalConnections() const { return _pDispatcher->totalConnections(); } diff --git a/Net/src/TCPServerDispatcher.cpp b/Net/src/TCPServerDispatcher.cpp index 2d974ae93..d798ba8f5 100644 --- a/Net/src/TCPServerDispatcher.cpp +++ b/Net/src/TCPServerDispatcher.cpp @@ -195,7 +195,7 @@ int TCPServerDispatcher::maxThreads() const } -int TCPServerDispatcher::totalConnections() const +Int64 TCPServerDispatcher::totalConnections() const { return _totalConnections; }