19 TcpConnectionPool::started_counter_(0);
22 TcpConnectionPool::stopped_counter_(0);
25 TcpConnectionPool::rejected_counter_(0);
30 std::lock_guard<std::mutex> lk(mutex_);
31 connections_.insert(connections_.end(), connection);
32 started_counter_ += 1;
34 connections_.insert(connections_.end(), connection);
35 started_counter_ += 1;
38 connection->asyncAccept();
44 std::lock_guard<std::mutex> lk(mutex_);
45 size_t before = connections_.size();
46 connections_.remove(connection);
47 size_t after = connections_.size();
48 stopped_counter_ += before - after;
50 size_t before = connections_.size();
51 connections_.remove(connection);
52 size_t after = connections_.size();
53 stopped_counter_ += before - after;
62 std::lock_guard<std::mutex> lk(mutex_);
63 size_t before = connections_.size();
64 connections_.remove(connection);
65 size_t after = connections_.size();
66 stopped_counter_ += before - after;
68 size_t before = connections_.size();
69 connections_.remove(connection);
70 size_t after = connections_.size();
71 stopped_counter_ += before - after;
74 connection->shutdown();
78 TcpConnectionPool::stopAll() {
80 std::lock_guard<std::mutex> lk(mutex_);
88 TcpConnectionPool::stopAllInternal() {
89 for (
auto connection = connections_.begin();
90 connection != connections_.end();
92 (*connection)->close();
95 size_t cnt = connections_.size();
97 stopped_counter_ += cnt;
101 TcpConnectionPool::usedByRemoteIp(
const IOAddress& remote_ip,
102 size_t& total_connections) {
104 std::lock_guard<std::mutex> lk(mutex_);
105 return (usedByRemoteIpInternal(remote_ip, total_connections));
107 return (usedByRemoteIpInternal(remote_ip, total_connections));
112 TcpConnectionPool::usedByRemoteIpInternal(
const IOAddress& remote_ip,
113 size_t& total_connections) {
114 total_connections = connections_.size();
116 for (
const auto& conn : connections_) {
117 const auto& ep = conn->getRemoteEndpoint();
118 if ((ep != TcpConnection::NO_ENDPOINT()) &&
119 (
IOAddress(ep.address()) == remote_ip)) {
The IOAddress class represents an IP addresses (version agnostic)
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
boost::shared_ptr< TcpConnection > TcpConnectionPtr
Pointer to the TcpConnection.
Defines the logger used by the top-level component of kea-lfc.