]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
connect: use TCP_KEEPALIVE only if TCP_KEEPIDLE is not defined
authorMAntoniak <47522782+MAntoniak@users.noreply.github.com>
Wed, 2 Mar 2022 22:36:38 +0000 (23:36 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 5 Mar 2022 22:57:08 +0000 (23:57 +0100)
Closes #8539

lib/connect.c

index 64f951118b0a19a50da1073222b714a4c8643a8a..c2241b48a6db1d212480b5e48a81cdac400efc55 100644 (file)
@@ -137,6 +137,14 @@ tcpkeepalive(struct Curl_easy *data,
           (void *)&optval, sizeof(optval)) < 0) {
       infof(data, "Failed to set TCP_KEEPIDLE on fd %d", sockfd);
     }
+#elif defined(TCP_KEEPALIVE)
+    /* Mac OS X style */
+    optval = curlx_sltosi(data->set.tcp_keepidle);
+    KEEPALIVE_FACTOR(optval);
+    if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE,
+      (void *)&optval, sizeof(optval)) < 0) {
+      infof(data, "Failed to set TCP_KEEPALIVE on fd %d", sockfd);
+    }
 #endif
 #ifdef TCP_KEEPINTVL
     optval = curlx_sltosi(data->set.tcp_keepintvl);
@@ -146,15 +154,6 @@ tcpkeepalive(struct Curl_easy *data,
       infof(data, "Failed to set TCP_KEEPINTVL on fd %d", sockfd);
     }
 #endif
-#ifdef TCP_KEEPALIVE
-    /* Mac OS X style */
-    optval = curlx_sltosi(data->set.tcp_keepidle);
-    KEEPALIVE_FACTOR(optval);
-    if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPALIVE,
-          (void *)&optval, sizeof(optval)) < 0) {
-      infof(data, "Failed to set TCP_KEEPALIVE on fd %d", sockfd);
-    }
-#endif
 #endif
   }
 }