mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 10:10:06 +00:00
Move netmgr/uv-compat.h to <isc/uv.h>
As we are going to use libuv outside of the netmgr, we need the shims to be readily available for the rest of the codebase. Move the "netmgr/uv-compat.h" to <isc/uv.h> and netmgr/uv-compat.c to uv.c, and as a rule of thumb, the users of libuv should include <isc/uv.h> instead of <uv.h> directly. Additionally, merge netmgr/uverr2result.c into uv.c and rename the single function from isc__nm_uverr2result() to isc_uverr2result().
This commit is contained in:
parent
24c3879675
commit
b43812692d
@ -16,12 +16,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
#include <isc/print.h>
|
#include <isc/print.h>
|
||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include <dns/dlz_dlopen.h>
|
#include <dns/dlz_dlopen.h>
|
||||||
#include <dns/log.h>
|
#include <dns/log.h>
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_DNSTAP
|
#ifdef HAVE_DNSTAP
|
||||||
#include <protobuf-c/protobuf-c.h>
|
#include <protobuf-c/protobuf-c.h>
|
||||||
@ -44,6 +43,7 @@
|
|||||||
#include <isc/task.h>
|
#include <isc/task.h>
|
||||||
#include <isc/timer.h>
|
#include <isc/timer.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include <dns/dispatch.h>
|
#include <dns/dispatch.h>
|
||||||
#include <dns/dyndb.h>
|
#include <dns/dyndb.h>
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
@ -23,6 +22,7 @@
|
|||||||
#include <isc/task.h>
|
#include <isc/task.h>
|
||||||
#include <isc/types.h>
|
#include <isc/types.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include <dns/dyndb.h>
|
#include <dns/dyndb.h>
|
||||||
#include <dns/log.h>
|
#include <dns/log.h>
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#define UNIT_TESTING
|
#define UNIT_TESTING
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
@ -32,6 +31,7 @@
|
|||||||
#include <isc/refcount.h>
|
#include <isc/refcount.h>
|
||||||
#include <isc/task.h>
|
#include <isc/task.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include <dns/dispatch.h>
|
#include <dns/dispatch.h>
|
||||||
#include <dns/name.h>
|
#include <dns/name.h>
|
||||||
@ -68,7 +68,7 @@ const struct in6_addr in6addr_blackhole = { { { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|||||||
static int
|
static int
|
||||||
setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
|
setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
|
||||||
socklen_t addrlen = sizeof(*addr);
|
socklen_t addrlen = sizeof(*addr);
|
||||||
uv_os_sock_t fd;
|
uv_os_sock_t fd = -1;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
|
isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
|
||||||
|
@ -97,7 +97,8 @@ libisc_la_HEADERS = \
|
|||||||
include/isc/types.h \
|
include/isc/types.h \
|
||||||
include/isc/url.h \
|
include/isc/url.h \
|
||||||
include/isc/utf8.h \
|
include/isc/utf8.h \
|
||||||
include/isc/util.h
|
include/isc/util.h \
|
||||||
|
include/isc/uv.h
|
||||||
|
|
||||||
libisc_la_SOURCES = \
|
libisc_la_SOURCES = \
|
||||||
$(libisc_la_HEADERS) \
|
$(libisc_la_HEADERS) \
|
||||||
@ -109,9 +110,6 @@ libisc_la_SOURCES = \
|
|||||||
netmgr/timer.c \
|
netmgr/timer.c \
|
||||||
netmgr/tlsdns.c \
|
netmgr/tlsdns.c \
|
||||||
netmgr/udp.c \
|
netmgr/udp.c \
|
||||||
netmgr/uv-compat.c \
|
|
||||||
netmgr/uv-compat.h \
|
|
||||||
netmgr/uverr2result.c \
|
|
||||||
aes.c \
|
aes.c \
|
||||||
app.c \
|
app.c \
|
||||||
assertions.c \
|
assertions.c \
|
||||||
@ -199,7 +197,8 @@ libisc_la_SOURCES = \
|
|||||||
trampoline.c \
|
trampoline.c \
|
||||||
trampoline_p.h \
|
trampoline_p.h \
|
||||||
url.c \
|
url.c \
|
||||||
utf8.c
|
utf8.c \
|
||||||
|
uv.c
|
||||||
|
|
||||||
libisc_la_CPPFLAGS = \
|
libisc_la_CPPFLAGS = \
|
||||||
$(AM_CPPFLAGS) \
|
$(AM_CPPFLAGS) \
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <uv.h>
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#define isc_barrier_t uv_barrier_t
|
#define isc_barrier_t uv_barrier_t
|
||||||
|
|
||||||
|
@ -12,13 +12,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
|
||||||
|
#include <isc/result.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These functions were introduced in newer libuv, but we still
|
* These functions were introduced in newer libuv, but we still
|
||||||
* want BIND9 compile on older ones so we emulate them.
|
* want BIND9 compile on older ones so we emulate them.
|
||||||
* They're inline to avoid conflicts when running with a newer
|
|
||||||
* library version.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define UV_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
#define UV_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
||||||
@ -44,6 +46,13 @@
|
|||||||
#define UV__ERR(x) (-(x))
|
#define UV__ERR(x) (-(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if UV_VERSION_HEX < UV_VERSION(1, 12, 0)
|
||||||
|
int
|
||||||
|
uv_os_getenv(const char *name, char *buffer, size_t *size);
|
||||||
|
|
||||||
|
#define uv_os_setenv(name, value) setenv(name, value, 0)
|
||||||
|
#endif /* UV_VERSION_HEX < UV_VERSION(1, 12, 0) */
|
||||||
|
|
||||||
#if UV_VERSION_HEX < UV_VERSION(1, 19, 0)
|
#if UV_VERSION_HEX < UV_VERSION(1, 19, 0)
|
||||||
static inline void *
|
static inline void *
|
||||||
uv_handle_get_data(const uv_handle_t *handle) {
|
uv_handle_get_data(const uv_handle_t *handle) {
|
||||||
@ -89,30 +98,33 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
|
|||||||
#define isc_uv_udp_connect uv_udp_connect
|
#define isc_uv_udp_connect uv_udp_connect
|
||||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
|
#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
|
||||||
|
|
||||||
#if UV_VERSION_HEX < UV_VERSION(1, 12, 0)
|
/*
|
||||||
#include <stdlib.h>
|
* These are used with all versions of libuv:
|
||||||
#include <string.h>
|
*/
|
||||||
|
|
||||||
static inline int
|
#define UV_RUNTIME_CHECK(func, ret) \
|
||||||
uv_os_getenv(const char *name, char *buffer, size_t *size) {
|
if (ret != 0) { \
|
||||||
size_t len;
|
isc_error_fatal(__FILE__, __LINE__, "%s failed: %s\n", #func, \
|
||||||
char *buf = getenv(name);
|
uv_strerror(ret)); \
|
||||||
|
|
||||||
if (buf == NULL) {
|
|
||||||
return (UV_ENOENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(buf) + 1;
|
#define isc_uverr2result(x) \
|
||||||
if (len > *size) {
|
isc__uverr2result(x, true, __FILE__, __LINE__, __func__)
|
||||||
*size = len;
|
isc_result_t
|
||||||
return (UV_ENOBUFS);
|
isc__uverr2result(int uverr, bool dolog, const char *file, unsigned int line,
|
||||||
}
|
const char *func);
|
||||||
|
/*%<
|
||||||
|
* Convert a libuv error value into an isc_result_t. The
|
||||||
|
* list of supported error values is not complete; new users
|
||||||
|
* of this function should add any expected errors that are
|
||||||
|
* not already there.
|
||||||
|
*/
|
||||||
|
|
||||||
*size = len;
|
/**
|
||||||
memmove(buffer, buf, len);
|
* Type-casting helpers
|
||||||
|
*/
|
||||||
|
|
||||||
return (0);
|
#define uv_handle_set_data(handle, data) \
|
||||||
}
|
uv_handle_set_data((uv_handle_t *)(handle), (data))
|
||||||
|
#define uv_handle_get_data(handle) uv_handle_get_data((uv_handle_t *)(handle))
|
||||||
#define uv_os_setenv(name, value) setenv(name, value, 0)
|
#define uv_close(handle, close_cb) uv_close((uv_handle_t *)handle, close_cb)
|
||||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 12, 0) */
|
|
@ -14,7 +14,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
@ -37,8 +36,7 @@
|
|||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/tls.h>
|
#include <isc/tls.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
#define ISC_NETMGR_TID_UNKNOWN -1
|
#define ISC_NETMGR_TID_UNKNOWN -1
|
||||||
|
|
||||||
@ -1821,18 +1819,6 @@ isc__nm_http_set_tlsctx(isc_nmsocket_t *sock, isc_tlsctx_t *tlsctx);
|
|||||||
void
|
void
|
||||||
isc__nm_async_settlsctx(isc__networker_t *worker, isc__netievent_t *ev0);
|
isc__nm_async_settlsctx(isc__networker_t *worker, isc__netievent_t *ev0);
|
||||||
|
|
||||||
#define isc__nm_uverr2result(x) \
|
|
||||||
isc___nm_uverr2result(x, true, __FILE__, __LINE__, __func__)
|
|
||||||
isc_result_t
|
|
||||||
isc___nm_uverr2result(int uverr, bool dolog, const char *file,
|
|
||||||
unsigned int line, const char *func);
|
|
||||||
/*%<
|
|
||||||
* Convert a libuv error value into an isc_result_t. The
|
|
||||||
* list of supported error values is not complete; new users
|
|
||||||
* of this function should add any expected errors that are
|
|
||||||
* not already there.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isc__nm_acquire_interlocked(isc_nm_t *mgr);
|
isc__nm_acquire_interlocked(isc_nm_t *mgr);
|
||||||
/*%<
|
/*%<
|
||||||
@ -2149,12 +2135,6 @@ isc__nmsocket_readtimeout_cb(uv_timer_t *timer);
|
|||||||
void
|
void
|
||||||
isc__nmsocket_writetimeout_cb(void *data, isc_result_t eresult);
|
isc__nmsocket_writetimeout_cb(void *data, isc_result_t eresult);
|
||||||
|
|
||||||
#define UV_RUNTIME_CHECK(func, ret) \
|
|
||||||
if (ret != 0) { \
|
|
||||||
isc_error_fatal(__FILE__, __LINE__, "%s failed: %s", #func, \
|
|
||||||
uv_strerror(ret)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bind to the socket, but allow binding to IPv6 tentative addresses reported by
|
* Bind to the socket, but allow binding to IPv6 tentative addresses reported by
|
||||||
* the route socket by setting IP_FREEBIND (or equivalent).
|
* the route socket by setting IP_FREEBIND (or equivalent).
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/backtrace.h>
|
#include <isc/backtrace.h>
|
||||||
@ -39,12 +38,12 @@
|
|||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/tls.h>
|
#include <isc/tls.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
#include "netmgr_p.h"
|
#include "netmgr_p.h"
|
||||||
#include "openssl_shim.h"
|
#include "openssl_shim.h"
|
||||||
#include "trampoline_p.h"
|
#include "trampoline_p.h"
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* How many isc_nmhandles and isc_nm_uvreqs will we be
|
* How many isc_nmhandles and isc_nm_uvreqs will we be
|
||||||
@ -3097,7 +3096,7 @@ isc__nm_after_work_cb(uv_work_t *req, int status) {
|
|||||||
isc_nm_t *netmgr = work->netmgr;
|
isc_nm_t *netmgr = work->netmgr;
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
work->after_cb(work->data, result);
|
work->after_cb(work->data, result);
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <isc/errno.h>
|
#include <isc/errno.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
#define setsockopt_on(socket, level, name) \
|
#define setsockopt_on(socket, level, name) \
|
||||||
setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
|
setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
|
||||||
@ -67,7 +67,7 @@ int
|
|||||||
isc__nm_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,
|
isc__nm_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,
|
||||||
unsigned int flags) {
|
unsigned int flags) {
|
||||||
int r;
|
int r;
|
||||||
uv_os_sock_t fd;
|
uv_os_sock_t fd = -1;
|
||||||
|
|
||||||
r = uv_fileno((const uv_handle_t *)handle, (uv_os_fd_t *)&fd);
|
r = uv_fileno((const uv_handle_t *)handle, (uv_os_fd_t *)&fd);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
@ -119,7 +119,7 @@ int
|
|||||||
isc__nm_tcp_freebind(uv_tcp_t *handle, const struct sockaddr *addr,
|
isc__nm_tcp_freebind(uv_tcp_t *handle, const struct sockaddr *addr,
|
||||||
unsigned int flags) {
|
unsigned int flags) {
|
||||||
int r;
|
int r;
|
||||||
uv_os_sock_t fd;
|
uv_os_sock_t fd = -1;
|
||||||
|
|
||||||
r = uv_fileno((const uv_handle_t *)handle, (uv_os_fd_t *)&fd);
|
r = uv_fileno((const uv_handle_t *)handle, (uv_os_fd_t *)&fd);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/barrier.h>
|
#include <isc/barrier.h>
|
||||||
@ -33,9 +32,9 @@
|
|||||||
#include <isc/stdtime.h>
|
#include <isc/stdtime.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
static atomic_uint_fast32_t last_tcpquota_log = 0;
|
static atomic_uint_fast32_t last_tcpquota_log = 0;
|
||||||
|
|
||||||
@ -175,7 +174,7 @@ tcp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
|
|||||||
atomic_store(&sock->connected, true);
|
atomic_store(&sock->connected, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
sock->result = result;
|
sock->result = result;
|
||||||
SIGNAL(&sock->cond);
|
SIGNAL(&sock->cond);
|
||||||
@ -262,7 +261,7 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) {
|
|||||||
result = ISC_R_TIMEDOUT;
|
result = ISC_R_TIMEDOUT;
|
||||||
goto error;
|
goto error;
|
||||||
} else if (status != 0) {
|
} else if (status != 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +269,7 @@ tcp_connect_cb(uv_connect_t *uvreq, int status) {
|
|||||||
r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
|
r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
|
||||||
&(int){ sizeof(ss) });
|
&(int){ sizeof(ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +585,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||||
ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
|
ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
|
||||||
"uv_listen failed: %s",
|
"uv_listen failed: %s",
|
||||||
isc_result_totext(isc__nm_uverr2result(r)));
|
isc_result_totext(isc_uverr2result(r)));
|
||||||
isc__nm_incstats(sock, STATID_BINDFAIL);
|
isc__nm_incstats(sock, STATID_BINDFAIL);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -594,7 +593,7 @@ isc__nm_async_tcplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
atomic_store(&sock->listening, true);
|
atomic_store(&sock->listening, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
sock->pquota = NULL;
|
sock->pquota = NULL;
|
||||||
}
|
}
|
||||||
@ -616,7 +615,7 @@ tcp_connection_cb(uv_stream_t *server, int status) {
|
|||||||
isc_quota_t *quota = NULL;
|
isc_quota_t *quota = NULL;
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,7 +852,7 @@ isc__nm_tcp_read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
|
|||||||
isc__nm_incstats(sock, STATID_RECVFAIL);
|
isc__nm_incstats(sock, STATID_RECVFAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc__nm_tcp_failed_read_cb(sock, isc__nm_uverr2result(nread));
|
isc__nm_tcp_failed_read_cb(sock, isc_uverr2result(nread));
|
||||||
|
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
@ -970,14 +969,14 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
|
|
||||||
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
|
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = uv_tcp_getpeername(&csock->uv_handle.tcp, (struct sockaddr *)&ss,
|
r = uv_tcp_getpeername(&csock->uv_handle.tcp, (struct sockaddr *)&ss,
|
||||||
&(int){ sizeof(ss) });
|
&(int){ sizeof(ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -990,7 +989,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
r = uv_tcp_getsockname(&csock->uv_handle.tcp, (struct sockaddr *)&ss,
|
r = uv_tcp_getsockname(&csock->uv_handle.tcp, (struct sockaddr *)&ss,
|
||||||
&(int){ sizeof(ss) });
|
&(int){ sizeof(ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1090,8 +1089,7 @@ tcp_send_cb(uv_write_t *req, int status) {
|
|||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
isc__nm_incstats(sock, STATID_SENDFAIL);
|
isc__nm_incstats(sock, STATID_SENDFAIL);
|
||||||
isc__nm_failed_send_cb(sock, uvreq,
|
isc__nm_failed_send_cb(sock, uvreq, isc_uverr2result(status));
|
||||||
isc__nm_uverr2result(status));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1135,7 +1133,7 @@ tcp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
|
|||||||
r = uv_write(&req->uv_req.write, &sock->uv_handle.stream, &req->uvbuf,
|
r = uv_write(&req->uv_req.write, &sock->uv_handle.stream, &req->uvbuf,
|
||||||
1, tcp_send_cb);
|
1, tcp_send_cb);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
return (isc__nm_uverr2result(r));
|
return (isc_uverr2result(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_nm_timer_create(req->handle, isc__nmsocket_writetimeout_cb, req,
|
isc_nm_timer_create(req->handle, isc__nmsocket_writetimeout_cb, req,
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/barrier.h>
|
#include <isc/barrier.h>
|
||||||
@ -33,9 +32,9 @@
|
|||||||
#include <isc/stdtime.h>
|
#include <isc/stdtime.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
static atomic_uint_fast32_t last_tcpdnsquota_log = 0;
|
static atomic_uint_fast32_t last_tcpdnsquota_log = 0;
|
||||||
|
|
||||||
@ -145,7 +144,7 @@ tcpdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
|
|||||||
atomic_store(&sock->connected, true);
|
atomic_store(&sock->connected, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
error:
|
error:
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
sock->result = result;
|
sock->result = result;
|
||||||
@ -225,7 +224,7 @@ tcpdns_connect_cb(uv_connect_t *uvreq, int status) {
|
|||||||
result = ISC_R_TIMEDOUT;
|
result = ISC_R_TIMEDOUT;
|
||||||
goto error;
|
goto error;
|
||||||
} else if (status != 0) {
|
} else if (status != 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +232,7 @@ tcpdns_connect_cb(uv_connect_t *uvreq, int status) {
|
|||||||
r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
|
r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
|
||||||
&(int){ sizeof(ss) });
|
&(int){ sizeof(ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +324,7 @@ isc_nm_tcpdnsconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
|
|||||||
static uv_os_sock_t
|
static uv_os_sock_t
|
||||||
isc__nm_tcpdns_lb_socket(isc_nm_t *mgr, sa_family_t sa_family) {
|
isc__nm_tcpdns_lb_socket(isc_nm_t *mgr, sa_family_t sa_family) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
uv_os_sock_t sock;
|
uv_os_sock_t sock = -1;
|
||||||
|
|
||||||
result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &sock);
|
result = isc__nm_socket(sa_family, SOCK_STREAM, 0, &sock);
|
||||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||||
@ -552,7 +551,7 @@ isc__nm_async_tcpdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||||
ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
|
ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
|
||||||
"uv_listen failed: %s",
|
"uv_listen failed: %s",
|
||||||
isc_result_totext(isc__nm_uverr2result(r)));
|
isc_result_totext(isc_uverr2result(r)));
|
||||||
isc__nm_incstats(sock, STATID_BINDFAIL);
|
isc__nm_incstats(sock, STATID_BINDFAIL);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -560,7 +559,7 @@ isc__nm_async_tcpdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
atomic_store(&sock->listening, true);
|
atomic_store(&sock->listening, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
sock->pquota = NULL;
|
sock->pquota = NULL;
|
||||||
}
|
}
|
||||||
@ -582,7 +581,7 @@ tcpdns_connection_cb(uv_stream_t *server, int status) {
|
|||||||
isc_quota_t *quota = NULL;
|
isc_quota_t *quota = NULL;
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,7 +852,7 @@ isc__nm_tcpdns_read_cb(uv_stream_t *stream, ssize_t nread,
|
|||||||
isc__nm_incstats(sock, STATID_RECVFAIL);
|
isc__nm_incstats(sock, STATID_RECVFAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nread), true);
|
isc__nm_failed_read_cb(sock, isc_uverr2result(nread), true);
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,7 +971,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
|
|
||||||
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
|
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,7 +979,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
(struct sockaddr *)&peer_ss,
|
(struct sockaddr *)&peer_ss,
|
||||||
&(int){ sizeof(peer_ss) });
|
&(int){ sizeof(peer_ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -994,7 +993,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
(struct sockaddr *)&local_ss,
|
(struct sockaddr *)&local_ss,
|
||||||
&(int){ sizeof(local_ss) });
|
&(int){ sizeof(local_ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1115,8 +1114,7 @@ tcpdns_send_cb(uv_write_t *req, int status) {
|
|||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
isc__nm_incstats(sock, STATID_SENDFAIL);
|
isc__nm_incstats(sock, STATID_SENDFAIL);
|
||||||
isc__nm_failed_send_cb(sock, uvreq,
|
isc__nm_failed_send_cb(sock, uvreq, isc_uverr2result(status));
|
||||||
isc__nm_uverr2result(status));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1175,14 +1173,14 @@ isc__nm_async_tcpdnssend(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
/* uv_try_write not supported, send asynchronously */
|
/* uv_try_write not supported, send asynchronously */
|
||||||
} else {
|
} else {
|
||||||
/* error sending data */
|
/* error sending data */
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = uv_write(&uvreq->uv_req.write, &sock->uv_handle.stream, bufs, nbufs,
|
r = uv_write(&uvreq->uv_req.write, &sock->uv_handle.stream, bufs, nbufs,
|
||||||
tcpdns_send_cb);
|
tcpdns_send_cb);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,10 +11,9 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/netmgr.h>
|
#include <isc/netmgr.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/barrier.h>
|
#include <isc/barrier.h>
|
||||||
@ -33,10 +32,10 @@
|
|||||||
#include <isc/stdtime.h>
|
#include <isc/stdtime.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
#include "openssl_shim.h"
|
#include "openssl_shim.h"
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
static atomic_uint_fast32_t last_tlsdnsquota_log = 0;
|
static atomic_uint_fast32_t last_tlsdnsquota_log = 0;
|
||||||
|
|
||||||
@ -175,7 +174,7 @@ tlsdns_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
|
|||||||
atomic_store(&sock->connected, true);
|
atomic_store(&sock->connected, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
error:
|
error:
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
sock->result = result;
|
sock->result = result;
|
||||||
@ -254,7 +253,7 @@ tlsdns_connect_cb(uv_connect_t *uvreq, int status) {
|
|||||||
result = ISC_R_TIMEDOUT;
|
result = ISC_R_TIMEDOUT;
|
||||||
goto error;
|
goto error;
|
||||||
} else if (status != 0) {
|
} else if (status != 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +261,7 @@ tlsdns_connect_cb(uv_connect_t *uvreq, int status) {
|
|||||||
r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
|
r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
|
||||||
&(int){ sizeof(ss) });
|
&(int){ sizeof(ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,7 +639,7 @@ isc__nm_async_tlsdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
|
||||||
ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
|
ISC_LOGMODULE_NETMGR, ISC_LOG_ERROR,
|
||||||
"uv_listen failed: %s",
|
"uv_listen failed: %s",
|
||||||
isc_result_totext(isc__nm_uverr2result(r)));
|
isc_result_totext(isc_uverr2result(r)));
|
||||||
isc__nm_incstats(sock, STATID_BINDFAIL);
|
isc__nm_incstats(sock, STATID_BINDFAIL);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -648,7 +647,7 @@ isc__nm_async_tlsdnslisten(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
atomic_store(&sock->listening, true);
|
atomic_store(&sock->listening, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
sock->pquota = NULL;
|
sock->pquota = NULL;
|
||||||
}
|
}
|
||||||
@ -670,7 +669,7 @@ tlsdns_connection_cb(uv_stream_t *server, int status) {
|
|||||||
isc_quota_t *quota = NULL;
|
isc_quota_t *quota = NULL;
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1195,7 +1194,7 @@ free_senddata(isc_nmsocket_t *sock, const isc_result_t result) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
tls_write_cb(uv_write_t *req, int status) {
|
tls_write_cb(uv_write_t *req, int status) {
|
||||||
isc_result_t result = status != 0 ? isc__nm_uverr2result(status)
|
isc_result_t result = status != 0 ? isc_uverr2result(status)
|
||||||
: ISC_R_SUCCESS;
|
: ISC_R_SUCCESS;
|
||||||
isc__nm_uvreq_t *uvreq = (isc__nm_uvreq_t *)req->data;
|
isc__nm_uvreq_t *uvreq = (isc__nm_uvreq_t *)req->data;
|
||||||
isc_nmsocket_t *sock = uvreq->sock;
|
isc_nmsocket_t *sock = uvreq->sock;
|
||||||
@ -1271,7 +1270,7 @@ tls_cycle_output(isc_nmsocket_t *sock) {
|
|||||||
/* uv_try_write is not supported, send
|
/* uv_try_write is not supported, send
|
||||||
* asynchronously */
|
* asynchronously */
|
||||||
} else {
|
} else {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
isc__nm_uvreq_put(&req, sock);
|
isc__nm_uvreq_put(&req, sock);
|
||||||
free_senddata(sock, result);
|
free_senddata(sock, result);
|
||||||
break;
|
break;
|
||||||
@ -1280,7 +1279,7 @@ tls_cycle_output(isc_nmsocket_t *sock) {
|
|||||||
r = uv_write(&req->uv_req.write, &sock->uv_handle.stream,
|
r = uv_write(&req->uv_req.write, &sock->uv_handle.stream,
|
||||||
&req->uvbuf, 1, tls_write_cb);
|
&req->uvbuf, 1, tls_write_cb);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
isc__nm_uvreq_put(&req, sock);
|
isc__nm_uvreq_put(&req, sock);
|
||||||
free_senddata(sock, result);
|
free_senddata(sock, result);
|
||||||
break;
|
break;
|
||||||
@ -1408,7 +1407,7 @@ isc__nm_tlsdns_read_cb(uv_stream_t *stream, ssize_t nread,
|
|||||||
isc__nm_incstats(sock, STATID_RECVFAIL);
|
isc__nm_incstats(sock, STATID_RECVFAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nread), true);
|
isc__nm_failed_read_cb(sock, isc_uverr2result(nread), true);
|
||||||
|
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
@ -1528,7 +1527,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
|
|
||||||
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
|
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1536,7 +1535,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
(struct sockaddr *)&peer_ss,
|
(struct sockaddr *)&peer_ss,
|
||||||
&(int){ sizeof(peer_ss) });
|
&(int){ sizeof(peer_ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1550,7 +1549,7 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
|
|||||||
(struct sockaddr *)&local_ss,
|
(struct sockaddr *)&local_ss,
|
||||||
&(int){ sizeof(local_ss) });
|
&(int){ sizeof(local_ss) });
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
@ -36,10 +35,10 @@
|
|||||||
#include <isc/stdtime.h>
|
#include <isc/stdtime.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "../openssl_shim.h"
|
#include "../openssl_shim.h"
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
#define TLS_BUF_SIZE (UINT16_MAX)
|
#define TLS_BUF_SIZE (UINT16_MAX)
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/barrier.h>
|
#include <isc/barrier.h>
|
||||||
@ -29,9 +28,9 @@
|
|||||||
#include <isc/sockaddr.h>
|
#include <isc/sockaddr.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#include "netmgr-int.h"
|
||||||
#include "uv-compat.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_NET_ROUTE_H
|
#ifdef HAVE_NET_ROUTE_H
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
@ -87,7 +86,7 @@ stop_udp_child(isc_nmsocket_t *sock);
|
|||||||
static uv_os_sock_t
|
static uv_os_sock_t
|
||||||
isc__nm_udp_lb_socket(isc_nm_t *mgr, sa_family_t sa_family) {
|
isc__nm_udp_lb_socket(isc_nm_t *mgr, sa_family_t sa_family) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
uv_os_sock_t sock;
|
uv_os_sock_t sock = -1;
|
||||||
|
|
||||||
result = isc__nm_socket(sa_family, SOCK_DGRAM, 0, &sock);
|
result = isc__nm_socket(sa_family, SOCK_DGRAM, 0, &sock);
|
||||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||||
@ -223,7 +222,7 @@ isc_nm_listenudp(isc_nm_t *mgr, uint32_t workers, isc_sockaddr_t *iface,
|
|||||||
static isc_result_t
|
static isc_result_t
|
||||||
route_socket(uv_os_sock_t *fdp) {
|
route_socket(uv_os_sock_t *fdp) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
uv_os_sock_t fd;
|
uv_os_sock_t fd = -1;
|
||||||
#ifdef USE_NETLINK
|
#ifdef USE_NETLINK
|
||||||
struct sockaddr_nl sa;
|
struct sockaddr_nl sa;
|
||||||
int r;
|
int r;
|
||||||
@ -286,7 +285,7 @@ route_connect_direct(isc_nmsocket_t *sock) {
|
|||||||
atomic_store(&sock->connected, true);
|
atomic_store(&sock->connected, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
error:
|
error:
|
||||||
|
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
@ -502,7 +501,7 @@ isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0) {
|
|||||||
atomic_store(&sock->listening, true);
|
atomic_store(&sock->listening, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
atomic_fetch_add(&sock->parent->rchildren, 1);
|
atomic_fetch_add(&sock->parent->rchildren, 1);
|
||||||
if (sock->parent->result == ISC_R_UNSET) {
|
if (sock->parent->result == ISC_R_UNSET) {
|
||||||
sock->parent->result = result;
|
sock->parent->result = result;
|
||||||
@ -603,8 +602,7 @@ udp_recv_cb(uv_udp_t *handle, ssize_t nrecv, const uv_buf_t *buf,
|
|||||||
* - If there was a networking error.
|
* - If there was a networking error.
|
||||||
*/
|
*/
|
||||||
if (nrecv < 0) {
|
if (nrecv < 0) {
|
||||||
isc__nm_failed_read_cb(sock, isc__nm_uverr2result(nrecv),
|
isc__nm_failed_read_cb(sock, isc_uverr2result(nrecv), false);
|
||||||
false);
|
|
||||||
goto free;
|
goto free;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -796,7 +794,7 @@ udp_send_cb(uv_udp_send_t *req, int status) {
|
|||||||
REQUIRE(sock->tid == isc_nm_tid());
|
REQUIRE(sock->tid == isc_nm_tid());
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
result = isc__nm_uverr2result(status);
|
result = isc_uverr2result(status);
|
||||||
isc__nm_incstats(sock, STATID_SENDFAIL);
|
isc__nm_incstats(sock, STATID_SENDFAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -837,7 +835,7 @@ udp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req,
|
|||||||
r = uv_udp_send(&req->uv_req.udp_send, &sock->uv_handle.udp,
|
r = uv_udp_send(&req->uv_req.udp_send, &sock->uv_handle.udp,
|
||||||
&req->uvbuf, 1, sa, udp_send_cb);
|
&req->uvbuf, 1, sa, udp_send_cb);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
return (isc__nm_uverr2result(r));
|
return (isc_uverr2result(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
@ -914,7 +912,7 @@ udp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
|
|||||||
atomic_store(&sock->connected, true);
|
atomic_store(&sock->connected, true);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
result = isc__nm_uverr2result(r);
|
result = isc_uverr2result(r);
|
||||||
error:
|
error:
|
||||||
|
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: MPL-2.0
|
|
||||||
*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*
|
|
||||||
* See the COPYRIGHT file distributed with this work for additional
|
|
||||||
* information regarding copyright ownership.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "uv-compat.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <isc/util.h>
|
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
|
||||||
|
|
||||||
#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
|
|
||||||
int
|
|
||||||
isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
do {
|
|
||||||
int addrlen = (addr->sa_family == AF_INET)
|
|
||||||
? sizeof(struct sockaddr_in)
|
|
||||||
: sizeof(struct sockaddr_in6);
|
|
||||||
err = connect(handle->io_watcher.fd, addr, addrlen);
|
|
||||||
} while (err == -1 && errno == EINTR);
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
|
|
||||||
return (uv_translate_sys_error(errno));
|
|
||||||
#else
|
|
||||||
return (-errno);
|
|
||||||
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
|
|
||||||
|
|
||||||
#if UV_VERSION_HEX < UV_VERSION(1, 32, 0)
|
|
||||||
int
|
|
||||||
uv_tcp_close_reset(uv_tcp_t *handle, uv_close_cb close_cb) {
|
|
||||||
if (setsockopt(handle->io_watcher.fd, SOL_SOCKET, SO_LINGER,
|
|
||||||
&(struct linger){ 1, 0 }, sizeof(struct linger)) == -1)
|
|
||||||
{
|
|
||||||
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
|
|
||||||
return (uv_translate_sys_error(errno));
|
|
||||||
#else
|
|
||||||
return (-errno);
|
|
||||||
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
|
|
||||||
}
|
|
||||||
|
|
||||||
uv_close((uv_handle_t *)handle, close_cb);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 32, 0) */
|
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/app.h>
|
#include <isc/app.h>
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
@ -39,6 +38,7 @@
|
|||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/time.h>
|
#include <isc/time.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIBXML2
|
#ifdef HAVE_LIBXML2
|
||||||
#include <libxml/xmlwriter.h>
|
#include <libxml/xmlwriter.h>
|
||||||
@ -49,7 +49,6 @@
|
|||||||
#include <json_object.h>
|
#include <json_object.h>
|
||||||
#endif /* HAVE_JSON_C */
|
#endif /* HAVE_JSON_C */
|
||||||
|
|
||||||
#include "netmgr/uv-compat.h"
|
|
||||||
#include "task_p.h"
|
#include "task_p.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
include $(top_srcdir)/Makefile.top
|
include $(top_srcdir)/Makefile.top
|
||||||
|
|
||||||
AM_CPPFLAGS += \
|
AM_CPPFLAGS += \
|
||||||
$(LIBISC_CFLAGS)
|
$(LIBISC_CFLAGS) \
|
||||||
|
-I..
|
||||||
|
|
||||||
LDADD += \
|
LDADD += \
|
||||||
libisctest.la \
|
libisctest.la \
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#define UNIT_TESTING
|
#define UNIT_TESTING
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
@ -37,6 +36,7 @@
|
|||||||
#include <isc/refcount.h>
|
#include <isc/refcount.h>
|
||||||
#include <isc/sockaddr.h>
|
#include <isc/sockaddr.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "uv_wrap.h"
|
#include "uv_wrap.h"
|
||||||
#define KEEP_BEFORE
|
#define KEEP_BEFORE
|
||||||
@ -44,8 +44,6 @@
|
|||||||
#include "../netmgr/http.c"
|
#include "../netmgr/http.c"
|
||||||
#include "../netmgr/netmgr-int.h"
|
#include "../netmgr/netmgr-int.h"
|
||||||
#include "../netmgr/socket.c"
|
#include "../netmgr/socket.c"
|
||||||
#include "../netmgr/uv-compat.c"
|
|
||||||
#include "../netmgr/uv-compat.h"
|
|
||||||
#include "../netmgr_p.h"
|
#include "../netmgr_p.h"
|
||||||
#include "isctest.h"
|
#include "isctest.h"
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#define UNIT_TESTING
|
#define UNIT_TESTING
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
@ -30,6 +29,7 @@
|
|||||||
#include <isc/sockaddr.h>
|
#include <isc/sockaddr.h>
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "uv_wrap.h"
|
#include "uv_wrap.h"
|
||||||
#define KEEP_BEFORE
|
#define KEEP_BEFORE
|
||||||
@ -37,8 +37,6 @@
|
|||||||
#include "../netmgr/netmgr-int.h"
|
#include "../netmgr/netmgr-int.h"
|
||||||
#include "../netmgr/socket.c"
|
#include "../netmgr/socket.c"
|
||||||
#include "../netmgr/udp.c"
|
#include "../netmgr/udp.c"
|
||||||
#include "../netmgr/uv-compat.c"
|
|
||||||
#include "../netmgr/uv-compat.h"
|
|
||||||
#include "../netmgr_p.h"
|
#include "../netmgr_p.h"
|
||||||
#include "isctest.h"
|
#include "isctest.h"
|
||||||
|
|
||||||
@ -244,7 +242,7 @@ _teardown(void **state __attribute__((unused))) {
|
|||||||
static int
|
static int
|
||||||
setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
|
setup_ephemeral_port(isc_sockaddr_t *addr, sa_family_t family) {
|
||||||
socklen_t addrlen = sizeof(*addr);
|
socklen_t addrlen = sizeof(*addr);
|
||||||
uv_os_sock_t fd;
|
uv_os_sock_t fd = -1;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
|
isc_sockaddr_fromin6(addr, &in6addr_loopback, 0);
|
||||||
|
@ -23,14 +23,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
|
|
||||||
#define UNIT_TESTING
|
#define UNIT_TESTING
|
||||||
#include <cmocka.h>
|
#include <cmocka.h>
|
||||||
|
|
||||||
#include "../netmgr/uv-compat.h"
|
#include <isc/uv.h>
|
||||||
|
|
||||||
/* uv_udp_t */
|
/* uv_udp_t */
|
||||||
|
|
||||||
|
@ -11,15 +11,62 @@
|
|||||||
* information regarding copyright ownership.
|
* information regarding copyright ownership.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <unistd.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/result.h>
|
|
||||||
#include <isc/strerr.h>
|
|
||||||
#include <isc/string.h>
|
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include "netmgr-int.h"
|
#if UV_VERSION_HEX < UV_VERSION(1, 12, 0)
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
|
||||||
|
int
|
||||||
|
isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
int addrlen = (addr->sa_family == AF_INET)
|
||||||
|
? sizeof(struct sockaddr_in)
|
||||||
|
: sizeof(struct sockaddr_in6);
|
||||||
|
err = connect(handle->io_watcher.fd, addr, addrlen);
|
||||||
|
} while (err == -1 && errno == EINTR);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
|
||||||
|
return (uv_translate_sys_error(errno));
|
||||||
|
#else
|
||||||
|
return (-errno);
|
||||||
|
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
|
||||||
|
|
||||||
|
#if UV_VERSION_HEX < UV_VERSION(1, 32, 0)
|
||||||
|
int
|
||||||
|
uv_tcp_close_reset(uv_tcp_t *handle, uv_close_cb close_cb) {
|
||||||
|
if (setsockopt(handle->io_watcher.fd, SOL_SOCKET, SO_LINGER,
|
||||||
|
&(struct linger){ 1, 0 }, sizeof(struct linger)) == -1)
|
||||||
|
{
|
||||||
|
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
|
||||||
|
return (uv_translate_sys_error(errno));
|
||||||
|
#else
|
||||||
|
return (-errno);
|
||||||
|
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
|
||||||
|
}
|
||||||
|
|
||||||
|
INSIST(!uv_is_closing((uv_handle_t *)handle));
|
||||||
|
uv_close((uv_handle_t *)handle, close_cb);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
#endif /* UV_VERSION_HEX < UV_VERSION(1, 32, 0) */
|
||||||
|
|
||||||
|
#define setsockopt_on(socket, level, name) \
|
||||||
|
setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Convert a libuv error value into an isc_result_t. The
|
* Convert a libuv error value into an isc_result_t. The
|
||||||
@ -28,8 +75,8 @@
|
|||||||
* not already there.
|
* not already there.
|
||||||
*/
|
*/
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc___nm_uverr2result(int uverr, bool dolog, const char *file,
|
isc__uverr2result(int uverr, bool dolog, const char *file, unsigned int line,
|
||||||
unsigned int line, const char *func) {
|
const char *func) {
|
||||||
switch (uverr) {
|
switch (uverr) {
|
||||||
case 0:
|
case 0:
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
@ -16,7 +16,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <uv.h>
|
|
||||||
|
|
||||||
#include <isc/errno.h>
|
#include <isc/errno.h>
|
||||||
#include <isc/list.h>
|
#include <isc/list.h>
|
||||||
@ -27,6 +26,7 @@
|
|||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
#include <isc/types.h>
|
#include <isc/types.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
#include <isc/uv.h>
|
||||||
|
|
||||||
#include <dns/view.h>
|
#include <dns/view.h>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user