diff --git a/server_http.hpp b/server_http.hpp index 84b410b..f49c41d 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -279,7 +279,6 @@ namespace SimpleWeb { std::shared_ptr handler_runner; std::unique_ptr socket; // Socket must be unique_ptr since asio::ssl::stream is not movable - std::mutex socket_close_mutex; std::unique_ptr timer; @@ -287,9 +286,8 @@ namespace SimpleWeb { void close() noexcept { error_code ec; - std::unique_lock lock(socket_close_mutex); // The following operations seems to be needed to run sequentially socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); - socket->lowest_layer().close(ec); + socket->lowest_layer().cancel(ec); } void set_timeout(long seconds) noexcept {