Browse Source

Fixed problem that `listen` may return incorrect value when calling `stop`;

yhirose 7 years ago
parent
commit
07910f73a9
1 changed files with 3 additions and 2 deletions
  1. 3 2
      httplib.h

+ 3 - 2
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);
     }
 }