]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Cleanup the remaining of HAVE_UV_<func> macros
authorOndřej Surý <ondrej@sury.org>
Wed, 2 Jun 2021 09:23:36 +0000 (11:23 +0200)
committerOndřej Surý <ondrej@sury.org>
Wed, 2 Jun 2021 09:23:36 +0000 (11:23 +0200)
While cleaning up the usage of HAVE_UV_<func> macros, we forgot to
cleanup the HAVE_UV_UDP_CONNECT in the actual code and
HAVE_UV_TRANSLATE_SYS_ERROR and this was causing Windows build to fail
on uv_udp_send() because the socket was already connected and we were
falsely assuming that it was not.

The platforms with autoconf support were not affected, because we were
still checking for the functions from the configure.

configure.ac
lib/isc/netmgr/udp.c
lib/isc/netmgr/uv-compat.c
lib/isc/tests/netmgr_test.c
lib/isc/tests/uv_wrap.h

index 9b947ff4d8622f5725d906399e3085ba7488520e..b0cd88496fa29559293d7d5d385ab49e6eeceb6a 100644 (file)
@@ -593,18 +593,6 @@ AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
 AC_MSG_CHECKING([for libuv])
 PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0], [],
                  [AC_MSG_ERROR([libuv not found])])
-AX_SAVE_FLAGS([libuv])
-
-CFLAGS="$CFLAGS $LIBUV_CFLAGS"
-LIBS="$LIBS $LIBUV_LIBS"
-
-# Those functions are only provided in newer versions of libuv, we'll be emulating them
-# for now
-AC_CHECK_FUNCS([uv_handle_get_data uv_handle_set_data])
-AC_CHECK_FUNCS([uv_req_get_data uv_req_set_data])
-AC_CHECK_FUNCS([uv_udp_connect uv_translate_sys_error uv_sleep])
-AC_CHECK_FUNCS([uv_os_getenv uv_os_setenv])
-AX_RESTORE_FLAGS([libuv])
 
 # libnghttp2
 AC_MSG_CHECKING([for libnghttp2])
index 95521f9a2f076462fc4f1b915df1389744c2eaa2..2259ebd74b190b8b8e358a86fe13ad19e388975a 100644 (file)
@@ -578,7 +578,7 @@ udp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
                return (ISC_R_CANCELED);
        }
 
-#ifdef HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
        /*
         * If we used uv_udp_connect() (and not the shim version for
         * older versions of libuv), then the peer address has to be
index 89d7ac025cd6474ac3569addd993312fb2af45fd..00a6a6390b927f86795a5e17cffd3487945d7ba4 100644 (file)
@@ -36,11 +36,11 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
 #ifdef WIN32
                return (uv_translate_sys_error(err));
 #else /* WIN32 */
-#ifdef HAVE_UV_TRANSLATE_SYS_ERROR
+#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
                return (uv_translate_sys_error(errno));
 #else
                return (-errno);
-#endif /* HAVE_UV_TRANSLATE_SYS_ERROR */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
 #endif /* WIN32 */
        }
 
index 0a28c8c5da733a6ddf8364e79dd0f19c7bd0c5b2..507c3a8a6e5f634c64b432288cbe61c740f7cc2b 100644 (file)
@@ -694,7 +694,7 @@ mock_udpconnect_uv_udp_bind(void **state __attribute__((unused))) {
        RESET_RETURN;
 }
 
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
 static void
 mock_udpconnect_uv_udp_connect(void **state __attribute__((unused))) {
        WILL_RETURN(uv_udp_connect, UV_ENOMEM);
@@ -2730,7 +2730,7 @@ main(void) {
                                                nm_setup, nm_teardown),
                cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_bind,
                                                nm_setup, nm_teardown),
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
                cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_connect,
                                                nm_setup, nm_teardown),
 #endif
index 46d41d2d454c8e2a8c7ebe1de929cb6f85ffba8b..99cedeec9c328776011076e11e891e61282298ff 100644 (file)
@@ -26,6 +26,8 @@
 #define UNIT_TESTING
 #include <cmocka.h>
 
+#include "../netmgr/uv-compat.h"
+
 /* uv_udp_t */
 
 int
@@ -33,13 +35,13 @@ __wrap_uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock);
 int
 __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
                   unsigned int flags);
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
 int
 __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
 int
 __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
                          int *namelen);
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
 int
 __wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name,
                          int *namelen);
@@ -114,7 +116,7 @@ __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
 static atomic_int __state_uv_udp_connect
        __attribute__((unused)) = ATOMIC_VAR_INIT(0);
 
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
 int
 __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
        if (atomic_load(&__state_uv_udp_connect) == 0) {
@@ -122,12 +124,12 @@ __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
        }
        return (atomic_load(&__state_uv_udp_connect));
 }
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
 
 static atomic_int __state_uv_udp_getpeername
        __attribute__((unused)) = ATOMIC_VAR_INIT(0);
 
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
 int
 __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
                          int *namelen) {
@@ -136,7 +138,7 @@ __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
        }
        return (atomic_load(&__state_uv_udp_getpeername));
 }
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
 
 static atomic_int __state_uv_udp_getsockname = ATOMIC_VAR_INIT(0);
 int
@@ -274,10 +276,10 @@ __wrap_uv_fileno(const uv_handle_t *handle, uv_os_fd_t *fd) {
 
 #define uv_udp_open(...) __wrap_uv_udp_open(__VA_ARGS__)
 #define uv_udp_bind(...) __wrap_uv_udp_bind(__VA_ARGS__)
-#if HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
 #define uv_udp_connect(...)    __wrap_uv_udp_connect(__VA_ARGS__)
 #define uv_udp_getpeername(...) __wrap_uv_udp_getpeername(__VA_ARGS__)
-#endif /* HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
 #define uv_udp_getsockname(...) __wrap_uv_udp_getsockname(__VA_ARGS__)
 #define uv_udp_send(...)       __wrap_uv_udp_send(__VA_ARGS__)
 #define uv_udp_recv_start(...) __wrap_uv_udp_recv_start(__VA_ARGS__)