summaryrefslogtreecommitdiffhomepage
path: root/whiteboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'whiteboard.cpp')
-rw-r--r--whiteboard.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/whiteboard.cpp b/whiteboard.cpp
index 6a71d3b..044321b 100644
--- a/whiteboard.cpp
+++ b/whiteboard.cpp
@@ -437,7 +437,12 @@ void Whiteboard::on_accept(boost::system::error_code ec, boost::asio::ip::tcp::s
if (ec) {
std::cerr << "Error on accept: " << ec.message() << std::endl;
} else {
- std::make_shared<session>(m_registry, *m_storage, m_storage_mutex, std::move(socket))->run();
+ if (m_registry.number_of_connections() >= m_config->getMaxConnections()) {
+ // limit reached
+ socket.close();
+ } else {
+ std::make_shared<session>(m_registry, *m_storage, m_storage_mutex, std::move(socket))->run();
+ }
}
do_accept();