Kea 2.5.8
tcp_connection_pool.h
Go to the documentation of this file.
1// Copyright (C) 2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef TCP_CONNECTION_POOL_H
8#define TCP_CONNECTION_POOL_H
9
10#include <tcp/tcp_connection.h>
11
12#include <list>
13#include <mutex>
14
15namespace isc {
16namespace tcp {
17
19typedef std::list<TcpConnectionPtr> TcpConnectionList;
20
34public:
35
42 void start(const TcpConnectionPtr& connection);
43
53 void shutdown(const TcpConnectionPtr& connection);
54
58 void stop(const TcpConnectionPtr& connection);
59
64 void stopAll();
65
73 size_t usedByRemoteIp(const asiolink::IOAddress& remote_ip,
74 size_t& total_connections);
75
77 static std::atomic<uint64_t> started_counter_;
78
80 static std::atomic<uint64_t> stopped_counter_;
81
83 static std::atomic<uint64_t> rejected_counter_;
84
85protected:
86
90 void stopAllInternal();
91
100 size_t usedByRemoteIpInternal(const asiolink::IOAddress& remote_ip,
101 size_t& total_connections);
102
105
107 std::mutex mutex_;
108};
109
110}
111}
112
113#endif
Pool of active TCP connections.
void stopAll()
Stops all connections and removes them from the pool.
void stop(const TcpConnectionPtr &connection)
Removes a connection from the pool and stops it.
void stopAllInternal()
Stops all connections and removes them from the pool.
size_t usedByRemoteIp(const asiolink::IOAddress &remote_ip, size_t &total_connections)
Returns the number of connections using a given remote IP address.
static std::atomic< uint64_t > rejected_counter_
Class/static rejected (by the accept filter) connection counter.
size_t usedByRemoteIpInternal(const asiolink::IOAddress &remote_ip, size_t &total_connections)
Returns the number of connections using a given remote IP address.
static std::atomic< uint64_t > stopped_counter_
Class/static stopped (i.e. removed from pool) connection counter.
void shutdown(const TcpConnectionPtr &connection)
Removes a connection from the pool and shutdown it.
std::mutex mutex_
Mutex to protect the internal state.
void start(const TcpConnectionPtr &connection)
Start new connection.
static std::atomic< uint64_t > started_counter_
Class/static started (i.e. added to pool) connection counter.
TcpConnectionList connections_
Set of connections.
boost::shared_ptr< TcpConnection > TcpConnectionPtr
Pointer to the TcpConnection.
std::list< TcpConnectionPtr > TcpConnectionList
Type of TCP connection pointer list.
Defines the logger used by the top-level component of kea-lfc.