From: Andy Pan Date: Sat, 1 Jun 2024 10:36:04 +0000 (+0800) Subject: socket: change TCP keepalive from ms to seconds on DragonFly BSD X-Git-Tag: curl-8_9_0~333 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6da320357f14251ee8f82d3fd6632148bcecaadf;p=thirdparty%2Fcurl.git socket: change TCP keepalive from ms to seconds on DragonFly BSD DragonFly BSD changed the time unit for TCP keep-alive from milliseconds to seconds since v5.8, thus setting the keepalive options with milliseconds with curl/libcurl will result in unexpected behaviors on DragonFlyBSD 5.8+ Distinguish the DragonFly BSD versions and use the proper time units accordingly. Ref: https://lists.dragonflybsd.org/pipermail/commits/2019-July/719125.html https://github.com/DragonFlyBSD/DragonFlyBSD/blob/965b380e960908836b97aa034fa2753091e0172e/sys/sys/param.h#L207 Fixes #13847 Closes #13848 --- diff --git a/lib/cf-socket.c b/lib/cf-socket.c index a6a609f7b5..09fa60ad2a 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -53,6 +53,11 @@ #include #endif +#ifdef __DragonFly__ +/* Required for __DragonFly_version */ +#include +#endif + #include "urldata.h" #include "bufq.h" #include "sendf.h" @@ -137,8 +142,9 @@ static void nosigpipe(struct Curl_easy *data, #define nosigpipe(x,y) Curl_nop_stmt #endif -#if defined(__DragonFly__) || defined(USE_WINSOCK) -/* DragonFlyBSD and Windows use millisecond units */ +#if defined(USE_WINSOCK) || \ + (defined(__DragonFly__) && __DragonFly_version < 500702) +/* DragonFlyBSD < 500702 and Windows use millisecond units */ #define KEEPALIVE_FACTOR(x) (x *= 1000) #else #define KEEPALIVE_FACTOR(x)