diff options
Diffstat (limited to 'fnet/src')
-rw-r--r-- | fnet/src/vespa/fnet/connection.cpp | 5 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/connection.h | 10 |
2 files changed, 14 insertions, 1 deletions
diff --git a/fnet/src/vespa/fnet/connection.cpp b/fnet/src/vespa/fnet/connection.cpp index 74a7d19387c..bf29cc29c18 100644 --- a/fnet/src/vespa/fnet/connection.cpp +++ b/fnet/src/vespa/fnet/connection.cpp @@ -13,6 +13,8 @@ #include <vespa/log/log.h> LOG_SETUP(".fnet"); +std::atomic<uint64_t> FNET_Connection::_num_connections = 0; + namespace { class SyncPacket : public FNET_DummyPacket { private: @@ -489,6 +491,7 @@ FNET_Connection::FNET_Connection(FNET_TransportThread *owner, _cleanup(nullptr) { assert(_socket && (_socket->get_fd() >= 0)); + ++_num_connections; } @@ -526,6 +529,7 @@ FNET_Connection::FNET_Connection(FNET_TransportThread *owner, _adminChannel = admin.get(); _channels.Register(admin.release()); } + ++_num_connections; } @@ -536,6 +540,7 @@ FNET_Connection::~FNET_Connection() delete _adminChannel; } assert(_cleanup == nullptr); + --_num_connections; } diff --git a/fnet/src/vespa/fnet/connection.h b/fnet/src/vespa/fnet/connection.h index 760b1b96d4d..c9c49c5151a 100644 --- a/fnet/src/vespa/fnet/connection.h +++ b/fnet/src/vespa/fnet/connection.h @@ -10,6 +10,7 @@ #include <vespa/vespalib/net/socket_handle.h> #include <vespa/vespalib/net/async_resolver.h> #include <vespa/vespalib/net/crypto_socket.h> +#include <atomic> class FNET_IPacketStreamer; class FNET_IServerAdapter; @@ -111,6 +112,8 @@ private: FNET_IConnectionCleanupHandler *_cleanup; // cleanup handler + static std::atomic<uint64_t> _num_connections; // total number of connections + FNET_Connection(const FNET_Connection &); FNET_Connection &operator=(const FNET_Connection &); @@ -517,5 +520,10 @@ public: */ uint32_t getInputBufferSize() const { return _input.GetBufSize(); } + /** + * @return the total number of connection objects + **/ + static uint64_t get_num_connections() { + return _num_connections.load(std::memory_order_relaxed); + } }; - |