From 7a4ffa4511c9518ff4bea2fc274ce97869f6ba8b Mon Sep 17 00:00:00 2001 From: zhengshuxin Date: Tue, 2 Apr 2024 09:44:54 +0800 Subject: [PATCH] Add conditional compiling for set_sock_timeo in openssl_io.cpp --- lib_acl_cpp/src/stream/openssl_io.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib_acl_cpp/src/stream/openssl_io.cpp b/lib_acl_cpp/src/stream/openssl_io.cpp index 5bfd73849..2b0d083af 100644 --- a/lib_acl_cpp/src/stream/openssl_io.cpp +++ b/lib_acl_cpp/src/stream/openssl_io.cpp @@ -182,20 +182,22 @@ void openssl_io::destroy(void) } } +#ifdef HAS_OPENSSL + static bool set_sock_timeo(ACL_SOCKET fd, int opt, int timeout) { if (timeout <= 0) { return true; } -#if defined(__APPLE__) || defined(_WIN32) || defined(_WIN64) +# if defined(__APPLE__) || defined(_WIN32) || defined(_WIN64) timeout *= 1000; // From seconds to millisecond. if (setsockopt(fd, SOL_SOCKET, opt, &timeout, sizeof(timeout)) < 0) { logger_error("setsockopt error=%s, timeout=%d, opt=%d, fd=%d", last_serror(), timeout, opt, (int) fd); return false; } -#else // Must be Linux. +# else // Must be Linux. struct timeval tm; tm.tv_sec = timeout; tm.tv_usec = 0; @@ -205,10 +207,12 @@ static bool set_sock_timeo(ACL_SOCKET fd, int opt, int timeout) last_serror(), timeout, opt, (int) fd); return false; } -#endif +# endif return true; } +#endif + bool openssl_io::open(ACL_VSTREAM* s) { if (s == NULL) {