Kea  2.3.5-git
connection_pool.cc
Go to the documentation of this file.
1 // Copyright (C) 2017-2021 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 
10 #include <http/connection_pool.h>
12 
13 namespace isc {
14 namespace http {
15 
16 void
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 
28 void
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 
40 void
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 
52 void
54  if (util::MultiThreadingMgr::instance().getMode()) {
55  std::lock_guard<std::mutex> lk(mutex_);
57  } else {
59  }
60 }
61 
62 void
64  for (auto connection = connections_.begin();
65  connection != connections_.end();
66  ++connection) {
67  (*connection)->close();
68  }
69 
70  connections_.clear();
71 }
72 
73 }
74 }
void start(const HttpConnectionPtr &connection)
Start new connection.
std::list< HttpConnectionPtr > connections_
Set of connections.
static MultiThreadingMgr & instance()
Returns a single instance of Multi Threading Manager.
void stopAllInternal()
Stops all connections and removes them from the pool.
std::mutex mutex_
Mutex to protect the internal state.
void stop(const HttpConnectionPtr &connection)
Removes a connection from the pool and stops it.
Defines the logger used by the top-level component of kea-lfc.
void stopAll()
Stops all connections and removes them from the pool.
boost::shared_ptr< HttpConnection > HttpConnectionPtr
Pointer to the HttpConnection.
Definition: connection.h:38
void shutdown(const HttpConnectionPtr &connection)
Removes a connection from the pool and shutdown it.