From 07910f73a929186ff8daaa769e6dc3f4ea8ccb3e Mon Sep 17 00:00:00 2001 From: yhirose Date: Tue, 31 Jul 2018 19:46:04 -0400 Subject: [PATCH] Fixed problem that `listen` may return incorrect value when calling `stop`; --- httplib.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httplib.h b/httplib.h index 2544c88..909d9ec 100644 --- a/httplib.h +++ b/httplib.h @@ -1516,9 +1516,10 @@ inline void Server::stop() { if (is_running_) { assert(svr_sock_ != INVALID_SOCKET); - detail::shutdown_socket(svr_sock_); - detail::close_socket(svr_sock_); + auto sock = svr_sock_; svr_sock_ = INVALID_SOCKET; + detail::shutdown_socket(sock); + detail::close_socket(sock); } }