mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Merge branch 'ondrej/fix-uv_udp_connect-detection' into 'main'
Cleanup the remaining of HAVE_UV_<func> macros See merge request isc-projects/bind9!5127
This commit is contained in:
12
configure.ac
12
configure.ac
@@ -593,18 +593,6 @@ AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
|
|||||||
AC_MSG_CHECKING([for libuv])
|
AC_MSG_CHECKING([for libuv])
|
||||||
PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0], [],
|
PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0], [],
|
||||||
[AC_MSG_ERROR([libuv not found])])
|
[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
|
# libnghttp2
|
||||||
AC_MSG_CHECKING([for libnghttp2])
|
AC_MSG_CHECKING([for libnghttp2])
|
||||||
|
@@ -578,7 +578,7 @@ udp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
|
|||||||
return (ISC_R_CANCELED);
|
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
|
* If we used uv_udp_connect() (and not the shim version for
|
||||||
* older versions of libuv), then the peer address has to be
|
* older versions of libuv), then the peer address has to be
|
||||||
|
@@ -36,11 +36,11 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
return (uv_translate_sys_error(err));
|
return (uv_translate_sys_error(err));
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
#ifdef HAVE_UV_TRANSLATE_SYS_ERROR
|
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
|
||||||
return (uv_translate_sys_error(errno));
|
return (uv_translate_sys_error(errno));
|
||||||
#else
|
#else
|
||||||
return (-errno);
|
return (-errno);
|
||||||
#endif /* HAVE_UV_TRANSLATE_SYS_ERROR */
|
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -694,7 +694,7 @@ mock_udpconnect_uv_udp_bind(void **state __attribute__((unused))) {
|
|||||||
RESET_RETURN;
|
RESET_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_UV_UDP_CONNECT
|
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
|
||||||
static void
|
static void
|
||||||
mock_udpconnect_uv_udp_connect(void **state __attribute__((unused))) {
|
mock_udpconnect_uv_udp_connect(void **state __attribute__((unused))) {
|
||||||
WILL_RETURN(uv_udp_connect, UV_ENOMEM);
|
WILL_RETURN(uv_udp_connect, UV_ENOMEM);
|
||||||
@@ -2730,7 +2730,7 @@ main(void) {
|
|||||||
nm_setup, nm_teardown),
|
nm_setup, nm_teardown),
|
||||||
cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_bind,
|
cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_bind,
|
||||||
nm_setup, nm_teardown),
|
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,
|
cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_connect,
|
||||||
nm_setup, nm_teardown),
|
nm_setup, nm_teardown),
|
||||||
#endif
|
#endif
|
||||||
|
@@ -26,6 +26,8 @@
|
|||||||
#define UNIT_TESTING
|
#define UNIT_TESTING
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
|
|
||||||
|
#include "../netmgr/uv-compat.h"
|
||||||
|
|
||||||
/* uv_udp_t */
|
/* uv_udp_t */
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -33,13 +35,13 @@ __wrap_uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock);
|
|||||||
int
|
int
|
||||||
__wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
|
__wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
#if HAVE_UV_UDP_CONNECT
|
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
|
||||||
int
|
int
|
||||||
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
|
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
|
||||||
int
|
int
|
||||||
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
|
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
|
||||||
int *namelen);
|
int *namelen);
|
||||||
#endif /* HAVE_UV_UDP_CONNECT */
|
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
|
||||||
int
|
int
|
||||||
__wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name,
|
__wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name,
|
||||||
int *namelen);
|
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
|
static atomic_int __state_uv_udp_connect
|
||||||
__attribute__((unused)) = ATOMIC_VAR_INIT(0);
|
__attribute__((unused)) = ATOMIC_VAR_INIT(0);
|
||||||
|
|
||||||
#if HAVE_UV_UDP_CONNECT
|
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
|
||||||
int
|
int
|
||||||
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
|
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
|
||||||
if (atomic_load(&__state_uv_udp_connect) == 0) {
|
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));
|
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
|
static atomic_int __state_uv_udp_getpeername
|
||||||
__attribute__((unused)) = ATOMIC_VAR_INIT(0);
|
__attribute__((unused)) = ATOMIC_VAR_INIT(0);
|
||||||
|
|
||||||
#if HAVE_UV_UDP_CONNECT
|
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
|
||||||
int
|
int
|
||||||
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
|
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
|
||||||
int *namelen) {
|
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));
|
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);
|
static atomic_int __state_uv_udp_getsockname = ATOMIC_VAR_INIT(0);
|
||||||
int
|
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_open(...) __wrap_uv_udp_open(__VA_ARGS__)
|
||||||
#define uv_udp_bind(...) __wrap_uv_udp_bind(__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_connect(...) __wrap_uv_udp_connect(__VA_ARGS__)
|
||||||
#define uv_udp_getpeername(...) __wrap_uv_udp_getpeername(__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_getsockname(...) __wrap_uv_udp_getsockname(__VA_ARGS__)
|
||||||
#define uv_udp_send(...) __wrap_uv_udp_send(__VA_ARGS__)
|
#define uv_udp_send(...) __wrap_uv_udp_send(__VA_ARGS__)
|
||||||
#define uv_udp_recv_start(...) __wrap_uv_udp_recv_start(__VA_ARGS__)
|
#define uv_udp_recv_start(...) __wrap_uv_udp_recv_start(__VA_ARGS__)
|
||||||
|
Reference in New Issue
Block a user