Kea 2.7.4
connection_pool.cc
Go to the documentation of this file.
1// Copyright (C) 2017-2024 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#include <config.h>
8
12
13namespace isc {
14namespace http {
15
16void
18 if (util::MultiThreadingMgr::instance().getMode()) {
19 std::lock_guard<std::mutex> lk(mutex_);
20 connections_.insert(connections_.end(), connection);
21 } else {
22 connections_.insert(connections_.end(), connection);
23 }
24
25 connection->asyncAccept();
26}
27
28void
30 if (util::MultiThreadingMgr::instance().getMode()) {
31 std::lock_guard<std::mutex> lk(mutex_);
32 connections_.remove(connection);
33 } else {
34 connections_.remove(connection);
35 }
36
37 connection->close();
38}
39
40void
42 if (util::MultiThreadingMgr::instance().getMode()) {
43 std::lock_guard<std::mutex> lk(mutex_);
44 connections_.remove(connection);
45 } else {
46 connections_.remove(connection);
47 }
48
49 connection->shutdown();
50}
51
52void
54 if (util::MultiThreadingMgr::instance().getMode()) {
55 std::lock_guard<std::mutex> lk(mutex_);
57 } else {
59 }
60}
61
62void
64 for (auto const& connection : connections_) {
65 connection->close();
66 }
67
68 connections_.clear();
69}
70
71}
72}
void stopAll()
Stops all connections and removes them from the pool.
void stop(const HttpConnectionPtr &connection)
Removes a connection from the pool and stops it.
void start(const HttpConnectionPtr &connection)
Start new connection.
std::list< HttpConnectionPtr > connections_
Set of connections.
std::mutex mutex_
Mutex to protect the internal state.
void stopAllInternal()
Stops all connections and removes them from the pool.
void shutdown(const HttpConnectionPtr &connection)
Removes a connection from the pool and shutdown it.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
boost::shared_ptr< HttpConnection > HttpConnectionPtr
Pointer to the HttpConnection.
Definition connection.h:41
Defines the logger used by the top-level component of kea-lfc.