mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-14 16:58:30 +00:00
parent
ebe7efa1cc
commit
71ba7e7b1b
2 changed files with 93 additions and 0 deletions
10
httplib.h
10
httplib.h
|
@ -7333,6 +7333,16 @@ inline ClientImpl::ClientImpl(const std::string &host, int port,
|
|||
client_cert_path_(client_cert_path), client_key_path_(client_key_path) {}
|
||||
|
||||
inline ClientImpl::~ClientImpl() {
|
||||
// Wait until all the requests in flight are handled.
|
||||
size_t retry_count = 10;
|
||||
while (retry_count-- > 0) {
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(socket_mutex_);
|
||||
if (socket_requests_in_flight_ == 0) { break; }
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{1});
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(socket_mutex_);
|
||||
shutdown_socket(socket_);
|
||||
close_socket(socket_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue