1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-11 20:15:03 -05:00

keepalive: multiply value for OS-specific units

DragonFly uses milliseconds, while our API and Linux use full seconds.

Reported by: John Marino
Bug: http://curl.haxx.se/bug/view.cgi?id=3546257
This commit is contained in:
Daniel Stenberg 2012-07-22 22:38:38 +02:00
parent d317ca50ae
commit c0f8340c7c

View File

@ -91,6 +91,13 @@
static bool verifyconnect(curl_socket_t sockfd, int *error); static bool verifyconnect(curl_socket_t sockfd, int *error);
#ifdef __DragonFly__
/* DragonFlyBSD uses millisecond as KEEPIDLE and KEEPINTVL units */
#define KEEPALIVE_FACTOR(x) (x *= 1000)
#else
#define KEEPALIVE_FACTOR(x)
#endif
static void static void
tcpkeepalive(struct SessionHandle *data, tcpkeepalive(struct SessionHandle *data,
curl_socket_t sockfd) curl_socket_t sockfd)
@ -105,6 +112,7 @@ tcpkeepalive(struct SessionHandle *data,
else { else {
#ifdef TCP_KEEPIDLE #ifdef TCP_KEEPIDLE
optval = curlx_sltosi(data->set.tcp_keepidle); optval = curlx_sltosi(data->set.tcp_keepidle);
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE, if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
(void *)&optval, sizeof(optval)) < 0) { (void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPIDLE on fd %d\n", sockfd); infof(data, "Failed to set TCP_KEEPIDLE on fd %d\n", sockfd);
@ -112,6 +120,7 @@ tcpkeepalive(struct SessionHandle *data,
#endif #endif
#ifdef TCP_KEEPINTVL #ifdef TCP_KEEPINTVL
optval = curlx_sltosi(data->set.tcp_keepintvl); optval = curlx_sltosi(data->set.tcp_keepintvl);
KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL, if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
(void *)&optval, sizeof(optval)) < 0) { (void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPINTVL on fd %d\n", sockfd); infof(data, "Failed to set TCP_KEEPINTVL on fd %d\n", sockfd);