]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
socket: change TCP keepalive from ms to seconds on DragonFly BSD
authorAndy Pan <i@andypan.me>
Sat, 1 Jun 2024 10:36:04 +0000 (18:36 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 1 Jun 2024 21:46:41 +0000 (23:46 +0200)
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

lib/cf-socket.c

index a6a609f7b5dcde5a97d810e416b87fcaf74ac59c..09fa60ad2aee07fe9b9e90a48eb4cd07b7794d2e 100644 (file)
 #include <inet.h>
 #endif
 
+#ifdef __DragonFly__
+/* Required for __DragonFly_version */
+#include <sys/param.h>
+#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)