mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-05 00:55:24 +00:00
Distribute queries among threads even on platforms without lb sockets
On platforms without load-balancing socket all the queries would be handle by a single thread. Currently, the support for load-balanced sockets is present in Linux with SO_REUSEPORT and FreeBSD 12 with SO_REUSEPORT_LB. This commit adds workaround for such platforms that: 1. setups single shared listening socket for all listening nmthreads for UDP, TCP and TCPDNS netmgr transports 2. Calls uv_udp_bind/uv_tcp_bind on the underlying socket just once and for rest of the nmthreads only copy the internal libuv flags (should be just UV_HANDLE_BOUND and optionally UV_HANDLE_IPV6). 3. start reading on UDP socket or listening on TCP socket The load distribution among the nmthreads is uneven, but it's still better than utilizing just one thread for processing all the incoming queries
This commit is contained in:
@@ -169,22 +169,6 @@ isc__nm_in_netthread(void) {
|
||||
return (isc__nm_tid_v >= 0);
|
||||
}
|
||||
|
||||
static bool
|
||||
isc__nm_test_lb_socket(sa_family_t sa_family, int protocol) {
|
||||
isc_result_t result;
|
||||
uv_os_sock_t fd = -1;
|
||||
|
||||
result = isc__nm_socket(sa_family, protocol, 0, &fd);
|
||||
REQUIRE(result == ISC_R_SUCCESS);
|
||||
|
||||
result = isc__nm_socket_reuse_lb(fd);
|
||||
REQUIRE(result == ISC_R_SUCCESS || result == ISC_R_NOTIMPLEMENTED);
|
||||
|
||||
isc__nm_closesocket(fd);
|
||||
|
||||
return (result == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
static void
|
||||
isc__nm_winsock_initialize(void) {
|
||||
@@ -231,14 +215,6 @@ isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
|
||||
|
||||
isc__nm_tls_initialize();
|
||||
|
||||
if (!isc__nm_test_lb_socket(AF_INET, SOCK_DGRAM) ||
|
||||
!isc__nm_test_lb_socket(AF_INET, SOCK_STREAM) ||
|
||||
!isc__nm_test_lb_socket(AF_INET6, SOCK_DGRAM) ||
|
||||
!isc__nm_test_lb_socket(AF_INET6, SOCK_STREAM))
|
||||
{
|
||||
workers = 1;
|
||||
}
|
||||
|
||||
mgr = isc_mem_get(mctx, sizeof(*mgr));
|
||||
*mgr = (isc_nm_t){ .nworkers = workers };
|
||||
|
||||
|
Reference in New Issue
Block a user