| 12610 | } |
| 12611 | |
| 12612 | inline void ClientImpl::close_socket(Socket &socket) { |
| 12613 | // If there are requests in flight in another thread, usually closing |
| 12614 | // the socket will be fine and they will simply receive an error when |
| 12615 | // using the closed socket, but it is still a bug since rarely the OS |
| 12616 | // may reassign the socket id to be used for a new socket, and then |
| 12617 | // suddenly they will be operating on a live socket that is different |
| 12618 | // than the one they intended! |
| 12619 | assert(socket_requests_in_flight_ == 0 || |
| 12620 | socket_requests_are_from_thread_ == std::this_thread::get_id()); |
| 12621 | |
| 12622 | // It is also a bug if this happens while SSL is still active |
| 12623 | #ifdef CPPHTTPLIB_SSL_ENABLED |
| 12624 | assert(socket.ssl == nullptr); |
| 12625 | #endif |
| 12626 | |
| 12627 | if (socket.sock == INVALID_SOCKET) { return; } |
| 12628 | detail::close_socket(socket.sock); |
| 12629 | socket.sock = INVALID_SOCKET; |
| 12630 | } |
| 12631 | |
| 12632 | inline void ClientImpl::disconnect(bool gracefully) { |
| 12633 | shutdown_ssl(socket_, gracefully); |
nothing calls this directly
no test coverage detected