Browse Source

Fixed ClientStop test error.

yhirose 5 years ago
parent
commit
0743d78c9b
1 changed files with 2 additions and 1 deletions
  1. 2 1
      httplib.h

+ 2 - 1
httplib.h

@@ -5054,7 +5054,9 @@ inline void Client::stop() {
   std::lock_guard<std::mutex> guard(socket_mutex_);
   if (socket_.is_open()) {
     detail::shutdown_socket(socket_.sock);
+    std::this_thread::sleep_for(std::chrono::milliseconds(10));
     close_socket(socket_, true);
+    std::this_thread::sleep_for(std::chrono::milliseconds(10));
   }
 }
 
@@ -5562,7 +5564,6 @@ inline bool SSLClient::initialize_ssl(Socket &socket) {
 inline void SSLClient::close_socket(Socket &socket, bool process_socket_ret) {
   detail::close_socket(socket.sock);
   socket_.sock = INVALID_SOCKET;
-  std::this_thread::sleep_for(std::chrono::milliseconds(10));
   if (socket.ssl) {
     detail::ssl_delete(ctx_mutex_, socket.ssl, process_socket_ret);
     socket_.ssl = nullptr;