]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cf-socket: prevent KEEPALIVE_FACTOR being set to 1000 for Windows
authorSam Jessup <samjessup@users.noreply.github.com>
Mon, 19 Aug 2024 15:37:59 +0000 (17:37 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 20 Aug 2024 07:24:12 +0000 (09:24 +0200)
Fixes #14368
Reported-by: feelingseas on github
Closes #14606

lib/cf-socket.c

index 7f64a2dba7422bd805e3ac11640cf098ca820208..3f0fb32bf809d1a0ccadedcfee4ae70996aacb84 100644 (file)
@@ -146,7 +146,13 @@ static void nosigpipe(struct Curl_easy *data,
 #define nosigpipe(x,y) Curl_nop_stmt
 #endif
 
-#if defined(USE_WINSOCK) || \
+#if defined(USE_WINSOCK) && \
+    defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) && defined(TCP_KEEPCNT)
+/*  Win 10, v 1709 (10.0.16299) and later can use SetSockOpt TCP_KEEP____
+ *  so should use seconds */
+#define CURL_WINSOCK_KEEP_SSO
+#define KEEPALIVE_FACTOR(x)
+#elif defined(USE_WINSOCK) || \
    (defined(__sun) && !defined(TCP_KEEPIDLE)) || \
    (defined(__DragonFly__) && __DragonFly_version < 500702) || \
    (defined(_WIN32) && !defined(TCP_KEEPIDLE))
@@ -183,7 +189,7 @@ tcpkeepalive(struct Curl_easy *data,
   else {
 #if defined(SIO_KEEPALIVE_VALS) /* Windows */
 /* Windows 10, version 1709 (10.0.16299) and later versions */
-#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) && defined(TCP_KEEPCNT)
+#if defined(CURL_WINSOCK_KEEP_SSO)
     optval = curlx_sltosi(data->set.tcp_keepidle);
     KEEPALIVE_FACTOR(optval);
     if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,