From 3541dd787928c4a4c4e71aba8beb1ac39e791452 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 12 Jul 2017 10:03:52 +0200 Subject: [PATCH] ::stop now closes connections even though internal io_service is used --- client_http.hpp | 6 ++---- server_http.hpp | 11 ++++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/client_http.hpp b/client_http.hpp index 964bdef..a613746 100644 --- a/client_http.hpp +++ b/client_http.hpp @@ -360,10 +360,8 @@ namespace SimpleWeb { void stop() { std::unique_lock lock(connections_mutex); for(auto it = connections.begin(); it != connections.end();) { - if(!internal_io_service) { - (*it)->attempt_reconnect = false; - (*it)->close(); - } + (*it)->attempt_reconnect = false; + (*it)->close(); it = connections.erase(it); } } diff --git a/server_http.hpp b/server_http.hpp index 3658bc2..bd1f068 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -419,15 +419,16 @@ namespace SimpleWeb { void stop() { if(acceptor) { acceptor->close(); - if(internal_io_service) - io_service->stop(); - std::unique_lock lock(*connections_mutex); - if(!internal_io_service) { + { + std::unique_lock lock(*connections_mutex); for(auto &connection : *connections) connection->close(); + connections->clear(); } - connections->clear(); + + if(internal_io_service) + io_service->stop(); } }