connect: use TCP_KEEPALIVE only if TCP_KEEPIDLE is not defined

Closes #8539
This commit is contained in:
MAntoniak 2022-03-02 23:36:38 +01:00 committed by Daniel Stenberg
parent f7d9a76ca7
commit 2cd9837e02
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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
}
}