From 4adeaab73d1a182ec4fed2299ec51edf76cbe2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 2 Dec 2020 21:54:25 +0100 Subject: [PATCH] Add FreeBSD connection timeout socket option On FreeBSD, the option to configure connection timeout is called TCP_KEEPINIT, use it to configure the connection timeout there. This also fixes the dangling socket problems in the unit test, so re-enable them. --- lib/isc/netmgr/netmgr.c | 4 ++++ lib/isc/tests/tcp_quota_test.c | 2 +- lib/isc/tests/tcp_test.c | 2 +- lib/isc/tests/tcpdns_test.c | 2 +- lib/isc/tests/udp_test.c | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 9ed966a6ed..4e654e11d8 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -2283,6 +2283,10 @@ isc__nm_socket_dontfrag(uv_os_sock_t fd, sa_family_t sa_family) { #define TIMEOUT_TYPE unsigned int #define TIMEOUT_DIV 1 #define TIMEOUT_OPTNAME TCP_USER_TIMEOUT +#elif defined(TCP_KEEPINIT) +#define TIMEOUT_TYPE int +#define TIMEOUT_DIV 1000 +#define TIMEOUT_OPTNAME TCP_KEEPINIT #endif isc_result_t diff --git a/lib/isc/tests/tcp_quota_test.c b/lib/isc/tests/tcp_quota_test.c index 0602dea28a..849213b677 100644 --- a/lib/isc/tests/tcp_quota_test.c +++ b/lib/isc/tests/tcp_quota_test.c @@ -9,7 +9,7 @@ * information regarding copyright ownership. */ -#if HAVE_CMOCKA && defined(__linux__) +#if HAVE_CMOCKA #include /* IWYU pragma: keep */ #include #include diff --git a/lib/isc/tests/tcp_test.c b/lib/isc/tests/tcp_test.c index 4c4fea0532..a27ab80ebb 100644 --- a/lib/isc/tests/tcp_test.c +++ b/lib/isc/tests/tcp_test.c @@ -9,7 +9,7 @@ * information regarding copyright ownership. */ -#if HAVE_CMOCKA && defined(__linux__) +#if HAVE_CMOCKA #include /* IWYU pragma: keep */ #include #include diff --git a/lib/isc/tests/tcpdns_test.c b/lib/isc/tests/tcpdns_test.c index c21a7cb73c..2145964592 100644 --- a/lib/isc/tests/tcpdns_test.c +++ b/lib/isc/tests/tcpdns_test.c @@ -9,7 +9,7 @@ * information regarding copyright ownership. */ -#if HAVE_CMOCKA && defined(__linux__) +#if HAVE_CMOCKA #include /* IWYU pragma: keep */ #include #include diff --git a/lib/isc/tests/udp_test.c b/lib/isc/tests/udp_test.c index b3062cc465..a1a99314e2 100644 --- a/lib/isc/tests/udp_test.c +++ b/lib/isc/tests/udp_test.c @@ -9,7 +9,7 @@ * information regarding copyright ownership. */ -#if HAVE_CMOCKA && defined(__linux__) +#if HAVE_CMOCKA #include /* IWYU pragma: keep */ #include #include