| 6709 | } |
| 6710 | |
| 6711 | inline void ClientImpl::close_socket(Socket &socket) { |
| 6712 | // If there are requests in flight in another thread, usually closing |
| 6713 | // the socket will be fine and they will simply receive an error when |
| 6714 | // using the closed socket, but it is still a bug since rarely the OS |
| 6715 | // may reassign the socket id to be used for a new socket, and then |
| 6716 | // suddenly they will be operating on a live socket that is different |
| 6717 | // than the one they intended! |
| 6718 | assert(socket_requests_in_flight_ == 0 || |
| 6719 | socket_requests_are_from_thread_ == std::this_thread::get_id()); |
| 6720 | |
| 6721 | // It is also a bug if this happens while SSL is still active |
| 6722 | #ifdef CPPHTTPLIB_OPENSSL_SUPPORT |
| 6723 | assert(socket.ssl == nullptr); |
| 6724 | #endif |
| 6725 | if (socket.sock == INVALID_SOCKET) { return; } |
| 6726 | detail::close_socket(socket.sock); |
| 6727 | socket.sock = INVALID_SOCKET; |
| 6728 | } |
| 6729 | |
| 6730 | inline bool ClientImpl::read_response_line(Stream &strm, const Request &req, |
| 6731 | Response &res) { |
nothing calls this directly
no test coverage detected