aboutsummaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2012-07-22 22:38:38 +0200
committerDaniel Stenberg <daniel@haxx.se>2012-07-22 22:42:42 +0200
commitc0f8340c7c5ead51ffc6c6297d465221181de4bd (patch)
treeccecbaca3754f0bc07c47dab4e93cd5846e0211f /lib/connect.c
parentd317ca50ae7d8bb250431f86709e53b94f7f6ddf (diff)
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
Diffstat (limited to 'lib/connect.c')
-rw-r--r--lib/connect.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 42b626f1a..dc6291bda 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -91,6 +91,13 @@
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
tcpkeepalive(struct SessionHandle *data,
curl_socket_t sockfd)
@@ -105,6 +112,7 @@ tcpkeepalive(struct SessionHandle *data,
else {
#ifdef TCP_KEEPIDLE
optval = curlx_sltosi(data->set.tcp_keepidle);
+ KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
(void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPIDLE on fd %d\n", sockfd);
@@ -112,6 +120,7 @@ tcpkeepalive(struct SessionHandle *data,
#endif
#ifdef TCP_KEEPINTVL
optval = curlx_sltosi(data->set.tcp_keepintvl);
+ KEEPALIVE_FACTOR(optval);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
(void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPINTVL on fd %d\n", sockfd);