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
  965b380e96/sys/sys/param.h (L207)

Fixes #13847
Closes #13848
This commit is contained in:
Andy Pan 2024-06-01 18:36:04 +08:00 committed by Daniel Stenberg
parent 47d930efae
commit 6da320357f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -53,6 +53,11 @@
#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)