Skip to content

Commit 4d6a649

Browse files
committed
Simplified
1 parent bad120e commit 4d6a649

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

httplib.h

+11-16
Original file line numberDiff line numberDiff line change
@@ -8551,24 +8551,19 @@ inline void ssl_delete(std::mutex &ctx_mutex, SSL *ssl, socket_t sock,
85518551
#ifdef _WIN32
85528552
SSL_shutdown(ssl);
85538553
#else
8554-
auto is_peer_could_be_closed = false;
8555-
{
8556-
timeval tv;
8557-
tv.tv_sec = 1;
8558-
tv.tv_usec = 0;
8559-
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
8560-
reinterpret_cast<const void *>(&tv), sizeof(tv));
8561-
8554+
timeval tv;
8555+
tv.tv_sec = 1;
8556+
tv.tv_usec = 0;
8557+
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO,
8558+
reinterpret_cast<const void *>(&tv), sizeof(tv));
8559+
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
8560+
reinterpret_cast<const void *>(&tv), sizeof(tv));
8561+
8562+
auto ret = SSL_shutdown(ssl);
8563+
while (ret == 0) {
85628564
std::this_thread::sleep_for(std::chrono::milliseconds(100));
8563-
8564-
char buf[1];
8565-
if (SSL_peek(ssl, buf, 1) == 0 &&
8566-
SSL_get_error(ssl, 0) == SSL_ERROR_ZERO_RETURN) {
8567-
is_peer_could_be_closed = true;
8568-
}
8565+
ret = SSL_shutdown(ssl);
85698566
}
8570-
8571-
if (!is_peer_could_be_closed) { SSL_shutdown(ssl); }
85728567
#endif
85738568
}
85748569

0 commit comments

Comments
 (0)