Merge branch '2433-improve-memory-contention' into 'main'
Reduce the contention of the memory allocator Closes #2433 See merge request isc-projects/bind9!5012
This commit is contained in:
+5
-5
@@ -864,7 +864,7 @@ gcc:asan:
|
||||
CC: gcc
|
||||
CFLAGS: "${CFLAGS_COMMON} -fsanitize=address,undefined"
|
||||
LDFLAGS: "-fsanitize=address,undefined"
|
||||
EXTRA_CONFIGURE: "--with-libidn2"
|
||||
EXTRA_CONFIGURE: "--with-libidn2 --without-jemalloc"
|
||||
<<: *base_image
|
||||
<<: *build_job
|
||||
|
||||
@@ -891,7 +891,7 @@ clang:asan:
|
||||
CC: ${CLANG}
|
||||
CFLAGS: "${CFLAGS_COMMON} -fsanitize=address,undefined"
|
||||
LDFLAGS: "-fsanitize=address,undefined"
|
||||
EXTRA_CONFIGURE: "--with-libidn2"
|
||||
EXTRA_CONFIGURE: "--with-libidn2 --without-jemalloc"
|
||||
<<: *base_image
|
||||
<<: *build_job
|
||||
|
||||
@@ -922,7 +922,7 @@ gcc:tsan:
|
||||
CC: gcc
|
||||
CFLAGS: "${CFLAGS_COMMON} -fsanitize=thread"
|
||||
LDFLAGS: "-fsanitize=thread"
|
||||
EXTRA_CONFIGURE: "--with-libidn2 --enable-pthread-rwlock"
|
||||
EXTRA_CONFIGURE: "--with-libidn2 --enable-pthread-rwlock --without-jemalloc"
|
||||
|
||||
system:gcc:tsan:
|
||||
variables:
|
||||
@@ -949,7 +949,7 @@ clang:tsan:
|
||||
CC: "${CLANG}"
|
||||
CFLAGS: "${CFLAGS_COMMON} -fsanitize=thread"
|
||||
LDFLAGS: "-fsanitize=thread"
|
||||
EXTRA_CONFIGURE: "--with-libidn2 --enable-pthread-rwlock"
|
||||
EXTRA_CONFIGURE: "--with-libidn2 --enable-pthread-rwlock --without-jemalloc"
|
||||
|
||||
system:clang:tsan:
|
||||
variables:
|
||||
@@ -998,7 +998,7 @@ gcc:softhsm2.4:
|
||||
variables:
|
||||
CC: gcc
|
||||
CFLAGS: "${CFLAGS_COMMON}"
|
||||
EXTRA_CONFIGURE: "--enable-native-pkcs11 --with-pkcs11=/usr/lib/softhsm/libsofthsm2.so"
|
||||
EXTRA_CONFIGURE: "--without-jemalloc --enable-native-pkcs11 --with-pkcs11=/usr/lib/softhsm/libsofthsm2.so"
|
||||
<<: *base_image
|
||||
<<: *build_job
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
5676. [func] Memory allocation has been substantially refactored,
|
||||
and is now based on the memory allocation API
|
||||
provided by 'libjemalloc'. This is now a build
|
||||
dependency for BIND. [GL #2433]
|
||||
|
||||
5675. [bug] Improve BIND's compatibility with DoH clients by
|
||||
ignoring an "Accept" HTTP header value. [GL !5246]
|
||||
|
||||
|
||||
+14
-5
@@ -12,8 +12,13 @@
|
||||
|
||||
In general, this version of BIND will build and run on any POSIX-compliant
|
||||
system with a C11-compliant C compiler, BSD-style sockets with RFC-compliant
|
||||
IPv6 support, POSIX-compliant threads, the `libuv` asynchronous I/O library,
|
||||
the OpenSSL cryptography library, and the `nghttp2` HTTP/2 library.
|
||||
IPv6 support, and POSIX-compliant threads, plus the following mandatory
|
||||
libraries:
|
||||
|
||||
- `libuv` for asynchronous I/O operations and event loops
|
||||
- `libssl` and `libcrpyto` from OpenSSL for cryptography
|
||||
- `libjemalloc` for memory allocation
|
||||
- `libnghttp2` for HTTP/2
|
||||
|
||||
The following C11 features are used in BIND 9:
|
||||
|
||||
@@ -31,13 +36,17 @@ some of the older systems listed below, you will have to install an updated
|
||||
updated packages. The other option is to build and install `libuv` from
|
||||
source.
|
||||
|
||||
Certain optional BIND features have additional library dependencies:
|
||||
Certain optional BIND features have additional library dependencies.
|
||||
These include:
|
||||
|
||||
* `libfstrm` and `libprotobuf-c` for DNSTAP
|
||||
* `libidn2` for internationalized domain name conversion.
|
||||
* `libidn2` for display of internationalized domain names in `dig`
|
||||
* `libjson-c` for JSON statistics
|
||||
* `libmaxminddb` for geolocation
|
||||
* `libnghttp2` for DNS over HTTPS
|
||||
* `libxml2` and `libjson-c` for statistics channel
|
||||
* `libxml2` for XML statistics
|
||||
* `libz` for compression of the HTTP statistics channel
|
||||
* `readline` for line editing in `nsupdate` and `nslookup`
|
||||
|
||||
ISC regularly tests BIND on many operating systems and architectures, but
|
||||
lacks the resources to test all of them. Consequently, ISC is only able to
|
||||
|
||||
@@ -125,13 +125,13 @@ including your patch as an attachment, preferably generated by
|
||||
|
||||
At a minimum, BIND requires a Unix or Linux system with an ANSI C compiler,
|
||||
basic POSIX support, and a 64-bit integer type. BIND also requires the
|
||||
`libuv` asynchronous I/O library, the `nghttp2` HTTP/2 library, and a
|
||||
cryptography provider library such as OpenSSL or a hardware service
|
||||
module supporting PKCS#11. On Linux, BIND requires the `libcap` library
|
||||
to set process privileges, though this requirement can be overridden by
|
||||
disabling capability support at compile time. See [Compile-time
|
||||
options](#opts) below for details on other libraries that may be
|
||||
required to support optional features.
|
||||
`libuv` asynchronous I/O library, the `nghttp2` HTTP/2 library, the
|
||||
`jemalloc` memory allocation library, and the OpenSSL cryptography
|
||||
library. On Linux, BIND requires the `libcap` library to set process
|
||||
privileges, though this requirement can be overridden by disabling
|
||||
capability support at compile time. See [Compile-time options](#opts)
|
||||
below for details on other libraries that may be required to support
|
||||
optional features.
|
||||
|
||||
Successful builds have been observed on many versions of Linux and
|
||||
Unix, including RHEL/CentOS, Fedora, Debian, Ubuntu, SLES, openSUSE,
|
||||
|
||||
@@ -611,12 +611,6 @@ main(int argc, char **argv) {
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "size") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGSIZE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "mctx") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGCTX;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
+6
-23
@@ -153,7 +153,6 @@ unsigned int digestbits = 0;
|
||||
isc_buffer_t *namebuf = NULL;
|
||||
dns_tsigkey_t *tsigkey = NULL;
|
||||
bool validated = true;
|
||||
isc_mempool_t *commctx = NULL;
|
||||
bool debugging = false;
|
||||
bool debugtiming = false;
|
||||
bool memdebugging = false;
|
||||
@@ -1367,15 +1366,6 @@ setup_libs(void) {
|
||||
check_result(result, "dst_lib_init");
|
||||
is_dst_up = true;
|
||||
|
||||
isc_mempool_create(mctx, COMMSIZE, &commctx);
|
||||
isc_mempool_setname(commctx, "COMMPOOL");
|
||||
/*
|
||||
* 6 and 2 set as reasonable parameters for 3 or 4 nameserver
|
||||
* systems.
|
||||
*/
|
||||
isc_mempool_setfreemax(commctx, 6);
|
||||
isc_mempool_setfillcount(commctx, 2);
|
||||
|
||||
isc_mutex_init(&lookup_lock);
|
||||
}
|
||||
|
||||
@@ -1559,7 +1549,7 @@ _destroy_lookup(dig_lookup_t *lookup) {
|
||||
isc_buffer_free(&lookup->querysig);
|
||||
}
|
||||
if (lookup->sendspace != NULL) {
|
||||
isc_mempool_put(commctx, lookup->sendspace);
|
||||
isc_mem_put(mctx, lookup->sendspace, COMMSIZE);
|
||||
}
|
||||
|
||||
if (lookup->tsigctx != NULL) {
|
||||
@@ -1645,8 +1635,8 @@ destroy_query(dig_query_t *query, const char *file, unsigned int line) {
|
||||
|
||||
INSIST(query->recvspace != NULL);
|
||||
|
||||
isc_mempool_put(commctx, query->recvspace);
|
||||
isc_mempool_put(commctx, query->tmpsendspace);
|
||||
isc_mem_put(mctx, query->recvspace, COMMSIZE);
|
||||
isc_mem_put(mctx, query->tmpsendspace, COMMSIZE);
|
||||
|
||||
query->magic = 0;
|
||||
isc_mem_free(mctx, query);
|
||||
@@ -2087,8 +2077,8 @@ _new_query(dig_lookup_t *lookup, char *servname, char *userarg,
|
||||
.userarg = userarg,
|
||||
.first_pass = true,
|
||||
.warn_id = true,
|
||||
.recvspace = isc_mempool_get(commctx),
|
||||
.tmpsendspace = isc_mempool_get(commctx) };
|
||||
.recvspace = isc_mem_get(mctx, COMMSIZE),
|
||||
.tmpsendspace = isc_mem_get(mctx, COMMSIZE) };
|
||||
|
||||
lookup_attach(lookup, &query->lookup);
|
||||
|
||||
@@ -2381,10 +2371,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
||||
check_result(result, "dns_message_settsigkey");
|
||||
}
|
||||
|
||||
lookup->sendspace = isc_mempool_get(commctx);
|
||||
if (lookup->sendspace == NULL) {
|
||||
fatal("memory allocation failure");
|
||||
}
|
||||
lookup->sendspace = isc_mem_get(mctx, COMMSIZE);
|
||||
|
||||
result = dns_compress_init(&cctx, -1, mctx);
|
||||
check_result(result, "dns_compress_init");
|
||||
@@ -4250,10 +4237,6 @@ destroy_libs(void) {
|
||||
|
||||
clear_searchlist();
|
||||
|
||||
if (commctx != NULL) {
|
||||
debug("freeing commctx");
|
||||
isc_mempool_destroy(&commctx);
|
||||
}
|
||||
if (tsigkey != NULL) {
|
||||
debug("freeing key %p", tsigkey);
|
||||
dns_tsigkey_detach(&tsigkey);
|
||||
|
||||
@@ -909,12 +909,6 @@ main(int argc, char **argv) {
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "size") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGSIZE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "mctx") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGCTX;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -3335,12 +3335,6 @@ main(int argc, char *argv[]) {
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "size") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGSIZE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "mctx") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGCTX;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -209,12 +209,6 @@ main(int argc, char *argv[]) {
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "size") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGSIZE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "mctx") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGCTX;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -430,8 +430,6 @@ static struct flag_def {
|
||||
{ "trace", ISC_MEM_DEBUGTRACE, false },
|
||||
{ "record", ISC_MEM_DEBUGRECORD, false },
|
||||
{ "usage", ISC_MEM_DEBUGUSAGE, false },
|
||||
{ "size", ISC_MEM_DEBUGSIZE, false },
|
||||
{ "mctx", ISC_MEM_DEBUGCTX, false },
|
||||
{ NULL, 0, false } },
|
||||
mem_context_flags[] = { { "fill", ISC_MEMFLAG_FILL, false },
|
||||
{ "nofill", ISC_MEMFLAG_FILL, true },
|
||||
|
||||
+6
-18
@@ -1260,7 +1260,7 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af,
|
||||
isc_result_t result = ISC_R_FAILURE;
|
||||
dns_dispatch_t *disp;
|
||||
isc_sockaddr_t sa;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
const cfg_obj_t *obj = NULL;
|
||||
unsigned int maxdispatchbuffers = UDPBUFFERS;
|
||||
isc_dscp_t dscp = -1;
|
||||
@@ -1331,17 +1331,10 @@ get_view_querysource_dispatch(const cfg_obj_t **maps, int af,
|
||||
}
|
||||
}
|
||||
|
||||
attrmask = 0;
|
||||
attrmask |= DNS_DISPATCHATTR_UDP;
|
||||
attrmask |= DNS_DISPATCHATTR_TCP;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV4;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV6;
|
||||
|
||||
disp = NULL;
|
||||
result = dns_dispatch_getudp(named_g_dispatchmgr, named_g_socketmgr,
|
||||
named_g_taskmgr, &sa, 4096,
|
||||
maxdispatchbuffers, 32768, 16411, 16433,
|
||||
attrs, attrmask, &disp);
|
||||
result = dns_dispatch_getudp(
|
||||
named_g_dispatchmgr, named_g_socketmgr, named_g_taskmgr, &sa,
|
||||
4096, maxdispatchbuffers, 32768, 16411, 16433, attrs, &disp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_sockaddr_t any;
|
||||
char buf[ISC_SOCKADDR_FORMATSIZE];
|
||||
@@ -10514,7 +10507,7 @@ named_add_reserved_dispatch(named_server_t *server,
|
||||
in_port_t port;
|
||||
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
|
||||
isc_result_t result;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
|
||||
REQUIRE(NAMED_SERVER_VALID(server));
|
||||
|
||||
@@ -10554,16 +10547,11 @@ named_add_reserved_dispatch(named_server_t *server,
|
||||
result = ISC_R_NOTIMPLEMENTED;
|
||||
goto cleanup;
|
||||
}
|
||||
attrmask = 0;
|
||||
attrmask |= DNS_DISPATCHATTR_UDP;
|
||||
attrmask |= DNS_DISPATCHATTR_TCP;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV4;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV6;
|
||||
|
||||
result = dns_dispatch_getudp(named_g_dispatchmgr, named_g_socketmgr,
|
||||
named_g_taskmgr, &dispatch->addr, 4096,
|
||||
UDPBUFFERS, 32768, 16411, 16433, attrs,
|
||||
attrmask, &dispatch->dispatch);
|
||||
&dispatch->dispatch);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -804,7 +804,7 @@ static void
|
||||
setup_system(void) {
|
||||
isc_result_t result;
|
||||
isc_sockaddr_t bind_any, bind_any6;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
isc_sockaddrlist_t *nslist;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
irs_resconf_t *resconf = NULL;
|
||||
@@ -939,9 +939,6 @@ setup_system(void) {
|
||||
|
||||
set_source_ports(dispatchmgr);
|
||||
|
||||
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
|
||||
|
||||
if (have_ipv6) {
|
||||
attrs = DNS_DISPATCHATTR_UDP;
|
||||
attrs |= DNS_DISPATCHATTR_MAKEQUERY;
|
||||
@@ -949,7 +946,7 @@ setup_system(void) {
|
||||
isc_sockaddr_any6(&bind_any6);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
&bind_any6, PACKETSIZE, 4, 2, 3, 5,
|
||||
attrs, attrmask, &dispatchv6);
|
||||
attrs, &dispatchv6);
|
||||
check_result(result, "dns_dispatch_getudp (v6)");
|
||||
}
|
||||
|
||||
@@ -960,7 +957,7 @@ setup_system(void) {
|
||||
isc_sockaddr_any(&bind_any);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
&bind_any, PACKETSIZE, 4, 2, 3, 5,
|
||||
attrs, attrmask, &dispatchv4);
|
||||
attrs, &dispatchv4);
|
||||
check_result(result, "dns_dispatch_getudp (v4)");
|
||||
}
|
||||
|
||||
|
||||
+2
-31
@@ -77,12 +77,6 @@ typedef struct filter_instance {
|
||||
ns_plugin_t *module;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
/*
|
||||
* Memory pool for use with persistent data.
|
||||
*/
|
||||
isc_mempool_t *datapool;
|
||||
isc_mutex_t plock;
|
||||
|
||||
/*
|
||||
* Hash table associating a client object with its persistent data.
|
||||
*/
|
||||
@@ -353,25 +347,9 @@ plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
cfg_line, mctx, lctx, actx));
|
||||
}
|
||||
|
||||
isc_mempool_create(mctx, sizeof(filter_data_t), &inst->datapool);
|
||||
CHECK(isc_ht_init(&inst->ht, mctx, 16));
|
||||
isc_mutex_init(&inst->hlock);
|
||||
|
||||
/*
|
||||
* Fill the mempool with 1K filter_a state objects at
|
||||
* a time; ideally after a single allocation, the mempool will
|
||||
* have enough to handle all the simultaneous queries the system
|
||||
* requires and it won't be necessary to allocate more.
|
||||
*
|
||||
* We don't set any limit on the number of free state objects
|
||||
* so that they'll always be returned to the pool and not
|
||||
* freed until the pool is destroyed on shutdown.
|
||||
*/
|
||||
isc_mempool_setfillcount(inst->datapool, 1024);
|
||||
isc_mempool_setfreemax(inst->datapool, UINT_MAX);
|
||||
isc_mutex_init(&inst->plock);
|
||||
isc_mempool_associatelock(inst->datapool, &inst->plock);
|
||||
|
||||
/*
|
||||
* Set hook points in the view's hooktable.
|
||||
*/
|
||||
@@ -427,10 +405,6 @@ plugin_destroy(void **instp) {
|
||||
isc_ht_destroy(&inst->ht);
|
||||
isc_mutex_destroy(&inst->hlock);
|
||||
}
|
||||
if (inst->datapool != NULL) {
|
||||
isc_mempool_destroy(&inst->datapool);
|
||||
isc_mutex_destroy(&inst->plock);
|
||||
}
|
||||
if (inst->a_acl != NULL) {
|
||||
dns_acl_detach(&inst->a_acl);
|
||||
}
|
||||
@@ -512,10 +486,7 @@ client_state_create(const query_ctx_t *qctx, filter_instance_t *inst) {
|
||||
filter_data_t *client_state;
|
||||
isc_result_t result;
|
||||
|
||||
client_state = isc_mempool_get(inst->datapool);
|
||||
if (client_state == NULL) {
|
||||
return;
|
||||
}
|
||||
client_state = isc_mem_get(inst->mctx, sizeof(*client_state));
|
||||
|
||||
client_state->mode = NONE;
|
||||
client_state->flags = 0;
|
||||
@@ -542,7 +513,7 @@ client_state_destroy(const query_ctx_t *qctx, filter_instance_t *inst) {
|
||||
UNLOCK(&inst->hlock);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
|
||||
isc_mempool_put(inst->datapool, client_state);
|
||||
isc_mem_put(inst->mctx, client_state, sizeof(*client_state));
|
||||
}
|
||||
|
||||
/*%
|
||||
|
||||
@@ -77,12 +77,6 @@ typedef struct filter_instance {
|
||||
ns_plugin_t *module;
|
||||
isc_mem_t *mctx;
|
||||
|
||||
/*
|
||||
* Memory pool for use with persistent data.
|
||||
*/
|
||||
isc_mempool_t *datapool;
|
||||
isc_mutex_t plock;
|
||||
|
||||
/*
|
||||
* Hash table associating a client object with its persistent data.
|
||||
*/
|
||||
@@ -356,25 +350,9 @@ plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
cfg_line, mctx, lctx, actx));
|
||||
}
|
||||
|
||||
isc_mempool_create(mctx, sizeof(filter_data_t), &inst->datapool);
|
||||
CHECK(isc_ht_init(&inst->ht, mctx, 16));
|
||||
isc_mutex_init(&inst->hlock);
|
||||
|
||||
/*
|
||||
* Fill the mempool with 1K filter_aaaa state objects at
|
||||
* a time; ideally after a single allocation, the mempool will
|
||||
* have enough to handle all the simultaneous queries the system
|
||||
* requires and it won't be necessary to allocate more.
|
||||
*
|
||||
* We don't set any limit on the number of free state objects
|
||||
* so that they'll always be returned to the pool and not
|
||||
* freed until the pool is destroyed on shutdown.
|
||||
*/
|
||||
isc_mempool_setfillcount(inst->datapool, 1024);
|
||||
isc_mempool_setfreemax(inst->datapool, UINT_MAX);
|
||||
isc_mutex_init(&inst->plock);
|
||||
isc_mempool_associatelock(inst->datapool, &inst->plock);
|
||||
|
||||
/*
|
||||
* Set hook points in the view's hooktable.
|
||||
*/
|
||||
@@ -430,10 +408,6 @@ plugin_destroy(void **instp) {
|
||||
isc_ht_destroy(&inst->ht);
|
||||
isc_mutex_destroy(&inst->hlock);
|
||||
}
|
||||
if (inst->datapool != NULL) {
|
||||
isc_mempool_destroy(&inst->datapool);
|
||||
isc_mutex_destroy(&inst->plock);
|
||||
}
|
||||
if (inst->aaaa_acl != NULL) {
|
||||
dns_acl_detach(&inst->aaaa_acl);
|
||||
}
|
||||
@@ -515,10 +489,7 @@ client_state_create(const query_ctx_t *qctx, filter_instance_t *inst) {
|
||||
filter_data_t *client_state;
|
||||
isc_result_t result;
|
||||
|
||||
client_state = isc_mempool_get(inst->datapool);
|
||||
if (client_state == NULL) {
|
||||
return;
|
||||
}
|
||||
client_state = isc_mem_get(inst->mctx, sizeof(*client_state));
|
||||
|
||||
client_state->mode = NONE;
|
||||
client_state->flags = 0;
|
||||
@@ -545,7 +516,7 @@ client_state_destroy(const query_ctx_t *qctx, filter_instance_t *inst) {
|
||||
UNLOCK(&inst->hlock);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
|
||||
isc_mempool_put(inst->datapool, client_state);
|
||||
isc_mem_put(inst->mctx, client_state, sizeof(*client_state));
|
||||
}
|
||||
|
||||
/*%
|
||||
|
||||
@@ -546,7 +546,7 @@ By default, start.pl starts a "named" server with the following options:
|
||||
-g Runs the server in the foreground and logs everything to
|
||||
stderr.
|
||||
|
||||
-m record,size,mctx
|
||||
-m record
|
||||
Turns on these memory usage debugging flags.
|
||||
|
||||
-U 4 Uses four listeners.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# this server runs named with only one worker thread
|
||||
-m record,size,mctx -c named.conf -d 99 -D additional-ns1 -X named.lock -g -n 1 -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 99 -D additional-ns1 -X named.lock -g -n 1 -T maxcachesize=2097152
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# this server only has 127.0.0.1 in its localhost/localnets ACLs
|
||||
-m record,size,mctx -c named.conf -d 99 -D allow-query-ns3 -X named.lock -g -T maxcachesize=2097152 -T fixedlocal
|
||||
-m record -c named.conf -d 99 -D allow-query-ns3 -X named.lock -g -T maxcachesize=2097152 -T fixedlocal
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 1 -D cacheclean-ns1 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 1 -D cacheclean-ns1 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 3 -D cacheclean-ns2 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 3 -D cacheclean-ns2 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -1 +1 @@
|
||||
-D delzone-ns2 -X named.lock -m record,size,mctx -c named.conf -g -U 4 -T maxcachesize=2097152
|
||||
-D delzone-ns2 -X named.lock -m record -c named.conf -g -U 4 -T maxcachesize=2097152
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dnssec-ns6 -X named.lock -g -T maxcachesize=2097152 -T nonearest -T tat=1
|
||||
-m record -c named.conf -d 99 -D dnssec-ns6 -X named.lock -g -T maxcachesize=2097152 -T nonearest -T tat=1
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# Using "-n 1" allows GL #1795 to be reliably reproduced
|
||||
-D dnstap-ns3 -X named.lock -m record,size,mctx -c named.conf -d 99 -g -U 4 -n 1 -T maxcachesize=2097152
|
||||
-D dnstap-ns3 -X named.lock -m record -c named.conf -d 99 -g -U 4 -n 1 -T maxcachesize=2097152
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dscp-ns1 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
-m record -c named.conf -d 99 -D dscp-ns1 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dscp-ns2 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
-m record -c named.conf -d 99 -D dscp-ns2 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dscp-ns3 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
-m record -c named.conf -d 99 -D dscp-ns3 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dscp-ns4 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
-m record -c named.conf -d 99 -D dscp-ns4 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dscp-ns5 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
-m record -c named.conf -d 99 -D dscp-ns5 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dscp-ns6 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
-m record -c named.conf -d 99 -D dscp-ns6 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D dscp-ns7 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
-m record -c named.conf -d 99 -D dscp-ns7 -X named.lock -g -U 4 -T maxcachesize=2097152 -T dscp=46
|
||||
|
||||
@@ -1 +1 @@
|
||||
-D dupsigs-ns1 -X named.lock -m record,size,mctx -c named.conf -d 99 -g -U 4 -T maxcachesize=2097152 -T sigvalinsecs
|
||||
-D dupsigs-ns1 -X named.lock -m record -c named.conf -d 99 -g -U 4 -T maxcachesize=2097152 -T sigvalinsecs
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 1 -D fetchlimit-ns3 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 1 -D fetchlimit-ns3 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
typedef struct async_instance {
|
||||
ns_plugin_t *module;
|
||||
isc_mem_t *mctx;
|
||||
isc_mempool_t *datapool;
|
||||
isc_ht_t *ht;
|
||||
isc_mutex_t hlock;
|
||||
isc_log_t *lctx;
|
||||
@@ -146,7 +145,6 @@ plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
*inst = (async_instance_t){ .mctx = NULL };
|
||||
isc_mem_attach(mctx, &inst->mctx);
|
||||
|
||||
isc_mempool_create(mctx, sizeof(state_t), &inst->datapool);
|
||||
CHECK(isc_ht_init(&inst->ht, mctx, 16));
|
||||
isc_mutex_init(&inst->hlock);
|
||||
|
||||
@@ -194,9 +192,6 @@ plugin_destroy(void **instp) {
|
||||
isc_ht_destroy(&inst->ht);
|
||||
isc_mutex_destroy(&inst->hlock);
|
||||
}
|
||||
if (inst->datapool != NULL) {
|
||||
isc_mempool_destroy(&inst->datapool);
|
||||
}
|
||||
|
||||
isc_mem_putanddetach(&inst->mctx, inst, sizeof(*inst));
|
||||
*instp = NULL;
|
||||
@@ -230,10 +225,8 @@ client_state_create(const query_ctx_t *qctx, async_instance_t *inst) {
|
||||
state_t *state = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
state = isc_mempool_get(inst->datapool);
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
state = isc_mem_get(inst->mctx, sizeof(*state));
|
||||
*state = (state_t){ .async = false };
|
||||
|
||||
LOCK(&inst->hlock);
|
||||
result = isc_ht_add(inst->ht, (const unsigned char *)&qctx->client,
|
||||
@@ -257,7 +250,7 @@ client_state_destroy(const query_ctx_t *qctx, async_instance_t *inst) {
|
||||
UNLOCK(&inst->hlock);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
|
||||
isc_mempool_put(inst->datapool, state);
|
||||
isc_mem_put(inst->mctx, state, sizeof(*state));
|
||||
}
|
||||
|
||||
static ns_hookresult_t
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D legacy-ns4 -X named.lock -g -U 4 -T maxcachesize=2097152 -T noedns
|
||||
-m record -c named.conf -d 99 -D legacy-ns4 -X named.lock -g -U 4 -T maxcachesize=2097152 -T noedns
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D legacy-ns5 -X named.lock -g -U 4 -T maxcachesize=2097152 -T noedns
|
||||
-m record -c named.conf -d 99 -D legacy-ns5 -X named.lock -g -U 4 -T maxcachesize=2097152 -T noedns
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D legacy-ns6 -X named.lock -g -U 4 -T maxcachesize=2097152 -T maxudp512
|
||||
-m record -c named.conf -d 99 -D legacy-ns6 -X named.lock -g -U 4 -T maxcachesize=2097152 -T maxudp512
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D legacy-ns7 -X named.lock -g -U 4 -T maxcachesize=2097152 -T maxudp512
|
||||
-m record -c named.conf -d 99 -D legacy-ns7 -X named.lock -g -U 4 -T maxcachesize=2097152 -T maxudp512
|
||||
|
||||
@@ -35,7 +35,7 @@ DLFILE="named_deflog"
|
||||
|
||||
PIDFILE="${THISDIR}/${CONFDIR}/named.pid"
|
||||
myRNDC="$RNDC -c ${THISDIR}/${CONFDIR}/rndc.conf"
|
||||
myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -T nosyslog -d 99 -D logfileconfig-ns1 -X named.lock -U 4"
|
||||
myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record -T nosyslog -d 99 -D logfileconfig-ns1 -X named.lock -U 4"
|
||||
|
||||
# Test given condition. If true, test again after a second. Used for testing
|
||||
# filesystem-dependent conditions in order to prevent false negatives caused by
|
||||
|
||||
@@ -1 +1 @@
|
||||
-D mirror-ns3 -X named.lock -m record,size,mctx -c named.conf -d 99 -g -U 4 -T maxcachesize=2097152 -T tat=3
|
||||
-D mirror-ns3 -X named.lock -m record -c named.conf -d 99 -g -U 4 -T maxcachesize=2097152 -T tat=3
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D mkeys-ns2 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=5/10/20 -T tat=1
|
||||
-m record -c named.conf -d 99 -D mkeys-ns2 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=5/10/20 -T tat=1
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D mkeys-ns3 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=5/10/20
|
||||
-m record -c named.conf -d 99 -D mkeys-ns3 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=5/10/20
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 99 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=2/20/40
|
||||
-m record -c named.conf -d 99 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=2/20/40
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=5/10/20
|
||||
-m record -c named.conf -d 99 -X named.lock -g -T maxcachesize=2097152 -T mkeytimers=5/10/20
|
||||
|
||||
@@ -1 +1 @@
|
||||
-D nsupdate-ns5 -m record,size,mctx -c named.conf -d 99 -X named.lock -g -U 4 -T maxcachesize=2097152 -T fixedlocal
|
||||
-D nsupdate-ns5 -m record -c named.conf -d 99 -X named.lock -g -U 4 -T maxcachesize=2097152 -T fixedlocal
|
||||
|
||||
@@ -1 +1 @@
|
||||
-D nsupdate-ns6 -m record,size,mctx -c named.conf -d 99 -X named.lock -g -U 4 -T maxcachesize=2097152 -T fixedlocal
|
||||
-D nsupdate-ns6 -m record -c named.conf -d 99 -X named.lock -g -U 4 -T maxcachesize=2097152 -T fixedlocal
|
||||
|
||||
@@ -211,7 +211,7 @@ main(int argc, char *argv[]) {
|
||||
isc_timermgr_t *timermgr = NULL;
|
||||
isc_socketmgr_t *socketmgr = NULL;
|
||||
dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
dns_dispatch_t *dispatchv4;
|
||||
dns_view_t *view;
|
||||
uint16_t port = PORT;
|
||||
@@ -284,12 +284,10 @@ main(int argc, char *argv[]) {
|
||||
|
||||
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
|
||||
DNS_DISPATCHATTR_IPV4;
|
||||
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
|
||||
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
|
||||
dispatchv4 = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
have_src ? &srcaddr : &bind_any, 4096, 4,
|
||||
2, 3, 5, attrs, attrmask, &dispatchv4));
|
||||
2, 3, 5, attrs, &dispatchv4));
|
||||
requestmgr = NULL;
|
||||
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
|
||||
@@ -833,7 +833,7 @@ status=`expr $status + $ret`
|
||||
n=`expr $n + 1`
|
||||
echo_i "check logged command line ($n)"
|
||||
ret=0
|
||||
grep "running as: .* -m record,size,mctx " ns1/named.run > /dev/null || ret=1
|
||||
grep "running as: .* -m record " ns1/named.run > /dev/null || ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 99 -D rpzextra-ns1 -X named.lock -U 4 -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 99 -D rpzextra-ns1 -X named.lock -U 4 -T maxcachesize=2097152
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
set -e
|
||||
|
||||
RNDCCMD="$RNDC -c ../common/rndc.conf -p ${CONTROLPORT} -s"
|
||||
NAMED_DEFAULT_ARGS="-m record,size,mctx -d 99 -g -U 4"
|
||||
NAMED_DEFAULT_ARGS="-m record -d 99 -g -U 4"
|
||||
|
||||
kill_named() {
|
||||
pidfile="${1}"
|
||||
|
||||
@@ -267,7 +267,7 @@ sub construct_ns_command {
|
||||
} else {
|
||||
$command .= "-D $test-$server ";
|
||||
$command .= "-X named.lock ";
|
||||
$command .= "-m record,size,mctx ";
|
||||
$command .= "-m record ";
|
||||
|
||||
foreach my $t_option(
|
||||
"dropedns", "ednsformerr", "ednsnotimp", "ednsrefused",
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 1 -D timeouts-ns1 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 1 -D timeouts-ns1 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -198,7 +198,7 @@ main(int argc, char *argv[]) {
|
||||
isc_timermgr_t *timermgr = NULL;
|
||||
isc_socketmgr_t *socketmgr = NULL;
|
||||
isc_socket_t *sock = NULL;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
isc_sockaddr_t bind_any;
|
||||
dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||
dns_dispatch_t *dispatchv4 = NULL;
|
||||
@@ -245,12 +245,9 @@ main(int argc, char *argv[]) {
|
||||
isc_sockaddr_any(&bind_any);
|
||||
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
|
||||
DNS_DISPATCHATTR_IPV4;
|
||||
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
|
||||
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
|
||||
dispatchv4 = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
|
||||
4096, 4, 2, 3, 5, attrs, attrmask,
|
||||
&dispatchv4));
|
||||
4096, 4, 2, 3, 5, attrs, &dispatchv4));
|
||||
requestmgr = NULL;
|
||||
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
|
||||
@@ -142,7 +142,7 @@ main(int argc, char **argv) {
|
||||
isc_timermgr_t *timermgr = NULL;
|
||||
isc_socketmgr_t *socketmgr = NULL;
|
||||
isc_socket_t *sock = NULL;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
isc_sockaddr_t bind_any;
|
||||
dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||
dns_dispatch_t *dispatchv4 = NULL;
|
||||
@@ -188,12 +188,9 @@ main(int argc, char **argv) {
|
||||
isc_sockaddr_any(&bind_any);
|
||||
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
|
||||
DNS_DISPATCHATTR_IPV4;
|
||||
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
|
||||
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
|
||||
dispatchv4 = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &bind_any,
|
||||
4096, 4, 2, 3, 5, attrs, attrmask,
|
||||
&dispatchv4));
|
||||
4096, 4, 2, 3, 5, attrs, &dispatchv4));
|
||||
requestmgr = NULL;
|
||||
RUNCHECK(dns_requestmgr_create(mctx, timermgr, socketmgr, taskmgr,
|
||||
dispatchmgr, dispatchv4, NULL,
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 1 -D zero-ns2 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 1 -D zero-ns2 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 1 -D zero-ns3 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 1 -D zero-ns3 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -1 +1 @@
|
||||
-m record,size,mctx -c named.conf -d 1 -D zero-ns4 -X named.lock -g -T maxcachesize=2097152
|
||||
-m record -c named.conf -d 1 -D zero-ns4 -X named.lock -g -T maxcachesize=2097152
|
||||
|
||||
@@ -130,12 +130,6 @@ main(int argc, char *argv[]) {
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "size") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGSIZE;
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "mctx") == 0) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGCTX;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
+2
-6
@@ -2071,7 +2071,7 @@ main(int argc, char *argv[]) {
|
||||
isc_timermgr_t *timermgr = NULL;
|
||||
isc_socketmgr_t *socketmgr = NULL;
|
||||
dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
dns_dispatch_t *dispatchvx = NULL;
|
||||
dns_view_t *view = NULL;
|
||||
int ns;
|
||||
@@ -2139,14 +2139,10 @@ main(int argc, char *argv[]) {
|
||||
isc_sockaddr_any6(&bind_any);
|
||||
attrs |= DNS_DISPATCHATTR_IPV6;
|
||||
}
|
||||
attrmask = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_TCP |
|
||||
DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_IPV6;
|
||||
dispatchvx = NULL;
|
||||
RUNCHECK(dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr,
|
||||
have_src ? &srcaddr : &bind_any, 4096, 100,
|
||||
100, 17, 19, attrs, attrmask,
|
||||
&dispatchvx));
|
||||
|
||||
100, 17, 19, attrs, &dispatchvx));
|
||||
RUNCHECK(dns_requestmgr_create(
|
||||
mctx, timermgr, socketmgr, taskmgr, dispatchmgr,
|
||||
have_ipv4 ? dispatchvx : NULL, have_ipv6 ? dispatchvx : NULL,
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
@@
|
||||
statement S;
|
||||
expression V;
|
||||
@@
|
||||
|
||||
V = isc_mempool_get(...);
|
||||
- if (V == NULL) S
|
||||
|
||||
@@
|
||||
type T;
|
||||
statement S;
|
||||
expression V;
|
||||
@@
|
||||
|
||||
V = (T *)isc_mempool_get(...);
|
||||
- if (V == NULL) S
|
||||
|
||||
@@
|
||||
statement S;
|
||||
expression V;
|
||||
@@
|
||||
|
||||
if (V == NULL) V = isc_mempool_get(...);
|
||||
- if (V == NULL) S
|
||||
|
||||
@@
|
||||
statement S1, S2;
|
||||
expression V;
|
||||
@@
|
||||
|
||||
V = isc_mempool_get(...);
|
||||
- if (V == NULL) S1 else { S2 }
|
||||
+ S2
|
||||
|
||||
@@
|
||||
type T;
|
||||
expression V, E1, E2;
|
||||
@@
|
||||
|
||||
- V = (T)isc_mempool_get(E1, E2);
|
||||
+ V = isc_mempool_get(E1, E2);
|
||||
@@ -1376,6 +1376,28 @@ AC_SUBST([CMOCKA_LIBS])
|
||||
|
||||
AM_CONDITIONAL([HAVE_CMOCKA], [test "$with_cmocka" = "yes"])
|
||||
|
||||
#
|
||||
# Compile with jemalloc (either provided as package or wired in the system on FreeBSD and NetBSD)
|
||||
#
|
||||
# [pairwise: --with-jemalloc=detect, --with-jemalloc=yes, --without-jemalloc]
|
||||
AC_ARG_WITH([jemalloc],
|
||||
[AS_HELP_STRING([--with-jemalloc=detect],[enable jemalloc memory allocator (default is detect)])],
|
||||
[],[with_jemalloc=detect])
|
||||
|
||||
AS_CASE([$with_jemalloc],
|
||||
[no],[],
|
||||
[yes],[AX_CHECK_JEMALLOC(
|
||||
[AC_DEFINE([HAVE_JEMALLOC], [1], [Define to 1 if jemalloc is available])],
|
||||
[AC_MSG_ERROR([jemalloc not found])])],
|
||||
[AX_CHECK_JEMALLOC(
|
||||
[AC_DEFINE([HAVE_JEMALLOC], [1], [Define to 1 if jemalloc is available])
|
||||
with_jemalloc=yes],
|
||||
[AC_MSG_WARN([jemalloc not found; performance will be reduced])
|
||||
with_jemalloc=no])])
|
||||
|
||||
AS_IF([test "$with_jemalloc" = "no"],
|
||||
[AC_CHECK_FUNCS([malloc_size malloc_usable_size])])
|
||||
|
||||
#
|
||||
# was --with-tuning specified?
|
||||
#
|
||||
@@ -1687,6 +1709,9 @@ report() {
|
||||
echo "Configuration summary:"
|
||||
echo "-------------------------------------------------------------------------------"
|
||||
echo "Optional features enabled:"
|
||||
if test "yes" = "$with_jemalloc"; then
|
||||
echo " Memory allocator: jemalloc"
|
||||
fi
|
||||
if test "yes" = "$enable_full_report" -o "standard" = "$with_locktype"; then
|
||||
echo " Mutex lock type: $with_locktype"
|
||||
fi
|
||||
@@ -1743,6 +1768,14 @@ report() {
|
||||
echo "-------------------------------------------------------------------------------"
|
||||
|
||||
echo "Features disabled or unavailable on this platform:"
|
||||
if test "no" = "$with_jemalloc"; then
|
||||
echo " Memory allocator: system"
|
||||
echo " WARNING: This is not a recommended configuration"
|
||||
echo " WARNING: Using system memory allocator causes"
|
||||
echo " WARNING: reduced performance and increased memory"
|
||||
echo " WARNING: fragmentation. Installing jemalloc >= 4.0.0"
|
||||
echo " WARNING: memory allocator is strongly recommended."
|
||||
fi
|
||||
test "small" = "$with_tuning" || echo " Small-system tuning (--with-tuning)"
|
||||
|
||||
test "no" = "$enable_dnstap" && \
|
||||
|
||||
+9
-16
@@ -483,10 +483,12 @@ or simply by running `isc_buffer_init()` on the region's base pointer.
|
||||
|
||||
#### <a name="mem"></a>Memory management
|
||||
|
||||
BIND manages its own memory internally via "memory contexts". Multiple
|
||||
BIND tracks its memory usage internally via "memory contexts". Multiple
|
||||
separate memory contexts can be created for the use of different modules or
|
||||
subcomponents, and each can have its own size limits and tuning parameters
|
||||
and maintain its own statistics, allocations and free lists.
|
||||
and maintain its own statistics, allocations and free lists. Memory
|
||||
allocation is based on the `jemalloc` library on platforms where the library
|
||||
is available.
|
||||
|
||||
The memory system helps with diagnosis of common coding errors such as
|
||||
memory leaks and use after free. Newly allocated memory is populated with
|
||||
@@ -499,13 +501,6 @@ To create a basic memory context, use:
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
(The zeroes are tuning parameters, `max_size` and `target_size`: Any
|
||||
allocations smaller than `max_size` will be satisfied by getting
|
||||
blocks of size `target_size` from the operating system's memory
|
||||
allocator and breaking them up into pieces, while larger allocations
|
||||
will call the system allocator directly. These parameters are rarely
|
||||
used.)
|
||||
|
||||
When holding a persistent reference to a memory context it is advisable to
|
||||
increment its reference counter using `isc_mem_attach()`. Do not just
|
||||
copy an `mctx` pointer; this may lead to a shutdown race in which the
|
||||
@@ -567,16 +562,14 @@ The function `isc_mem_strdup()` -- a version of `strdup()` that uses memory
|
||||
contexts -- will also return memory that can be freed with
|
||||
`isc_mem_free()`.
|
||||
|
||||
Every allocation and deallocation requires a memory context lock to be
|
||||
acquired. This will cause performance problems if you write code that
|
||||
allocates and deallocates memory frequently. Whenever possible,
|
||||
inner loop functions should be passed static buffers rather than allocating
|
||||
memory.
|
||||
|
||||
In cases where small fixed-size blocks of memory may be needed frequently,
|
||||
the `isc_mempool` API can be used. This creates a standing pool of blocks
|
||||
of a specified size which can be passed out and returned without the need
|
||||
for locking the entire memory context.
|
||||
for a new memory allocation; this can improve performance in tight inner
|
||||
loops.
|
||||
|
||||
None of these allocation functions, including `isc_mempool_get()`, can
|
||||
fail. If no memory is available for allocation, the program will abort.
|
||||
|
||||
#### <a name="lists"></a>Lists
|
||||
|
||||
|
||||
@@ -51,6 +51,11 @@ Feature Changes
|
||||
configuration option ``--disable-doh``. This allows BIND 9 to be
|
||||
compiled without libnghttp2 library. [GL #2478]
|
||||
|
||||
- Memory allocation has been substantially refactored, and is now based on
|
||||
the memory allocation API provided by the `jemalloc` library on platforms
|
||||
where it is available. This library is now recommended for building BIND 9.
|
||||
:gl:`#2433`
|
||||
|
||||
Bug Fixes
|
||||
~~~~~~~~~
|
||||
|
||||
|
||||
+31
-128
@@ -112,14 +112,8 @@ struct dns_adb {
|
||||
unsigned int irefcnt;
|
||||
unsigned int erefcnt;
|
||||
|
||||
isc_mutex_t mplock;
|
||||
isc_mempool_t *nmp; /*%< dns_adbname_t */
|
||||
isc_mempool_t *nhmp; /*%< dns_adbnamehook_t */
|
||||
isc_mempool_t *limp; /*%< dns_adblameinfo_t */
|
||||
isc_mempool_t *emp; /*%< dns_adbentry_t */
|
||||
isc_mempool_t *ahmp; /*%< dns_adbfind_t */
|
||||
isc_mempool_t *aimp; /*%< dns_adbaddrinfo_t */
|
||||
isc_mempool_t *afmp; /*%< dns_adbfetch_t */
|
||||
isc_refcount_t ahrefcnt;
|
||||
isc_refcount_t nhrefcnt;
|
||||
|
||||
/*!
|
||||
* Bucketized locks and lists for names.
|
||||
@@ -624,12 +618,6 @@ grow_entries(isc_task_t *task, isc_event_t *ev) {
|
||||
newentrylocks = isc_mem_get(adb->mctx, sizeof(*newentrylocks) * n);
|
||||
newentry_sd = isc_mem_get(adb->mctx, sizeof(*newentry_sd) * n);
|
||||
newentry_refcnt = isc_mem_get(adb->mctx, sizeof(*newentry_refcnt) * n);
|
||||
if (newentries == NULL || newdeadentries == NULL ||
|
||||
newentrylocks == NULL || newentry_sd == NULL ||
|
||||
newentry_refcnt == NULL)
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the new resources.
|
||||
@@ -795,11 +783,6 @@ grow_names(isc_task_t *task, isc_event_t *ev) {
|
||||
newnamelocks = isc_mem_get(adb->mctx, sizeof(*newnamelocks) * n);
|
||||
newname_sd = isc_mem_get(adb->mctx, sizeof(*newname_sd) * n);
|
||||
newname_refcnt = isc_mem_get(adb->mctx, sizeof(*newname_refcnt) * n);
|
||||
if (newnames == NULL || newdeadnames == NULL || newnamelocks == NULL ||
|
||||
newname_sd == NULL || newname_refcnt == NULL)
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the new resources.
|
||||
@@ -1734,10 +1717,7 @@ static inline dns_adbname_t *
|
||||
new_adbname(dns_adb_t *adb, const dns_name_t *dnsname) {
|
||||
dns_adbname_t *name;
|
||||
|
||||
name = isc_mempool_get(adb->nmp);
|
||||
if (name == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
name = isc_mem_get(adb->mctx, sizeof(*name));
|
||||
|
||||
dns_name_init(&name->name, NULL);
|
||||
dns_name_dup(dnsname, adb->mctx, &name->name);
|
||||
@@ -1795,7 +1775,7 @@ free_adbname(dns_adb_t *adb, dns_adbname_t **name) {
|
||||
n->magic = 0;
|
||||
dns_name_free(&n->name, adb->mctx);
|
||||
|
||||
isc_mempool_put(adb->nmp, n);
|
||||
isc_mem_put(adb->mctx, n, sizeof(*n));
|
||||
LOCK(&adb->namescntlock);
|
||||
adb->namescnt--;
|
||||
dec_adbstats(adb, dns_adbstats_namescnt);
|
||||
@@ -1806,10 +1786,8 @@ static inline dns_adbnamehook_t *
|
||||
new_adbnamehook(dns_adb_t *adb, dns_adbentry_t *entry) {
|
||||
dns_adbnamehook_t *nh;
|
||||
|
||||
nh = isc_mempool_get(adb->nhmp);
|
||||
if (nh == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
nh = isc_mem_get(adb->mctx, sizeof(*nh));
|
||||
isc_refcount_increment0(&adb->nhrefcnt);
|
||||
|
||||
nh->magic = DNS_ADBNAMEHOOK_MAGIC;
|
||||
nh->entry = entry;
|
||||
@@ -1830,7 +1808,9 @@ free_adbnamehook(dns_adb_t *adb, dns_adbnamehook_t **namehook) {
|
||||
INSIST(!ISC_LINK_LINKED(nh, plink));
|
||||
|
||||
nh->magic = 0;
|
||||
isc_mempool_put(adb->nhmp, nh);
|
||||
|
||||
isc_refcount_decrement(&adb->nhrefcnt);
|
||||
isc_mem_put(adb->mctx, nh, sizeof(*nh));
|
||||
}
|
||||
|
||||
static inline dns_adblameinfo_t *
|
||||
@@ -1838,10 +1818,7 @@ new_adblameinfo(dns_adb_t *adb, const dns_name_t *qname,
|
||||
dns_rdatatype_t qtype) {
|
||||
dns_adblameinfo_t *li;
|
||||
|
||||
li = isc_mempool_get(adb->limp);
|
||||
if (li == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
li = isc_mem_get(adb->mctx, sizeof(*li));
|
||||
|
||||
dns_name_init(&li->qname, NULL);
|
||||
dns_name_dup(qname, adb->mctx, &li->qname);
|
||||
@@ -1867,17 +1844,14 @@ free_adblameinfo(dns_adb_t *adb, dns_adblameinfo_t **lameinfo) {
|
||||
|
||||
li->magic = 0;
|
||||
|
||||
isc_mempool_put(adb->limp, li);
|
||||
isc_mem_put(adb->mctx, li, sizeof(*li));
|
||||
}
|
||||
|
||||
static inline dns_adbentry_t *
|
||||
new_adbentry(dns_adb_t *adb) {
|
||||
dns_adbentry_t *e;
|
||||
|
||||
e = isc_mempool_get(adb->emp);
|
||||
if (e == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
e = isc_mem_get(adb->mctx, sizeof(*e));
|
||||
|
||||
e->magic = DNS_ADBENTRY_MAGIC;
|
||||
e->lock_bucket = DNS_ADB_INVALIDBUCKET;
|
||||
@@ -1944,7 +1918,7 @@ free_adbentry(dns_adb_t *adb, dns_adbentry_t **entry) {
|
||||
li = ISC_LIST_HEAD(e->lameinfo);
|
||||
}
|
||||
|
||||
isc_mempool_put(adb->emp, e);
|
||||
isc_mem_put(adb->mctx, e, sizeof(*e));
|
||||
LOCK(&adb->entriescntlock);
|
||||
adb->entriescnt--;
|
||||
dec_adbstats(adb, dns_adbstats_entriescnt);
|
||||
@@ -1955,10 +1929,8 @@ static inline dns_adbfind_t *
|
||||
new_adbfind(dns_adb_t *adb) {
|
||||
dns_adbfind_t *h;
|
||||
|
||||
h = isc_mempool_get(adb->ahmp);
|
||||
if (h == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
h = isc_mem_get(adb->mctx, sizeof(*h));
|
||||
isc_refcount_increment0(&adb->ahrefcnt);
|
||||
|
||||
/*
|
||||
* Public members.
|
||||
@@ -1993,10 +1965,7 @@ static inline dns_adbfetch_t *
|
||||
new_adbfetch(dns_adb_t *adb) {
|
||||
dns_adbfetch_t *f;
|
||||
|
||||
f = isc_mempool_get(adb->afmp);
|
||||
if (f == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
f = isc_mem_get(adb->mctx, sizeof(*f));
|
||||
|
||||
f->magic = 0;
|
||||
f->fetch = NULL;
|
||||
@@ -2022,7 +1991,7 @@ free_adbfetch(dns_adb_t *adb, dns_adbfetch_t **fetch) {
|
||||
dns_rdataset_disassociate(&f->rdataset);
|
||||
}
|
||||
|
||||
isc_mempool_put(adb->afmp, f);
|
||||
isc_mem_put(adb->mctx, f, sizeof(*f));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
@@ -2042,7 +2011,9 @@ free_adbfind(dns_adb_t *adb, dns_adbfind_t **findp) {
|
||||
find->magic = 0;
|
||||
|
||||
isc_mutex_destroy(&find->lock);
|
||||
isc_mempool_put(adb->ahmp, find);
|
||||
|
||||
isc_refcount_decrement(&adb->ahrefcnt);
|
||||
isc_mem_put(adb->mctx, find, sizeof(*find));
|
||||
return (dec_adb_irefcnt(adb));
|
||||
}
|
||||
|
||||
@@ -2055,10 +2026,7 @@ static inline dns_adbaddrinfo_t *
|
||||
new_adbaddrinfo(dns_adb_t *adb, dns_adbentry_t *entry, in_port_t port) {
|
||||
dns_adbaddrinfo_t *ai;
|
||||
|
||||
ai = isc_mempool_get(adb->aimp);
|
||||
if (ai == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
ai = isc_mem_get(adb->mctx, sizeof(*ai));
|
||||
|
||||
ai->magic = DNS_ADBADDRINFO_MAGIC;
|
||||
ai->sockaddr = entry->sockaddr;
|
||||
@@ -2085,7 +2053,7 @@ free_adbaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **ainfo) {
|
||||
|
||||
ai->magic = 0;
|
||||
|
||||
isc_mempool_put(adb->aimp, ai);
|
||||
isc_mem_put(adb->mctx, ai, sizeof(*ai));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2539,14 +2507,6 @@ destroy(dns_adb_t *adb) {
|
||||
isc_task_detach(&adb->excl);
|
||||
}
|
||||
|
||||
isc_mempool_destroy(&adb->nmp);
|
||||
isc_mempool_destroy(&adb->nhmp);
|
||||
isc_mempool_destroy(&adb->limp);
|
||||
isc_mempool_destroy(&adb->emp);
|
||||
isc_mempool_destroy(&adb->ahmp);
|
||||
isc_mempool_destroy(&adb->aimp);
|
||||
isc_mempool_destroy(&adb->afmp);
|
||||
|
||||
isc_mutexblock_destroy(adb->entrylocks, adb->nentries);
|
||||
isc_mem_put(adb->mctx, adb->entries,
|
||||
sizeof(*adb->entries) * adb->nentries);
|
||||
@@ -2572,7 +2532,6 @@ destroy(dns_adb_t *adb) {
|
||||
|
||||
isc_mutex_destroy(&adb->reflock);
|
||||
isc_mutex_destroy(&adb->lock);
|
||||
isc_mutex_destroy(&adb->mplock);
|
||||
isc_mutex_destroy(&adb->overmemlock);
|
||||
isc_mutex_destroy(&adb->entriescntlock);
|
||||
isc_mutex_destroy(&adb->namescntlock);
|
||||
@@ -2608,13 +2567,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
adb->magic = 0;
|
||||
adb->erefcnt = 1;
|
||||
adb->irefcnt = 0;
|
||||
adb->nmp = NULL;
|
||||
adb->nhmp = NULL;
|
||||
adb->limp = NULL;
|
||||
adb->emp = NULL;
|
||||
adb->ahmp = NULL;
|
||||
adb->aimp = NULL;
|
||||
adb->afmp = NULL;
|
||||
adb->task = NULL;
|
||||
adb->excl = NULL;
|
||||
adb->mctx = NULL;
|
||||
@@ -2670,7 +2622,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
isc_mem_attach(mem, &adb->mctx);
|
||||
|
||||
isc_mutex_init(&adb->lock);
|
||||
isc_mutex_init(&adb->mplock);
|
||||
isc_mutex_init(&adb->reflock);
|
||||
isc_mutex_init(&adb->overmemlock);
|
||||
isc_mutex_init(&adb->entriescntlock);
|
||||
@@ -2680,10 +2631,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
do { \
|
||||
(adb)->el = isc_mem_get((adb)->mctx, \
|
||||
sizeof(*(adb)->el) * (adb)->nentries); \
|
||||
if ((adb)->el == NULL) { \
|
||||
result = ISC_R_NOMEMORY; \
|
||||
goto fail1; \
|
||||
} \
|
||||
} while (0)
|
||||
ALLOCENTRY(adb, entries);
|
||||
ALLOCENTRY(adb, deadentries);
|
||||
@@ -2696,10 +2643,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
do { \
|
||||
(adb)->el = isc_mem_get((adb)->mctx, \
|
||||
sizeof(*(adb)->el) * (adb)->nnames); \
|
||||
if ((adb)->el == NULL) { \
|
||||
result = ISC_R_NOMEMORY; \
|
||||
goto fail1; \
|
||||
} \
|
||||
} while (0)
|
||||
ALLOCNAME(adb, names);
|
||||
ALLOCNAME(adb, deadnames);
|
||||
@@ -2730,27 +2673,8 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
|
||||
}
|
||||
isc_mutexblock_init(adb->entrylocks, adb->nentries);
|
||||
|
||||
/*
|
||||
* Memory pools
|
||||
*/
|
||||
#define MPINIT(t, p, n) \
|
||||
do { \
|
||||
isc_mempool_create(mem, sizeof(t), &(p)); \
|
||||
isc_mempool_setfreemax((p), FREE_ITEMS); \
|
||||
isc_mempool_setfillcount((p), FILL_COUNT); \
|
||||
isc_mempool_setname((p), n); \
|
||||
isc_mempool_associatelock((p), &adb->mplock); \
|
||||
} while (0)
|
||||
|
||||
MPINIT(dns_adbname_t, adb->nmp, "adbname");
|
||||
MPINIT(dns_adbnamehook_t, adb->nhmp, "adbnamehook");
|
||||
MPINIT(dns_adblameinfo_t, adb->limp, "adblameinfo");
|
||||
MPINIT(dns_adbentry_t, adb->emp, "adbentry");
|
||||
MPINIT(dns_adbfind_t, adb->ahmp, "adbfind");
|
||||
MPINIT(dns_adbaddrinfo_t, adb->aimp, "adbaddrinfo");
|
||||
MPINIT(dns_adbfetch_t, adb->afmp, "adbfetch");
|
||||
|
||||
#undef MPINIT
|
||||
isc_refcount_init(&adb->ahrefcnt, 0);
|
||||
isc_refcount_init(&adb->nhrefcnt, 0);
|
||||
|
||||
/*
|
||||
* Allocate an internal task.
|
||||
@@ -2786,7 +2710,6 @@ fail2:
|
||||
isc_mutexblock_destroy(adb->entrylocks, adb->nentries);
|
||||
isc_mutexblock_destroy(adb->namelocks, adb->nnames);
|
||||
|
||||
fail1: /* clean up only allocated memory */
|
||||
if (adb->entries != NULL) {
|
||||
isc_mem_put(adb->mctx, adb->entries,
|
||||
sizeof(*adb->entries) * adb->nentries);
|
||||
@@ -2827,33 +2750,11 @@ fail1: /* clean up only allocated memory */
|
||||
isc_mem_put(adb->mctx, adb->name_refcnt,
|
||||
sizeof(*adb->name_refcnt) * adb->nnames);
|
||||
}
|
||||
if (adb->nmp != NULL) {
|
||||
isc_mempool_destroy(&adb->nmp);
|
||||
}
|
||||
if (adb->nhmp != NULL) {
|
||||
isc_mempool_destroy(&adb->nhmp);
|
||||
}
|
||||
if (adb->limp != NULL) {
|
||||
isc_mempool_destroy(&adb->limp);
|
||||
}
|
||||
if (adb->emp != NULL) {
|
||||
isc_mempool_destroy(&adb->emp);
|
||||
}
|
||||
if (adb->ahmp != NULL) {
|
||||
isc_mempool_destroy(&adb->ahmp);
|
||||
}
|
||||
if (adb->aimp != NULL) {
|
||||
isc_mempool_destroy(&adb->aimp);
|
||||
}
|
||||
if (adb->afmp != NULL) {
|
||||
isc_mempool_destroy(&adb->afmp);
|
||||
}
|
||||
|
||||
isc_mutex_destroy(&adb->namescntlock);
|
||||
isc_mutex_destroy(&adb->entriescntlock);
|
||||
isc_mutex_destroy(&adb->overmemlock);
|
||||
isc_mutex_destroy(&adb->reflock);
|
||||
isc_mutex_destroy(&adb->mplock);
|
||||
isc_mutex_destroy(&adb->lock);
|
||||
if (adb->excl != NULL) {
|
||||
isc_task_detach(&adb->excl);
|
||||
@@ -2918,7 +2819,7 @@ dns_adb_whenshutdown(dns_adb_t *adb, isc_task_t *task, isc_event_t **eventp) {
|
||||
zeroirefcnt = (adb->irefcnt == 0);
|
||||
|
||||
if (adb->shutting_down && zeroirefcnt &&
|
||||
isc_mempool_getallocated(adb->ahmp) == 0)
|
||||
isc_refcount_current(&adb->ahrefcnt) == 0)
|
||||
{
|
||||
/*
|
||||
* We're already shutdown. Send the event.
|
||||
@@ -2968,7 +2869,7 @@ dns_adb_shutdown(dns_adb_t *adb) {
|
||||
|
||||
if (!adb->shutting_down) {
|
||||
adb->shutting_down = true;
|
||||
isc_mem_setwater(adb->mctx, water, adb, 0, 0);
|
||||
isc_mem_setwater(adb->mctx, NULL, NULL, 0, 0);
|
||||
/*
|
||||
* Isolate shutdown_names and shutdown_entries calls.
|
||||
*/
|
||||
@@ -3523,9 +3424,11 @@ dump_adb(dns_adb_t *adb, FILE *f, bool debug, isc_stdtime_t now) {
|
||||
fprintf(f, "; [plain success/timeout]\n;\n");
|
||||
if (debug) {
|
||||
LOCK(&adb->reflock);
|
||||
fprintf(f, "; addr %p, erefcnt %u, irefcnt %u, finds out %u\n",
|
||||
fprintf(f,
|
||||
"; addr %p, erefcnt %u, irefcnt %u, finds out "
|
||||
"%" PRIuFAST32 "\n",
|
||||
adb, adb->erefcnt, adb->irefcnt,
|
||||
isc_mempool_getallocated(adb->nhmp));
|
||||
isc_refcount_current(&adb->nhrefcnt));
|
||||
UNLOCK(&adb->reflock);
|
||||
}
|
||||
|
||||
@@ -4796,7 +4699,7 @@ dns_adb_setadbsize(dns_adb_t *adb, size_t size) {
|
||||
lowater = size - (size >> 2); /* Approximately 3/4ths. */
|
||||
|
||||
if (size == 0U || hiwater == 0U || lowater == 0U) {
|
||||
isc_mem_setwater(adb->mctx, water, adb, 0, 0);
|
||||
isc_mem_setwater(adb->mctx, NULL, NULL, 0, 0);
|
||||
} else {
|
||||
isc_mem_setwater(adb->mctx, water, adb, hiwater, lowater);
|
||||
}
|
||||
|
||||
+1
-1
@@ -950,7 +950,7 @@ dns_cache_setcachesize(dns_cache_t *cache, size_t size) {
|
||||
/*
|
||||
* Disable cache memory limiting.
|
||||
*/
|
||||
isc_mem_setwater(cache->mctx, water, cache, 0, 0);
|
||||
isc_mem_setwater(cache->mctx, NULL, NULL, 0, 0);
|
||||
} else {
|
||||
/*
|
||||
* Establish new cache memory limits (either for the first
|
||||
|
||||
+2
-8
@@ -201,7 +201,7 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
|
||||
isc_socketmgr_t *socketmgr, isc_taskmgr_t *taskmgr,
|
||||
bool is_shared, dns_dispatch_t **dispp,
|
||||
const isc_sockaddr_t *localaddr) {
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
dns_dispatch_t *disp;
|
||||
unsigned buffersize, maxbuffers, maxrequests, buckets, increment;
|
||||
isc_result_t result;
|
||||
@@ -220,11 +220,6 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
|
||||
INSIST(0);
|
||||
ISC_UNREACHABLE();
|
||||
}
|
||||
attrmask = 0;
|
||||
attrmask |= DNS_DISPATCHATTR_UDP;
|
||||
attrmask |= DNS_DISPATCHATTR_TCP;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV4;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV6;
|
||||
|
||||
if (localaddr == NULL) {
|
||||
isc_sockaddr_anyofpf(&anyaddr, family);
|
||||
@@ -240,8 +235,7 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
|
||||
disp = NULL;
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, localaddr,
|
||||
buffersize, maxbuffers, maxrequests,
|
||||
buckets, increment, attrs, attrmask,
|
||||
&disp);
|
||||
buckets, increment, attrs, &disp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
*dispp = disp;
|
||||
}
|
||||
|
||||
+54
-363
@@ -74,17 +74,7 @@ struct dns_dispatchmgr {
|
||||
unsigned int buffersize; /*%< size of each buffer */
|
||||
unsigned int maxbuffers; /*%< max buffers */
|
||||
|
||||
/* Locked internally. */
|
||||
isc_mutex_t depool_lock;
|
||||
isc_mempool_t *depool; /*%< pool for dispatch events */
|
||||
isc_mutex_t rpool_lock;
|
||||
isc_mempool_t *rpool; /*%< pool for replies */
|
||||
isc_mutex_t dpool_lock;
|
||||
isc_mempool_t *dpool; /*%< dispatch allocations */
|
||||
isc_mutex_t bpool_lock;
|
||||
isc_mempool_t *bpool; /*%< pool for buffers */
|
||||
isc_mutex_t spool_lock;
|
||||
isc_mempool_t *spool; /*%< pool for dispsocks */
|
||||
isc_refcount_t irefs;
|
||||
|
||||
/*%
|
||||
* Locked by qid->lock if qid exists; otherwise, can be used without
|
||||
@@ -206,8 +196,7 @@ struct dns_dispatch {
|
||||
unsigned int maxrequests; /*%< max requests */
|
||||
isc_event_t *ctlevent;
|
||||
|
||||
isc_mutex_t sepool_lock;
|
||||
isc_mempool_t *sepool; /*%< pool for socket events */
|
||||
isc_mem_t *sepool; /*%< pool for socket events */
|
||||
|
||||
/*% Locked by mgr->lock. */
|
||||
ISC_LINK(dns_dispatch_t) link;
|
||||
@@ -232,7 +221,6 @@ struct dns_dispatch {
|
||||
dns_tcpmsg_t tcpmsg; /*%< for tcp streams */
|
||||
dns_qid_t *qid;
|
||||
dispportlist_t *port_table; /*%< hold ports 'owned' by us */
|
||||
isc_mempool_t *portpool; /*%< port table entries */
|
||||
};
|
||||
|
||||
#define QID_MAGIC ISC_MAGIC('Q', 'i', 'd', ' ')
|
||||
@@ -547,8 +535,7 @@ destroy_disp(isc_task_t *task, isc_event_t *event) {
|
||||
disp->socket, disp->task[0]); /* XXXX */
|
||||
|
||||
if (disp->sepool != NULL) {
|
||||
isc_mempool_destroy(&disp->sepool);
|
||||
isc_mutex_destroy(&disp->sepool_lock);
|
||||
isc_mem_destroy(&disp->sepool);
|
||||
}
|
||||
|
||||
if (disp->socket != NULL) {
|
||||
@@ -601,10 +588,7 @@ new_portentry(dns_dispatch_t *disp, in_port_t port) {
|
||||
|
||||
REQUIRE(disp->port_table != NULL);
|
||||
|
||||
portentry = isc_mempool_get(disp->portpool);
|
||||
if (portentry == NULL) {
|
||||
return (portentry);
|
||||
}
|
||||
portentry = isc_mem_get(disp->mgr->mctx, sizeof(*portentry));
|
||||
|
||||
portentry->port = port;
|
||||
isc_refcount_init(&portentry->refs, 1);
|
||||
@@ -633,7 +617,7 @@ deref_portentry(dns_dispatch_t *disp, dispportentry_t **portentryp) {
|
||||
ISC_LIST_UNLINK(disp->port_table[portentry->port %
|
||||
DNS_DISPATCH_PORTTABLESIZE],
|
||||
portentry, link);
|
||||
isc_mempool_put(disp->portpool, portentry);
|
||||
isc_mem_put(disp->mgr->mctx, portentry, sizeof(*portentry));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,10 +687,7 @@ get_dispsocket(dns_dispatch_t *disp, const isc_sockaddr_t *dest,
|
||||
sock = dispsock->socket;
|
||||
dispsock->socket = NULL;
|
||||
} else {
|
||||
dispsock = isc_mempool_get(mgr->spool);
|
||||
if (dispsock == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
dispsock = isc_mem_get(mgr->mctx, sizeof(*dispsock));
|
||||
|
||||
disp->nsockets++;
|
||||
dispsock->socket = NULL;
|
||||
@@ -832,7 +813,7 @@ destroy_dispsocket(dns_dispatch_t *disp, dispsocket_t **dispsockp) {
|
||||
if (dispsock->task != NULL) {
|
||||
isc_task_detach(&dispsock->task);
|
||||
}
|
||||
isc_mempool_put(disp->mgr->spool, dispsock);
|
||||
isc_mem_put(disp->mgr->mctx, dispsock, sizeof(*dispsock));
|
||||
}
|
||||
|
||||
/*%
|
||||
@@ -911,7 +892,7 @@ entry_search(dns_qid_t *qid, const isc_sockaddr_t *dest, dns_messageid_t id,
|
||||
|
||||
static void
|
||||
free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len) {
|
||||
isc_mempool_t *bpool;
|
||||
unsigned int buffersize;
|
||||
INSIST(buf != NULL && len != 0);
|
||||
|
||||
switch (disp->socktype) {
|
||||
@@ -925,9 +906,9 @@ free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len) {
|
||||
INSIST(disp->mgr->buffers > 0);
|
||||
INSIST(len == disp->mgr->buffersize);
|
||||
disp->mgr->buffers--;
|
||||
bpool = disp->mgr->bpool;
|
||||
buffersize = disp->mgr->buffersize;
|
||||
UNLOCK(&disp->mgr->buffer_lock);
|
||||
isc_mempool_put(bpool, buf);
|
||||
isc_mem_put(disp->mgr->mctx, buf, buffersize);
|
||||
break;
|
||||
default:
|
||||
INSIST(0);
|
||||
@@ -937,34 +918,25 @@ free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len) {
|
||||
|
||||
static void *
|
||||
allocate_udp_buffer(dns_dispatch_t *disp) {
|
||||
isc_mempool_t *bpool;
|
||||
void *temp;
|
||||
unsigned int buffersize;
|
||||
|
||||
LOCK(&disp->mgr->buffer_lock);
|
||||
if (disp->mgr->buffers >= disp->mgr->maxbuffers) {
|
||||
UNLOCK(&disp->mgr->buffer_lock);
|
||||
return (NULL);
|
||||
}
|
||||
bpool = disp->mgr->bpool;
|
||||
buffersize = disp->mgr->buffersize;
|
||||
disp->mgr->buffers++;
|
||||
UNLOCK(&disp->mgr->buffer_lock);
|
||||
|
||||
temp = isc_mempool_get(bpool);
|
||||
|
||||
if (temp == NULL) {
|
||||
LOCK(&disp->mgr->buffer_lock);
|
||||
disp->mgr->buffers--;
|
||||
UNLOCK(&disp->mgr->buffer_lock);
|
||||
}
|
||||
|
||||
return (temp);
|
||||
return (isc_mem_get(disp->mgr->mctx, buffersize));
|
||||
}
|
||||
|
||||
static inline void
|
||||
free_sevent(isc_event_t *ev) {
|
||||
isc_mempool_t *pool = ev->ev_destroy_arg;
|
||||
isc_mem_t *pool = ev->ev_destroy_arg;
|
||||
isc_socketevent_t *sev = (isc_socketevent_t *)ev;
|
||||
isc_mempool_put(pool, sev);
|
||||
isc_mem_put(pool, sev, sizeof(*sev));
|
||||
}
|
||||
|
||||
static inline isc_socketevent_t *
|
||||
@@ -973,10 +945,7 @@ allocate_sevent(dns_dispatch_t *disp, isc_socket_t *sock, isc_eventtype_t type,
|
||||
isc_socketevent_t *ev;
|
||||
void *deconst_arg;
|
||||
|
||||
ev = isc_mempool_get(disp->sepool);
|
||||
if (ev == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
ev = isc_mem_get(disp->sepool, sizeof(*ev));
|
||||
DE_CONST(arg, deconst_arg);
|
||||
ISC_EVENT_INIT(ev, sizeof(*ev), 0, NULL, type, action, deconst_arg,
|
||||
sock, free_sevent, disp->sepool);
|
||||
@@ -999,17 +968,16 @@ free_devent(dns_dispatch_t *disp, dns_dispatchevent_t *ev) {
|
||||
return;
|
||||
}
|
||||
|
||||
isc_mempool_put(disp->mgr->depool, ev);
|
||||
isc_refcount_decrement(&disp->mgr->irefs);
|
||||
isc_mem_put(disp->mgr->mctx, ev, sizeof(*ev));
|
||||
}
|
||||
|
||||
static inline dns_dispatchevent_t *
|
||||
allocate_devent(dns_dispatch_t *disp) {
|
||||
dns_dispatchevent_t *ev;
|
||||
|
||||
ev = isc_mempool_get(disp->mgr->depool);
|
||||
if (ev == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
ev = isc_mem_get(disp->mgr->mctx, sizeof(*ev));
|
||||
isc_refcount_increment0(&disp->mgr->irefs);
|
||||
ISC_EVENT_INIT(ev, sizeof(*ev), 0, NULL, 0, NULL, NULL, NULL, NULL,
|
||||
NULL);
|
||||
|
||||
@@ -1627,25 +1595,15 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) {
|
||||
static bool
|
||||
destroy_mgr_ok(dns_dispatchmgr_t *mgr) {
|
||||
mgr_log(mgr, LVL(90),
|
||||
"destroy_mgr_ok: shuttingdown=%d, listnonempty=%d, "
|
||||
"depool=%d, rpool=%d, dpool=%d",
|
||||
MGR_IS_SHUTTINGDOWN(mgr), !ISC_LIST_EMPTY(mgr->list),
|
||||
isc_mempool_getallocated(mgr->depool),
|
||||
isc_mempool_getallocated(mgr->rpool),
|
||||
isc_mempool_getallocated(mgr->dpool));
|
||||
"destroy_mgr_ok: shuttingdown=%d, listnonempty=%d, ",
|
||||
MGR_IS_SHUTTINGDOWN(mgr), !ISC_LIST_EMPTY(mgr->list));
|
||||
if (!MGR_IS_SHUTTINGDOWN(mgr)) {
|
||||
return (false);
|
||||
}
|
||||
if (!ISC_LIST_EMPTY(mgr->list)) {
|
||||
return (false);
|
||||
}
|
||||
if (isc_mempool_getallocated(mgr->depool) != 0) {
|
||||
return (false);
|
||||
}
|
||||
if (isc_mempool_getallocated(mgr->rpool) != 0) {
|
||||
return (false);
|
||||
}
|
||||
if (isc_mempool_getallocated(mgr->dpool) != 0) {
|
||||
if (isc_refcount_current(&mgr->irefs) != 0) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
@@ -1666,22 +1624,6 @@ destroy_mgr(dns_dispatchmgr_t **mgrp) {
|
||||
isc_mutex_destroy(&mgr->lock);
|
||||
mgr->state = 0;
|
||||
|
||||
isc_mempool_destroy(&mgr->depool);
|
||||
isc_mempool_destroy(&mgr->rpool);
|
||||
isc_mempool_destroy(&mgr->dpool);
|
||||
if (mgr->bpool != NULL) {
|
||||
isc_mempool_destroy(&mgr->bpool);
|
||||
}
|
||||
if (mgr->spool != NULL) {
|
||||
isc_mempool_destroy(&mgr->spool);
|
||||
}
|
||||
|
||||
isc_mutex_destroy(&mgr->spool_lock);
|
||||
isc_mutex_destroy(&mgr->bpool_lock);
|
||||
isc_mutex_destroy(&mgr->dpool_lock);
|
||||
isc_mutex_destroy(&mgr->rpool_lock);
|
||||
isc_mutex_destroy(&mgr->depool_lock);
|
||||
|
||||
if (mgr->qid != NULL) {
|
||||
qid_destroy(mgr->mctx, &mgr->qid);
|
||||
}
|
||||
@@ -1791,61 +1733,17 @@ dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp) {
|
||||
REQUIRE(mgrp != NULL && *mgrp == NULL);
|
||||
|
||||
mgr = isc_mem_get(mctx, sizeof(dns_dispatchmgr_t));
|
||||
*mgr = (dns_dispatchmgr_t){ 0 };
|
||||
|
||||
mgr->mctx = NULL;
|
||||
isc_mem_attach(mctx, &mgr->mctx);
|
||||
|
||||
mgr->blackhole = NULL;
|
||||
mgr->stats = NULL;
|
||||
|
||||
isc_mutex_init(&mgr->lock);
|
||||
isc_mutex_init(&mgr->buffer_lock);
|
||||
isc_mutex_init(&mgr->depool_lock);
|
||||
isc_mutex_init(&mgr->rpool_lock);
|
||||
isc_mutex_init(&mgr->dpool_lock);
|
||||
isc_mutex_init(&mgr->bpool_lock);
|
||||
isc_mutex_init(&mgr->spool_lock);
|
||||
|
||||
mgr->depool = NULL;
|
||||
isc_mempool_create(mgr->mctx, sizeof(dns_dispatchevent_t),
|
||||
&mgr->depool);
|
||||
isc_refcount_init(&mgr->irefs, 0);
|
||||
|
||||
mgr->rpool = NULL;
|
||||
isc_mempool_create(mgr->mctx, sizeof(dns_dispentry_t), &mgr->rpool);
|
||||
|
||||
mgr->dpool = NULL;
|
||||
isc_mempool_create(mgr->mctx, sizeof(dns_dispatch_t), &mgr->dpool);
|
||||
|
||||
isc_mempool_setname(mgr->depool, "dispmgr_depool");
|
||||
isc_mempool_setmaxalloc(mgr->depool, 32768);
|
||||
isc_mempool_setfreemax(mgr->depool, 32768);
|
||||
isc_mempool_associatelock(mgr->depool, &mgr->depool_lock);
|
||||
isc_mempool_setfillcount(mgr->depool, 32);
|
||||
|
||||
isc_mempool_setname(mgr->rpool, "dispmgr_rpool");
|
||||
isc_mempool_setmaxalloc(mgr->rpool, 32768);
|
||||
isc_mempool_setfreemax(mgr->rpool, 32768);
|
||||
isc_mempool_associatelock(mgr->rpool, &mgr->rpool_lock);
|
||||
isc_mempool_setfillcount(mgr->rpool, 32);
|
||||
|
||||
isc_mempool_setname(mgr->dpool, "dispmgr_dpool");
|
||||
isc_mempool_setmaxalloc(mgr->dpool, 32768);
|
||||
isc_mempool_setfreemax(mgr->dpool, 32768);
|
||||
isc_mempool_associatelock(mgr->dpool, &mgr->dpool_lock);
|
||||
isc_mempool_setfillcount(mgr->dpool, 32);
|
||||
|
||||
mgr->buffers = 0;
|
||||
mgr->buffersize = 0;
|
||||
mgr->maxbuffers = 0;
|
||||
mgr->bpool = NULL;
|
||||
mgr->spool = NULL;
|
||||
mgr->qid = NULL;
|
||||
mgr->state = 0;
|
||||
ISC_LIST_INIT(mgr->list);
|
||||
mgr->v4ports = NULL;
|
||||
mgr->v6ports = NULL;
|
||||
mgr->nv4ports = 0;
|
||||
mgr->nv6ports = 0;
|
||||
|
||||
mgr->magic = DNS_DISPATCHMGR_MAGIC;
|
||||
|
||||
result = create_default_portset(mctx, &v4portset);
|
||||
@@ -1870,14 +1768,6 @@ dns_dispatchmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t **mgrp) {
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
kill_dpool:
|
||||
isc_mempool_destroy(&mgr->dpool);
|
||||
isc_mempool_destroy(&mgr->rpool);
|
||||
isc_mempool_destroy(&mgr->depool);
|
||||
isc_mutex_destroy(&mgr->spool_lock);
|
||||
isc_mutex_destroy(&mgr->bpool_lock);
|
||||
isc_mutex_destroy(&mgr->dpool_lock);
|
||||
isc_mutex_destroy(&mgr->rpool_lock);
|
||||
isc_mutex_destroy(&mgr->depool_lock);
|
||||
isc_mutex_destroy(&mgr->buffer_lock);
|
||||
isc_mutex_destroy(&mgr->lock);
|
||||
isc_mem_putanddetach(&mctx, mgr, sizeof(dns_dispatchmgr_t));
|
||||
@@ -1965,6 +1855,7 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr, unsigned int buffersize,
|
||||
REQUIRE(maxbuffers > 0);
|
||||
REQUIRE(buckets < 2097169); /* next prime > 65536 * 32 */
|
||||
REQUIRE(increment > buckets);
|
||||
UNUSED(maxrequests);
|
||||
|
||||
/*
|
||||
* Keep some number of items around. This should be a config
|
||||
@@ -1985,48 +1876,15 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr, unsigned int buffersize,
|
||||
|
||||
LOCK(&mgr->buffer_lock);
|
||||
|
||||
/* Create or adjust buffer pool */
|
||||
if (mgr->bpool != NULL) {
|
||||
/*
|
||||
* We only increase the maxbuffers to avoid accidental buffer
|
||||
* shortage. Ideally we'd separate the manager-wide maximum
|
||||
* from per-dispatch limits and respect the latter within the
|
||||
* global limit. But at this moment that's deemed to be
|
||||
* overkilling and isn't worth additional implementation
|
||||
* complexity.
|
||||
*/
|
||||
if (maxbuffers > mgr->maxbuffers) {
|
||||
isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
|
||||
isc_mempool_setfreemax(mgr->bpool, maxbuffers);
|
||||
mgr->maxbuffers = maxbuffers;
|
||||
}
|
||||
} else {
|
||||
isc_mempool_create(mgr->mctx, buffersize, &mgr->bpool);
|
||||
isc_mempool_setname(mgr->bpool, "dispmgr_bpool");
|
||||
isc_mempool_setmaxalloc(mgr->bpool, maxbuffers);
|
||||
isc_mempool_setfreemax(mgr->bpool, maxbuffers);
|
||||
isc_mempool_associatelock(mgr->bpool, &mgr->bpool_lock);
|
||||
isc_mempool_setfillcount(mgr->bpool, 32);
|
||||
if (maxbuffers > mgr->maxbuffers) {
|
||||
mgr->maxbuffers = maxbuffers;
|
||||
}
|
||||
|
||||
/* Create or adjust socket pool */
|
||||
if (mgr->spool != NULL) {
|
||||
if (maxrequests < DNS_DISPATCH_POOLSOCKS * 2) {
|
||||
isc_mempool_setmaxalloc(mgr->spool,
|
||||
DNS_DISPATCH_POOLSOCKS * 2);
|
||||
isc_mempool_setfreemax(mgr->spool,
|
||||
DNS_DISPATCH_POOLSOCKS * 2);
|
||||
}
|
||||
if (mgr->qid != NULL) {
|
||||
UNLOCK(&mgr->buffer_lock);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
isc_mempool_create(mgr->mctx, sizeof(dispsocket_t), &mgr->spool);
|
||||
|
||||
isc_mempool_setname(mgr->spool, "dispmgr_spool");
|
||||
isc_mempool_setmaxalloc(mgr->spool, maxrequests);
|
||||
isc_mempool_setfreemax(mgr->spool, maxrequests);
|
||||
isc_mempool_associatelock(mgr->spool, &mgr->spool_lock);
|
||||
isc_mempool_setfillcount(mgr->spool, 32);
|
||||
|
||||
result = qid_allocate(mgr, buckets, increment, &mgr->qid, true);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
@@ -2039,10 +1897,6 @@ dns_dispatchmgr_setudp(dns_dispatchmgr_t *mgr, unsigned int buffersize,
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
isc_mempool_destroy(&mgr->bpool);
|
||||
if (mgr->spool != NULL) {
|
||||
isc_mempool_destroy(&mgr->spool);
|
||||
}
|
||||
UNLOCK(&mgr->buffer_lock);
|
||||
return (result);
|
||||
}
|
||||
@@ -2137,101 +1991,6 @@ unlock:
|
||||
|
||||
#define ATTRMATCH(_a1, _a2, _mask) (((_a1) & (_mask)) == ((_a2) & (_mask)))
|
||||
|
||||
static bool
|
||||
local_addr_match(dns_dispatch_t *disp, const isc_sockaddr_t *addr) {
|
||||
isc_sockaddr_t sockaddr;
|
||||
isc_result_t result;
|
||||
|
||||
REQUIRE(disp->socket != NULL);
|
||||
|
||||
if (addr == NULL) {
|
||||
return (true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't match wildcard ports unless the port is available in the
|
||||
* current configuration.
|
||||
*/
|
||||
if (isc_sockaddr_getport(addr) == 0 &&
|
||||
isc_sockaddr_getport(&disp->local) == 0 &&
|
||||
!portavailable(disp->mgr, disp->socket, NULL))
|
||||
{
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we match the binding <address,port>.
|
||||
* Wildcard ports match/fail here.
|
||||
*/
|
||||
if (isc_sockaddr_equal(&disp->local, addr)) {
|
||||
return (true);
|
||||
}
|
||||
if (isc_sockaddr_getport(addr) == 0) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we match a bound wildcard port <address,port>.
|
||||
*/
|
||||
if (!isc_sockaddr_eqaddr(&disp->local, addr)) {
|
||||
return (false);
|
||||
}
|
||||
result = isc_socket_getsockname(disp->socket, &sockaddr);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (isc_sockaddr_equal(&sockaddr, addr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Requires mgr be locked.
|
||||
*
|
||||
* No dispatcher can be locked by this thread when calling this function.
|
||||
*
|
||||
*
|
||||
* NOTE:
|
||||
* If a matching dispatcher is found, it is locked after this function
|
||||
* returns, and must be unlocked by the caller.
|
||||
*/
|
||||
static isc_result_t
|
||||
dispatch_find(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *local,
|
||||
unsigned int attributes, unsigned int mask,
|
||||
dns_dispatch_t **dispp) {
|
||||
dns_dispatch_t *disp;
|
||||
isc_result_t result;
|
||||
|
||||
/*
|
||||
* Make certain that we will not match a private or exclusive dispatch.
|
||||
*/
|
||||
attributes &= ~(DNS_DISPATCHATTR_PRIVATE | DNS_DISPATCHATTR_EXCLUSIVE);
|
||||
mask |= (DNS_DISPATCHATTR_PRIVATE | DNS_DISPATCHATTR_EXCLUSIVE);
|
||||
|
||||
disp = ISC_LIST_HEAD(mgr->list);
|
||||
while (disp != NULL) {
|
||||
LOCK(&disp->lock);
|
||||
if ((disp->shutting_down == 0) &&
|
||||
ATTRMATCH(disp->attributes, attributes, mask) &&
|
||||
local_addr_match(disp, local))
|
||||
{
|
||||
break;
|
||||
}
|
||||
UNLOCK(&disp->lock);
|
||||
disp = ISC_LIST_NEXT(disp, link);
|
||||
}
|
||||
|
||||
if (disp == NULL) {
|
||||
result = ISC_R_NOTFOUND;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*dispp = disp;
|
||||
result = ISC_R_SUCCESS;
|
||||
out:
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
qid_allocate(dns_dispatchmgr_t *mgr, unsigned int buckets,
|
||||
unsigned int increment, dns_qid_t **qidp, bool needsocktable) {
|
||||
@@ -2308,10 +2067,8 @@ dispatch_allocate(dns_dispatchmgr_t *mgr, unsigned int maxrequests,
|
||||
* the options that are controlled by tcp vs. udp, etc.
|
||||
*/
|
||||
|
||||
disp = isc_mempool_get(mgr->dpool);
|
||||
if (disp == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
disp = isc_mem_get(mgr->mctx, sizeof(*disp));
|
||||
isc_refcount_increment0(&mgr->irefs);
|
||||
|
||||
disp->magic = 0;
|
||||
disp->mgr = mgr;
|
||||
@@ -2335,7 +2092,6 @@ dispatch_allocate(dns_dispatchmgr_t *mgr, unsigned int maxrequests,
|
||||
ISC_LIST_INIT(disp->inactivesockets);
|
||||
disp->nsockets = 0;
|
||||
disp->port_table = NULL;
|
||||
disp->portpool = NULL;
|
||||
disp->dscp = -1;
|
||||
|
||||
isc_mutex_init(&disp->lock);
|
||||
@@ -2356,7 +2112,8 @@ dispatch_allocate(dns_dispatchmgr_t *mgr, unsigned int maxrequests,
|
||||
*/
|
||||
kill_lock:
|
||||
isc_mutex_destroy(&disp->lock);
|
||||
isc_mempool_put(mgr->dpool, disp);
|
||||
isc_refcount_decrement(&mgr->irefs);
|
||||
isc_mem_put(mgr->mctx, disp, sizeof(*disp));
|
||||
|
||||
return (result);
|
||||
}
|
||||
@@ -2387,7 +2144,8 @@ dispatch_free(dns_dispatch_t **dispp) {
|
||||
INSIST(ISC_LIST_EMPTY(disp->activesockets));
|
||||
INSIST(ISC_LIST_EMPTY(disp->inactivesockets));
|
||||
|
||||
isc_mempool_put(mgr->depool, disp->failsafe_ev);
|
||||
isc_refcount_decrement(&mgr->irefs);
|
||||
isc_mem_put(mgr->mctx, disp->failsafe_ev, sizeof(*disp->failsafe_ev));
|
||||
disp->failsafe_ev = NULL;
|
||||
|
||||
if (disp->qid != NULL) {
|
||||
@@ -2403,14 +2161,11 @@ dispatch_free(dns_dispatch_t **dispp) {
|
||||
DNS_DISPATCH_PORTTABLESIZE);
|
||||
}
|
||||
|
||||
if (disp->portpool != NULL) {
|
||||
isc_mempool_destroy(&disp->portpool);
|
||||
}
|
||||
|
||||
disp->mgr = NULL;
|
||||
isc_mutex_destroy(&disp->lock);
|
||||
disp->magic = 0;
|
||||
isc_mempool_put(mgr->dpool, disp);
|
||||
isc_refcount_decrement(&mgr->irefs);
|
||||
isc_mem_put(mgr->mctx, disp, sizeof(*disp));
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -2600,13 +2355,12 @@ dns_dispatch_gettcp(dns_dispatchmgr_t *mgr, const isc_sockaddr_t *destaddr,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_dispatch_getudp_dup(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr,
|
||||
unsigned int buffersize, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment, unsigned int attributes,
|
||||
unsigned int mask, dns_dispatch_t **dispp,
|
||||
dns_dispatch_t *dup_dispatch) {
|
||||
dns_dispatch_getudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr,
|
||||
unsigned int buffersize, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment, unsigned int attributes,
|
||||
dns_dispatch_t **dispp) {
|
||||
isc_result_t result;
|
||||
dns_dispatch_t *disp = NULL;
|
||||
|
||||
@@ -2634,46 +2388,12 @@ dns_dispatch_getudp_dup(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
goto createudp;
|
||||
}
|
||||
|
||||
/*
|
||||
* See if we have a dispatcher that matches.
|
||||
*/
|
||||
if (dup_dispatch == NULL) {
|
||||
result = dispatch_find(mgr, localaddr, attributes, mask, &disp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
disp->refcount++;
|
||||
|
||||
if (disp->maxrequests < maxrequests) {
|
||||
disp->maxrequests = maxrequests;
|
||||
}
|
||||
|
||||
if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) ==
|
||||
0 &&
|
||||
(attributes & DNS_DISPATCHATTR_NOLISTEN) != 0)
|
||||
{
|
||||
disp->attributes |= DNS_DISPATCHATTR_NOLISTEN;
|
||||
if (disp->recv_pending != 0) {
|
||||
isc_socket_cancel(disp->socket,
|
||||
disp->task[0],
|
||||
ISC_SOCKCANCEL_RECV);
|
||||
}
|
||||
}
|
||||
|
||||
UNLOCK(&disp->lock);
|
||||
UNLOCK(&mgr->lock);
|
||||
|
||||
*dispp = disp;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
createudp:
|
||||
/*
|
||||
* Nope, create one.
|
||||
*/
|
||||
result = dispatch_createudp(
|
||||
mgr, sockmgr, taskmgr, localaddr, maxrequests, attributes,
|
||||
&disp, dup_dispatch == NULL ? NULL : dup_dispatch->socket);
|
||||
result = dispatch_createudp(mgr, sockmgr, taskmgr, localaddr,
|
||||
maxrequests, attributes, &disp, NULL);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNLOCK(&mgr->lock);
|
||||
@@ -2686,19 +2406,6 @@ createudp:
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_dispatch_getudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr,
|
||||
unsigned int buffersize, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment, unsigned int attributes,
|
||||
unsigned int mask, dns_dispatch_t **dispp) {
|
||||
return (dns_dispatch_getudp_dup(mgr, sockmgr, taskmgr, localaddr,
|
||||
buffersize, maxbuffers, maxrequests,
|
||||
buckets, increment, attributes, mask,
|
||||
dispp, NULL));
|
||||
}
|
||||
|
||||
/*
|
||||
* mgr should be locked.
|
||||
*/
|
||||
@@ -2886,11 +2593,6 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
for (i = 0; i < DNS_DISPATCH_PORTTABLESIZE; i++) {
|
||||
ISC_LIST_INIT(disp->port_table[i]);
|
||||
}
|
||||
|
||||
isc_mempool_create(mgr->mctx, sizeof(dispportentry_t),
|
||||
&disp->portpool);
|
||||
isc_mempool_setname(disp->portpool, "disp_portpool");
|
||||
isc_mempool_setfreemax(disp->portpool, 128);
|
||||
}
|
||||
disp->socket = sock;
|
||||
disp->local = *localaddr;
|
||||
@@ -2918,15 +2620,8 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
destroy_disp, disp, sizeof(isc_event_t));
|
||||
|
||||
disp->sepool = NULL;
|
||||
isc_mempool_create(mgr->mctx, sizeof(isc_socketevent_t), &disp->sepool);
|
||||
|
||||
isc_mutex_init(&disp->sepool_lock);
|
||||
|
||||
isc_mempool_setname(disp->sepool, "disp_sepool");
|
||||
isc_mempool_setmaxalloc(disp->sepool, 32768);
|
||||
isc_mempool_setfreemax(disp->sepool, 32768);
|
||||
isc_mempool_associatelock(disp->sepool, &disp->sepool_lock);
|
||||
isc_mempool_setfillcount(disp->sepool, 16);
|
||||
isc_mem_create(&disp->sepool);
|
||||
isc_mem_setname(disp->sepool, "disp_sepool");
|
||||
|
||||
attributes &= ~DNS_DISPATCHATTR_TCP;
|
||||
attributes |= DNS_DISPATCHATTR_UDP;
|
||||
@@ -3142,14 +2837,8 @@ dns_dispatch_addresponse(dns_dispatch_t *disp, unsigned int options,
|
||||
return (ISC_R_NOMORE);
|
||||
}
|
||||
|
||||
res = isc_mempool_get(disp->mgr->rpool);
|
||||
if (res == NULL) {
|
||||
if (dispsocket != NULL) {
|
||||
destroy_dispsocket(disp, &dispsocket);
|
||||
}
|
||||
UNLOCK(&disp->lock);
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
res = isc_mem_get(disp->mgr->mctx, sizeof(*res));
|
||||
isc_refcount_increment0(&disp->mgr->irefs);
|
||||
|
||||
disp->refcount++;
|
||||
disp->requests++;
|
||||
@@ -3204,7 +2893,8 @@ dns_dispatch_addresponse(dns_dispatch_t *disp, unsigned int options,
|
||||
|
||||
UNLOCK(&disp->lock);
|
||||
isc_task_detach(&res->task);
|
||||
isc_mempool_put(disp->mgr->rpool, res);
|
||||
isc_refcount_decrement(&disp->mgr->irefs);
|
||||
isc_mem_put(disp->mgr->mctx, res, sizeof(*res));
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
@@ -3392,7 +3082,8 @@ dns_dispatch_removeresponse(dns_dispentry_t **resp,
|
||||
ev = ISC_LIST_HEAD(res->items);
|
||||
}
|
||||
res->magic = 0;
|
||||
isc_mempool_put(disp->mgr->rpool, res);
|
||||
isc_refcount_decrement(&disp->mgr->irefs);
|
||||
isc_mem_put(disp->mgr->mctx, res, sizeof(*res));
|
||||
if (disp->shutting_down == 1) {
|
||||
do_cancel(disp);
|
||||
} else {
|
||||
|
||||
@@ -229,16 +229,7 @@ dns_dispatch_getudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
unsigned int buffersize, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment, unsigned int attributes,
|
||||
unsigned int mask, dns_dispatch_t **dispp);
|
||||
|
||||
isc_result_t
|
||||
dns_dispatch_getudp_dup(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
|
||||
isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr,
|
||||
unsigned int buffersize, unsigned int maxbuffers,
|
||||
unsigned int maxrequests, unsigned int buckets,
|
||||
unsigned int increment, unsigned int attributes,
|
||||
unsigned int mask, dns_dispatch_t **dispp,
|
||||
dns_dispatch_t *dup);
|
||||
dns_dispatch_t **dispp);
|
||||
/*%<
|
||||
* Attach to existing dns_dispatch_t if one is found with dns_dispatchmgr_find,
|
||||
* otherwise create a new UDP dispatch.
|
||||
|
||||
@@ -899,7 +899,6 @@ dns_message_gettempname(dns_message_t *msg, dns_name_t **item);
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- All is well.
|
||||
*\li #ISC_R_NOMEMORY -- No item can be allocated.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
@@ -916,7 +915,6 @@ dns_message_gettemprdata(dns_message_t *msg, dns_rdata_t **item);
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- All is well.
|
||||
*\li #ISC_R_NOMEMORY -- No item can be allocated.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
@@ -934,7 +932,6 @@ dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item);
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- All is well.
|
||||
*\li #ISC_R_NOMEMORY -- No item can be allocated.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
@@ -951,7 +948,6 @@ dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item);
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- All is well.
|
||||
*\li #ISC_R_NOMEMORY -- No item can be allocated.
|
||||
*/
|
||||
|
||||
void
|
||||
|
||||
+1
-39
@@ -295,10 +295,6 @@ newrdata(dns_message_t *msg) {
|
||||
if (rdata == NULL) {
|
||||
msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdata_t),
|
||||
RDATA_COUNT);
|
||||
if (msgblock == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ISC_LIST_APPEND(msg->rdatas, msgblock, link);
|
||||
|
||||
rdata = msgblock_get(msgblock, dns_rdata_t);
|
||||
@@ -329,19 +325,12 @@ newrdatalist(dns_message_t *msg) {
|
||||
if (rdatalist == NULL) {
|
||||
msgblock = msgblock_allocate(msg->mctx, sizeof(dns_rdatalist_t),
|
||||
RDATALIST_COUNT);
|
||||
if (msgblock == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ISC_LIST_APPEND(msg->rdatalists, msgblock, link);
|
||||
|
||||
rdatalist = msgblock_get(msgblock, dns_rdatalist_t);
|
||||
}
|
||||
out:
|
||||
if (rdatalist != NULL) {
|
||||
dns_rdatalist_init(rdatalist);
|
||||
}
|
||||
|
||||
dns_rdatalist_init(rdatalist);
|
||||
return (rdatalist);
|
||||
}
|
||||
|
||||
@@ -355,10 +344,6 @@ newoffsets(dns_message_t *msg) {
|
||||
if (offsets == NULL) {
|
||||
msgblock = msgblock_allocate(msg->mctx, sizeof(dns_offsets_t),
|
||||
OFFSET_COUNT);
|
||||
if (msgblock == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
ISC_LIST_APPEND(msg->offsets, msgblock, link);
|
||||
|
||||
offsets = msgblock_get(msgblock, dns_offsets_t);
|
||||
@@ -1076,10 +1061,6 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
|
||||
goto cleanup;
|
||||
}
|
||||
rdataset = isc_mempool_get(msg->rdspool);
|
||||
if (rdataset == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert rdatalist to rdataset, and attach the latter to
|
||||
@@ -1516,10 +1497,6 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
|
||||
|
||||
if (result == ISC_R_NOTFOUND) {
|
||||
rdataset = isc_mempool_get(msg->rdspool);
|
||||
if (rdataset == NULL) {
|
||||
result = ISC_R_NOMEMORY;
|
||||
goto cleanup;
|
||||
}
|
||||
free_rdataset = true;
|
||||
|
||||
rdatalist = newrdatalist(msg);
|
||||
@@ -2531,9 +2508,6 @@ dns_message_gettempname(dns_message_t *msg, dns_name_t **item) {
|
||||
REQUIRE(item != NULL && *item == NULL);
|
||||
|
||||
fn = isc_mempool_get(msg->namepool);
|
||||
if (fn == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
*item = dns_fixedname_initname(fn);
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -2545,10 +2519,6 @@ dns_message_gettemprdata(dns_message_t *msg, dns_rdata_t **item) {
|
||||
REQUIRE(item != NULL && *item == NULL);
|
||||
|
||||
*item = newrdata(msg);
|
||||
if (*item == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -2558,10 +2528,6 @@ dns_message_gettemprdataset(dns_message_t *msg, dns_rdataset_t **item) {
|
||||
REQUIRE(item != NULL && *item == NULL);
|
||||
|
||||
*item = isc_mempool_get(msg->rdspool);
|
||||
if (*item == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
dns_rdataset_init(*item);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -2572,10 +2538,6 @@ dns_message_gettemprdatalist(dns_message_t *msg, dns_rdatalist_t **item) {
|
||||
REQUIRE(item != NULL && *item == NULL);
|
||||
|
||||
*item = newrdatalist(msg);
|
||||
if (*item == NULL) {
|
||||
return (ISC_R_NOMEMORY);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
+2
-7
@@ -593,7 +593,7 @@ static isc_result_t
|
||||
find_udp_dispatch(dns_requestmgr_t *requestmgr, const isc_sockaddr_t *srcaddr,
|
||||
const isc_sockaddr_t *destaddr, dns_dispatch_t **dispatchp) {
|
||||
dns_dispatch_t *disp = NULL;
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
|
||||
if (srcaddr == NULL) {
|
||||
switch (isc_sockaddr_pf(destaddr)) {
|
||||
@@ -628,15 +628,10 @@ find_udp_dispatch(dns_requestmgr_t *requestmgr, const isc_sockaddr_t *srcaddr,
|
||||
default:
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
}
|
||||
attrmask = 0;
|
||||
attrmask |= DNS_DISPATCHATTR_UDP;
|
||||
attrmask |= DNS_DISPATCHATTR_TCP;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV4;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV6;
|
||||
return (dns_dispatch_getudp(requestmgr->dispatchmgr,
|
||||
requestmgr->socketmgr, requestmgr->taskmgr,
|
||||
srcaddr, 4096, 32768, 32768, 16411, 16433,
|
||||
attrs, attrmask, dispatchp));
|
||||
attrs, dispatchp));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
|
||||
+2
-6
@@ -2158,7 +2158,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
|
||||
*/
|
||||
} else {
|
||||
if (have_addr) {
|
||||
unsigned int attrs, attrmask;
|
||||
unsigned int attrs;
|
||||
attrs = DNS_DISPATCHATTR_UDP;
|
||||
switch (isc_sockaddr_pf(&addr)) {
|
||||
case AF_INET:
|
||||
@@ -2173,14 +2173,10 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
|
||||
result = ISC_R_NOTIMPLEMENTED;
|
||||
goto cleanup_query;
|
||||
}
|
||||
attrmask = DNS_DISPATCHATTR_UDP;
|
||||
attrmask |= DNS_DISPATCHATTR_TCP;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV4;
|
||||
attrmask |= DNS_DISPATCHATTR_IPV6;
|
||||
result = dns_dispatch_getudp(
|
||||
res->dispatchmgr, res->socketmgr, res->taskmgr,
|
||||
&addr, 4096, 20000, 32768, 16411, 16433, attrs,
|
||||
attrmask, &query->dispatch);
|
||||
&query->dispatch);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_query;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ make_dispatchset(unsigned int ndisps) {
|
||||
isc_sockaddr_any(&any);
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &any, 512,
|
||||
6, 1024, 17, 19, attrs, attrs, &disp);
|
||||
6, 1024, 17, 19, attrs, &disp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
@@ -275,8 +275,7 @@ dispatch_getnext(void **state) {
|
||||
isc_sockaddr_fromin(&local, &ina, 0);
|
||||
attrs = DNS_DISPATCHATTR_IPV4 | DNS_DISPATCHATTR_UDP;
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &local,
|
||||
512, 6, 1024, 17, 19, attrs, attrs,
|
||||
&dispatch);
|
||||
512, 6, 1024, 17, 19, attrs, &dispatch);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
|
||||
@@ -58,7 +58,7 @@ _setup(void **state) {
|
||||
|
||||
isc_sockaddr_any(&local);
|
||||
result = dns_dispatch_getudp(dispatchmgr, socketmgr, taskmgr, &local,
|
||||
4096, 100, 100, 100, 500, 0, 0, &dispatch);
|
||||
4096, 100, 100, 100, 500, 0, &dispatch);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
return (0);
|
||||
|
||||
@@ -167,6 +167,7 @@ libisc_la_SOURCES = \
|
||||
httpd.c \
|
||||
interfaceiter.c \
|
||||
iterated_hash.c \
|
||||
jemalloc_shim.h \
|
||||
lex.c \
|
||||
lib.c \
|
||||
log.c \
|
||||
@@ -230,6 +231,7 @@ libisc_la_SOURCES = \
|
||||
|
||||
libisc_la_CPPFLAGS = \
|
||||
$(AM_CPPFLAGS) \
|
||||
$(JEMALLOC_CPPFLAGS) \
|
||||
$(LIBISC_CFLAGS) \
|
||||
$(LIBUV_CFLAGS) \
|
||||
$(OPENSSL_CFLAGS) \
|
||||
@@ -240,6 +242,7 @@ libisc_la_LDFLAGS = \
|
||||
-release "$(PACKAGE_VERSION)"
|
||||
|
||||
libisc_la_LIBADD = \
|
||||
$(JEMALLOC_LIBS) \
|
||||
$(LIBUV_LIBS) \
|
||||
$(OPENSSL_LIBS) \
|
||||
$(ZLIB_LIBS)
|
||||
|
||||
+21
-71
@@ -43,8 +43,6 @@ extern unsigned int isc_mem_defaultflags;
|
||||
#define ISC_MEM_DEBUGTRACE 0x00000001U
|
||||
#define ISC_MEM_DEBUGRECORD 0x00000002U
|
||||
#define ISC_MEM_DEBUGUSAGE 0x00000004U
|
||||
#define ISC_MEM_DEBUGSIZE 0x00000008U
|
||||
#define ISC_MEM_DEBUGCTX 0x00000010U
|
||||
#define ISC_MEM_DEBUGALL 0x0000001FU
|
||||
/*!<
|
||||
* The variable isc_mem_debugging holds a set of flags for
|
||||
@@ -63,14 +61,6 @@ extern unsigned int isc_mem_defaultflags;
|
||||
* \li #ISC_MEM_DEBUGUSAGE
|
||||
* If a hi_water mark is set, print the maximum inuse memory
|
||||
* every time it is raised once it exceeds the hi_water mark.
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGSIZE
|
||||
* Check the size argument being passed to isc_mem_put() matches
|
||||
* that passed to isc_mem_get().
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGCTX
|
||||
* Check the mctx argument being passed to isc_mem_put() matches
|
||||
* that passed to isc_mem_get().
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
@@ -175,8 +165,8 @@ extern unsigned int isc_mem_defaultflags;
|
||||
} while (0)
|
||||
|
||||
/*@{*/
|
||||
void
|
||||
isc_mem_create(isc_mem_t **mctxp);
|
||||
#define isc_mem_create(cp) ISCMEMFUNC(create)((cp)_ISC_MEM_FILELINE)
|
||||
void ISCMEMFUNC(create)(isc_mem_t **_ISC_MEM_FLARG);
|
||||
|
||||
/*!<
|
||||
* \brief Create a memory context.
|
||||
@@ -188,8 +178,8 @@ isc_mem_create(isc_mem_t **mctxp);
|
||||
/*@{*/
|
||||
void
|
||||
isc_mem_attach(isc_mem_t *, isc_mem_t **);
|
||||
void
|
||||
isc_mem_detach(isc_mem_t **);
|
||||
#define isc_mem_detach(cp) ISCMEMFUNC(detach)((cp)_ISC_MEM_FILELINE)
|
||||
void ISCMEMFUNC(detach)(isc_mem_t **_ISC_MEM_FLARG);
|
||||
/*!<
|
||||
* \brief Attach to / detach from a memory context.
|
||||
*
|
||||
@@ -204,8 +194,8 @@ isc_mem_detach(isc_mem_t **);
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
void
|
||||
isc_mem_destroy(isc_mem_t **);
|
||||
#define isc_mem_destroy(cp) ISCMEMFUNC(destroy)((cp)_ISC_MEM_FILELINE)
|
||||
void ISCMEMFUNC(destroy)(isc_mem_t **_ISC_MEM_FLARG);
|
||||
/*%<
|
||||
* Destroy a memory context.
|
||||
*/
|
||||
@@ -371,8 +361,11 @@ isc_mem_renderjson(void *memobj0);
|
||||
* Memory pools
|
||||
*/
|
||||
|
||||
#define isc_mempool_create(c, s, mp) \
|
||||
isc__mempool_create((c), (s), (mp)_ISC_MEM_FILELINE)
|
||||
void
|
||||
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
|
||||
isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
||||
isc_mempool_t **mpctxp _ISC_MEM_FLARG);
|
||||
/*%<
|
||||
* Create a memory pool.
|
||||
*
|
||||
@@ -382,7 +375,6 @@ isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
|
||||
*\li mpctxp != NULL and *mpctxp == NULL
|
||||
*
|
||||
* Defaults:
|
||||
*\li maxalloc = UINT_MAX
|
||||
*\li freemax = 1
|
||||
*\li fillcount = 1
|
||||
*
|
||||
@@ -391,8 +383,9 @@ isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
|
||||
*\li #ISC_R_SUCCESS -- all is well.
|
||||
*/
|
||||
|
||||
#define isc_mempool_destroy(mp) isc__mempool_destroy((mp)_ISC_MEM_FILELINE)
|
||||
void
|
||||
isc_mempool_destroy(isc_mempool_t **mpctxp);
|
||||
isc__mempool_destroy(isc_mempool_t **restrict mpctxp _ISC_MEM_FLARG);
|
||||
/*%<
|
||||
* Destroy a memory pool.
|
||||
*
|
||||
@@ -402,7 +395,7 @@ isc_mempool_destroy(isc_mempool_t **mpctxp);
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setname(isc_mempool_t *mpctx, const char *name);
|
||||
isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name);
|
||||
/*%<
|
||||
* Associate a name with a memory pool. At most 15 characters may be
|
||||
*used.
|
||||
@@ -412,95 +405,52 @@ isc_mempool_setname(isc_mempool_t *mpctx, const char *name);
|
||||
*\li name != NULL;
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_associatelock(isc_mempool_t *mpctx, isc_mutex_t *lock);
|
||||
/*%<
|
||||
* Associate a lock with this memory pool.
|
||||
*
|
||||
* This lock is used when getting or putting items using this memory
|
||||
*pool, and it is also used to set or get internal state via the
|
||||
*isc_mempool_get*() and isc_mempool_set*() set of functions.
|
||||
*
|
||||
* Multiple pools can each share a single lock. For instance, if
|
||||
*"manager" type object contained pools for various sizes of events, and
|
||||
*each of these pools used a common lock. Note that this lock must
|
||||
*NEVER be used by other than mempool routines once it is given to a
|
||||
*pool, since that can easily cause double locking.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li mpctpx is a valid pool.
|
||||
*
|
||||
*\li lock != NULL.
|
||||
*
|
||||
*\li No previous lock is assigned to this pool.
|
||||
*
|
||||
*\li The lock is initialized before calling this function via the
|
||||
*normal means of doing that.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following functions get/set various parameters. Note that due to
|
||||
* the unlocked nature of pools these are potentially random values
|
||||
*unless the imposed externally provided locking protocols are followed.
|
||||
*
|
||||
* Also note that the quota limits will not always take immediate
|
||||
*effect. For instance, setting "maxalloc" to a number smaller than the
|
||||
*currently allocated count is permitted. New allocations will be
|
||||
*refused until the count drops below this threshold.
|
||||
* effect.
|
||||
*
|
||||
* All functions require (in addition to other requirements):
|
||||
* mpctx is a valid memory pool
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfreemax(isc_mempool_t *mpctx);
|
||||
isc_mempool_getfreemax(isc_mempool_t *restrict mpctx);
|
||||
/*%<
|
||||
* Returns the maximum allowed size of the free list.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit);
|
||||
isc_mempool_setfreemax(isc_mempool_t *restrict mpctx, const unsigned int limit);
|
||||
/*%<
|
||||
* Sets the maximum allowed size of the free list.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfreecount(isc_mempool_t *mpctx);
|
||||
isc_mempool_getfreecount(isc_mempool_t *restrict mpctx);
|
||||
/*%<
|
||||
* Returns current size of the free list.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getmaxalloc(isc_mempool_t *mpctx);
|
||||
/*!<
|
||||
* Returns the maximum allowed number of allocations.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit);
|
||||
/*%<
|
||||
* Sets the maximum allowed number of allocations.
|
||||
*
|
||||
* Additional requirements:
|
||||
*\li limit > 0
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getallocated(isc_mempool_t *mpctx);
|
||||
isc_mempool_getallocated(isc_mempool_t *restrict mpctx);
|
||||
/*%<
|
||||
* Returns the number of items allocated from this pool.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfillcount(isc_mempool_t *mpctx);
|
||||
isc_mempool_getfillcount(isc_mempool_t *restrict mpctx);
|
||||
/*%<
|
||||
* Returns the number of items allocated as a block from the parent
|
||||
* memory context when the free list is empty.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit);
|
||||
isc_mempool_setfillcount(isc_mempool_t *restrict mpctx,
|
||||
const unsigned int limit);
|
||||
/*%<
|
||||
* Sets the fillcount.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(HAVE_JEMALLOC)
|
||||
|
||||
#include <isc/util.h>
|
||||
|
||||
const char *malloc_conf = NULL;
|
||||
|
||||
#if defined(HAVE_MALLOC_SIZE) || defined(HAVE_MALLOC_USABLE_SIZE)
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static inline void *
|
||||
mallocx(size_t size, int flags) {
|
||||
UNUSED(flags);
|
||||
void *__ptr = malloc(size);
|
||||
REQUIRE(__ptr != NULL);
|
||||
return (__ptr);
|
||||
}
|
||||
|
||||
static inline void
|
||||
sdallocx(void *ptr, size_t size, int flags) {
|
||||
UNUSED(size);
|
||||
UNUSED(flags);
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
rallocx(void *ptr, size_t size, int flags) {
|
||||
UNUSED(flags);
|
||||
REQUIRE(size != 0);
|
||||
|
||||
void *__ptr = realloc(ptr, size);
|
||||
REQUIRE(__ptr != NULL);
|
||||
|
||||
return (__ptr);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MALLOC_SIZE
|
||||
|
||||
#include <malloc/malloc.h>
|
||||
|
||||
static inline size_t
|
||||
sallocx(void *ptr, int flags) {
|
||||
UNUSED(flags);
|
||||
|
||||
return (malloc_size(ptr));
|
||||
}
|
||||
|
||||
#elif HAVE_MALLOC_USABLE_SIZE
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
static inline size_t
|
||||
sallocx(void *ptr, int flags) {
|
||||
UNUSED(flags);
|
||||
|
||||
return (malloc_usable_size(ptr));
|
||||
}
|
||||
|
||||
#endif /* HAVE_MALLOC_SIZE */
|
||||
|
||||
#else /* defined(HAVE_MALLOC_SIZE) || defined (HAVE_MALLOC_USABLE_SIZE) */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static inline void *
|
||||
mallocx(size_t size, int flags) {
|
||||
UNUSED(flags);
|
||||
|
||||
size_t *__ptr = malloc(size + sizeof(size_t));
|
||||
REQUIRE(__ptr != NULL);
|
||||
__ptr[0] = size;
|
||||
|
||||
return (&__ptr[1]);
|
||||
}
|
||||
|
||||
static inline void
|
||||
sdallocx(void *ptr, size_t size, int flags) {
|
||||
UNUSED(size);
|
||||
UNUSED(flags);
|
||||
|
||||
free(&((size_t *)ptr)[-1]);
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
sallocx(void *ptr, int flags) {
|
||||
UNUSED(flags);
|
||||
|
||||
return (((size_t *)ptr)[-1]);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
rallocx(void *ptr, size_t size, int flags) {
|
||||
UNUSED(flags);
|
||||
|
||||
size_t *__ptr = realloc(&((size_t *)ptr)[-1], size);
|
||||
REQUIRE(__ptr != NULL);
|
||||
__ptr[0] = size;
|
||||
|
||||
return (&__ptr[1]);
|
||||
}
|
||||
|
||||
#endif /* defined(HAVE_MALLOC_SIZE) || defined (HAVE_MALLOC_USABLE_SIZE) */
|
||||
|
||||
#endif /* !defined(HAVE_JEMALLOC) */
|
||||
+348
-472
File diff suppressed because it is too large
Load Diff
@@ -669,12 +669,6 @@ struct isc_nm {
|
||||
|
||||
isc_stats_t *stats;
|
||||
|
||||
isc_mempool_t *reqpool;
|
||||
isc_mutex_t reqlock;
|
||||
|
||||
isc_mempool_t *evpool;
|
||||
isc_mutex_t evlock;
|
||||
|
||||
uint_fast32_t workers_running;
|
||||
atomic_uint_fast32_t workers_paused;
|
||||
atomic_uint_fast32_t maxudp;
|
||||
|
||||
+20
-38
@@ -281,21 +281,6 @@ isc__netmgr_create(isc_mem_t *mctx, uint32_t workers, isc_nm_t **netmgrp) {
|
||||
atomic_init(&mgr->keepalive, 30000);
|
||||
atomic_init(&mgr->advertised, 30000);
|
||||
|
||||
isc_mutex_init(&mgr->reqlock);
|
||||
isc_mempool_create(mgr->mctx, sizeof(isc__nm_uvreq_t), &mgr->reqpool);
|
||||
isc_mempool_setname(mgr->reqpool, "nm_reqpool");
|
||||
isc_mempool_setfreemax(mgr->reqpool, 4096);
|
||||
isc_mempool_associatelock(mgr->reqpool, &mgr->reqlock);
|
||||
isc_mempool_setfillcount(mgr->reqpool, 32);
|
||||
|
||||
isc_mutex_init(&mgr->evlock);
|
||||
isc_mempool_create(mgr->mctx, sizeof(isc__netievent_storage_t),
|
||||
&mgr->evpool);
|
||||
isc_mempool_setname(mgr->evpool, "nm_evpool");
|
||||
isc_mempool_setfreemax(mgr->evpool, 4096);
|
||||
isc_mempool_associatelock(mgr->evpool, &mgr->evlock);
|
||||
isc_mempool_setfillcount(mgr->evpool, 32);
|
||||
|
||||
isc_barrier_init(&mgr->pausing, workers);
|
||||
isc_barrier_init(&mgr->resuming, workers);
|
||||
|
||||
@@ -377,14 +362,14 @@ nm_destroy(isc_nm_t **mgr0) {
|
||||
|
||||
/* Empty the async event queues */
|
||||
while ((ievent = DEQUEUE_PRIORITY_NETIEVENT(worker)) != NULL) {
|
||||
isc_mempool_put(mgr->evpool, ievent);
|
||||
isc_mem_put(mgr->mctx, ievent, sizeof(*ievent));
|
||||
}
|
||||
|
||||
INSIST(DEQUEUE_PRIVILEGED_NETIEVENT(worker) == NULL);
|
||||
INSIST(DEQUEUE_TASK_NETIEVENT(worker) == NULL);
|
||||
|
||||
while ((ievent = DEQUEUE_PRIORITY_NETIEVENT(worker)) != NULL) {
|
||||
isc_mempool_put(mgr->evpool, ievent);
|
||||
isc_mem_put(mgr->mctx, ievent, sizeof(*ievent));
|
||||
}
|
||||
isc_condition_destroy(&worker->cond_prio);
|
||||
|
||||
@@ -413,12 +398,6 @@ nm_destroy(isc_nm_t **mgr0) {
|
||||
isc_condition_destroy(&mgr->wkpausecond);
|
||||
isc_mutex_destroy(&mgr->lock);
|
||||
|
||||
isc_mempool_destroy(&mgr->evpool);
|
||||
isc_mutex_destroy(&mgr->evlock);
|
||||
|
||||
isc_mempool_destroy(&mgr->reqpool);
|
||||
isc_mutex_destroy(&mgr->reqlock);
|
||||
|
||||
isc_mem_put(mgr->mctx, mgr->workers,
|
||||
mgr->nworkers * sizeof(isc__networker_t));
|
||||
isc_mem_putanddetach(&mgr->mctx, mgr, sizeof(*mgr));
|
||||
@@ -1038,7 +1017,8 @@ process_queue(isc__networker_t *worker, netievent_type_t type) {
|
||||
|
||||
void *
|
||||
isc__nm_get_netievent(isc_nm_t *mgr, isc__netievent_type type) {
|
||||
isc__netievent_storage_t *event = isc_mempool_get(mgr->evpool);
|
||||
isc__netievent_storage_t *event = isc_mem_get(mgr->mctx,
|
||||
sizeof(*event));
|
||||
|
||||
*event = (isc__netievent_storage_t){ .ni.type = type };
|
||||
return (event);
|
||||
@@ -1046,7 +1026,7 @@ isc__nm_get_netievent(isc_nm_t *mgr, isc__netievent_type type) {
|
||||
|
||||
void
|
||||
isc__nm_put_netievent(isc_nm_t *mgr, void *ievent) {
|
||||
isc_mempool_put(mgr->evpool, ievent);
|
||||
isc_mem_put(mgr->mctx, ievent, sizeof(isc__netievent_storage_t));
|
||||
}
|
||||
|
||||
NETIEVENT_SOCKET_DEF(tcpclose);
|
||||
@@ -1261,7 +1241,7 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) {
|
||||
}
|
||||
|
||||
if (sock->buf != NULL) {
|
||||
isc_mem_free(sock->mgr->mctx, sock->buf);
|
||||
isc_mem_put(sock->mgr->mctx, sock->buf, sock->buf_size);
|
||||
}
|
||||
|
||||
if (sock->quota != NULL) {
|
||||
@@ -1273,14 +1253,16 @@ nmsocket_cleanup(isc_nmsocket_t *sock, bool dofree FLARG) {
|
||||
isc_astack_destroy(sock->inactivehandles);
|
||||
|
||||
while ((uvreq = isc_astack_pop(sock->inactivereqs)) != NULL) {
|
||||
isc_mempool_put(sock->mgr->reqpool, uvreq);
|
||||
isc_mem_put(sock->mgr->mctx, uvreq, sizeof(*uvreq));
|
||||
}
|
||||
|
||||
isc_astack_destroy(sock->inactivereqs);
|
||||
sock->magic = 0;
|
||||
|
||||
isc_mem_free(sock->mgr->mctx, sock->ah_frees);
|
||||
isc_mem_free(sock->mgr->mctx, sock->ah_handles);
|
||||
isc_mem_put(sock->mgr->mctx, sock->ah_frees,
|
||||
sock->ah_size * sizeof(sock->ah_frees[0]));
|
||||
isc_mem_put(sock->mgr->mctx, sock->ah_handles,
|
||||
sock->ah_size * sizeof(sock->ah_handles[0]));
|
||||
isc_mutex_destroy(&sock->lock);
|
||||
isc_condition_destroy(&sock->scond);
|
||||
#if HAVE_LIBNGHTTP2
|
||||
@@ -1492,10 +1474,10 @@ isc___nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr, isc_nmsocket_type type,
|
||||
isc_nm_attach(mgr, &sock->mgr);
|
||||
sock->uv_handle.handle.data = sock;
|
||||
|
||||
sock->ah_frees = isc_mem_allocate(mgr->mctx,
|
||||
sock->ah_size * sizeof(size_t));
|
||||
sock->ah_handles = isc_mem_allocate(
|
||||
mgr->mctx, sock->ah_size * sizeof(isc_nmhandle_t *));
|
||||
sock->ah_frees = isc_mem_get(mgr->mctx,
|
||||
sock->ah_size * sizeof(sock->ah_frees[0]));
|
||||
sock->ah_handles = isc_mem_get(
|
||||
mgr->mctx, sock->ah_size * sizeof(sock->ah_handles[0]));
|
||||
ISC_LINK_INIT(&sock->quotacb, link);
|
||||
for (size_t i = 0; i < 32; i++) {
|
||||
sock->ah_frees[i] = i;
|
||||
@@ -1905,12 +1887,12 @@ isc__nm_alloc_dnsbuf(isc_nmsocket_t *sock, size_t len) {
|
||||
if (sock->buf == NULL) {
|
||||
/* We don't have the buffer at all */
|
||||
size_t alloc_len = len < NM_REG_BUF ? NM_REG_BUF : NM_BIG_BUF;
|
||||
sock->buf = isc_mem_allocate(sock->mgr->mctx, alloc_len);
|
||||
sock->buf = isc_mem_get(sock->mgr->mctx, alloc_len);
|
||||
sock->buf_size = alloc_len;
|
||||
} else {
|
||||
/* We have the buffer but it's too small */
|
||||
sock->buf = isc_mem_reallocate(sock->mgr->mctx, sock->buf,
|
||||
NM_BIG_BUF);
|
||||
isc_mem_put(sock->mgr->mctx, sock->buf, sock->buf_size);
|
||||
sock->buf = isc_mem_get(sock->mgr->mctx, NM_BIG_BUF);
|
||||
sock->buf_size = NM_BIG_BUF;
|
||||
}
|
||||
}
|
||||
@@ -2426,7 +2408,7 @@ isc___nm_uvreq_get(isc_nm_t *mgr, isc_nmsocket_t *sock FLARG) {
|
||||
}
|
||||
|
||||
if (req == NULL) {
|
||||
req = isc_mempool_get(mgr->reqpool);
|
||||
req = isc_mem_get(mgr->mctx, sizeof(*req));
|
||||
}
|
||||
|
||||
*req = (isc__nm_uvreq_t){ .magic = 0 };
|
||||
@@ -2462,7 +2444,7 @@ isc___nm_uvreq_put(isc__nm_uvreq_t **req0, isc_nmsocket_t *sock FLARG) {
|
||||
|
||||
if (!isc__nmsocket_active(sock) ||
|
||||
!isc_astack_trypush(sock->inactivereqs, req)) {
|
||||
isc_mempool_put(sock->mgr->reqpool, req);
|
||||
isc_mem_put(sock->mgr->mctx, req, sizeof(*req));
|
||||
}
|
||||
|
||||
if (handle != NULL) {
|
||||
|
||||
@@ -82,7 +82,6 @@ isc_mem_test(void **state) {
|
||||
|
||||
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
|
||||
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
|
||||
isc_mempool_setmaxalloc(mp1, MP1_MAXALLOC);
|
||||
|
||||
/*
|
||||
* Allocate MP1_MAXALLOC items from the pool. This is our max.
|
||||
@@ -92,12 +91,6 @@ isc_mem_test(void **state) {
|
||||
assert_non_null(items1[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to allocate one more. This should fail.
|
||||
*/
|
||||
tmp = isc_mempool_get(mp1);
|
||||
assert_null(tmp);
|
||||
|
||||
/*
|
||||
* Free the first 11 items. Verify that there are 10 free items on
|
||||
* the free list (which is our max).
|
||||
@@ -174,15 +167,14 @@ isc_mem_total_test(void **state) {
|
||||
for (i = 0; i < 100000; i++) {
|
||||
void *ptr;
|
||||
|
||||
ptr = isc_mem_allocate(mctx2, 2048);
|
||||
isc_mem_free(mctx2, ptr);
|
||||
ptr = isc_mem_get(mctx2, 2048);
|
||||
isc_mem_put(mctx2, ptr, 2048);
|
||||
}
|
||||
|
||||
after = isc_mem_total(mctx2);
|
||||
diff = after - before;
|
||||
|
||||
/* 2048 +8 bytes extra for size_info */
|
||||
assert_int_equal(diff, (2048 + 8) * 100000);
|
||||
assert_int_equal(diff, (2048) * 100000);
|
||||
|
||||
/* ISC_MEMFLAG_INTERNAL */
|
||||
|
||||
@@ -191,15 +183,14 @@ isc_mem_total_test(void **state) {
|
||||
for (i = 0; i < 100000; i++) {
|
||||
void *ptr;
|
||||
|
||||
ptr = isc_mem_allocate(test_mctx, 2048);
|
||||
isc_mem_free(test_mctx, ptr);
|
||||
ptr = isc_mem_get(test_mctx, 2048);
|
||||
isc_mem_put(test_mctx, ptr, 2048);
|
||||
}
|
||||
|
||||
after = isc_mem_total(test_mctx);
|
||||
diff = after - before;
|
||||
|
||||
/* 2048 +8 bytes extra for size_info */
|
||||
assert_int_equal(diff, (2048 + 8) * 100000);
|
||||
assert_int_equal(diff, (2048) * 100000);
|
||||
|
||||
isc_mem_destroy(&mctx2);
|
||||
}
|
||||
@@ -430,68 +421,6 @@ isc_mem_benchmark(void **state) {
|
||||
(nthreads * ITERS * NUM_ITEMS) / (t / 1000000.0));
|
||||
}
|
||||
|
||||
static isc_threadresult_t
|
||||
mempool_thread(isc_threadarg_t arg) {
|
||||
isc_mempool_t *mp = (isc_mempool_t *)arg;
|
||||
void *items[NUM_ITEMS];
|
||||
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
for (int j = 0; j < NUM_ITEMS; j++) {
|
||||
items[j] = isc_mempool_get(mp);
|
||||
}
|
||||
for (int j = 0; j < NUM_ITEMS; j++) {
|
||||
isc_mempool_put(mp, items[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return ((isc_threadresult_t)0);
|
||||
}
|
||||
|
||||
static void
|
||||
isc_mempool_benchmark(void **state) {
|
||||
int nthreads = ISC_MAX(ISC_MIN(isc_os_ncpus(), 32), 1);
|
||||
isc_thread_t threads[32];
|
||||
isc_time_t ts1, ts2;
|
||||
double t;
|
||||
isc_result_t result;
|
||||
isc_mempool_t *mp = NULL;
|
||||
isc_mutex_t mplock;
|
||||
|
||||
isc_mutex_init(&mplock);
|
||||
|
||||
isc_mempool_create(test_mctx, ITEM_SIZE, &mp);
|
||||
|
||||
isc_mempool_associatelock(mp, &mplock);
|
||||
|
||||
isc_mempool_setfreemax(mp, 32768);
|
||||
isc_mempool_setfillcount(mp, ISC_MAX(NUM_ITEMS / nthreads, 1));
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = isc_time_now(&ts1);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
for (int i = 0; i < nthreads; i++) {
|
||||
isc_thread_create(mempool_thread, mp, &threads[i]);
|
||||
}
|
||||
for (int i = 0; i < nthreads; i++) {
|
||||
isc_thread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
result = isc_time_now(&ts2);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
t = isc_time_microdiff(&ts2, &ts1);
|
||||
|
||||
printf("[ TIME ] isc_mempool_benchmark: "
|
||||
"%d isc_mempool_{get,put} calls, %f seconds, %f calls/second\n",
|
||||
nthreads * ITERS * NUM_ITEMS, t / 1000000.0,
|
||||
(nthreads * ITERS * NUM_ITEMS) / (t / 1000000.0));
|
||||
|
||||
isc_mempool_destroy(&mp);
|
||||
isc_mutex_destroy(&mplock);
|
||||
}
|
||||
|
||||
#endif /* __SANITIZE_THREAD */
|
||||
|
||||
/*
|
||||
@@ -511,8 +440,6 @@ main(void) {
|
||||
#if !defined(__SANITIZE_THREAD__)
|
||||
cmocka_unit_test_setup_teardown(isc_mem_benchmark, _setup,
|
||||
_teardown),
|
||||
cmocka_unit_test_setup_teardown(isc_mempool_benchmark, _setup,
|
||||
_teardown),
|
||||
#endif /* __SANITIZE_THREAD__ */
|
||||
#if ISC_MEM_TRACKLINES
|
||||
cmocka_unit_test_setup_teardown(isc_mem_noflags_test, _setup,
|
||||
|
||||
+1
-5
@@ -72,11 +72,7 @@ tls_initialize(void) {
|
||||
/*
|
||||
* We can't use isc_mem API here, because it's called too
|
||||
* early and when the isc_mem_debugging flags are changed
|
||||
* later and ISC_MEM_DEBUGSIZE or ISC_MEM_DEBUGCTX flags are
|
||||
* added, neither isc_mem_put() nor isc_mem_free() can be used
|
||||
* to free up the memory allocated here because the flags were
|
||||
* not set when calling isc_mem_get() or isc_mem_allocate()
|
||||
* here.
|
||||
* later.
|
||||
*
|
||||
* Actually, since this is a single allocation at library load
|
||||
* and deallocation at library unload, using the standard
|
||||
|
||||
+6
-10
@@ -40,17 +40,13 @@ static size_t isc__trampoline_min = 1;
|
||||
static size_t isc__trampoline_max = 65;
|
||||
|
||||
/*
|
||||
* We can't use isc_mem API here, because it's called too
|
||||
* early and when the isc_mem_debugging flags are changed
|
||||
* later and ISC_MEM_DEBUGSIZE or ISC_MEM_DEBUGCTX flags are
|
||||
* added, neither isc_mem_put() nor isc_mem_free() can be used
|
||||
* to free up the memory allocated here because the flags were
|
||||
* not set when calling isc_mem_get() or isc_mem_allocate()
|
||||
* here.
|
||||
* We can't use isc_mem API here, because it's called too early and the
|
||||
* isc_mem_debugging flags can be changed later causing mismatch between flags
|
||||
* used for isc_mem_get() and isc_mem_put().
|
||||
*
|
||||
* Actually, since this is a single allocation at library load
|
||||
* and deallocation at library unload, using the standard
|
||||
* allocator without the tracking is fine for this purpose.
|
||||
* Since this is a single allocation at library load and deallocation at library
|
||||
* unload, using the standard allocator without the tracking is fine for this
|
||||
* single purpose.
|
||||
*/
|
||||
static isc__trampoline_t *
|
||||
isc__trampoline_new(int tid, isc_threadfunc_t start, isc_threadarg_t arg) {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# ===========================================================================
|
||||
# https://gitlab.isc.org/isc-projects/autoconf-archive/ax_jemalloc.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CHECK_JEMALLOC([, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Test for the jemalloc library in a path
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2021 Internet Systems Consortium
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 1
|
||||
|
||||
#
|
||||
AC_DEFUN([AX_CHECK_JEMALLOC], [
|
||||
found=false
|
||||
PKG_CHECK_MODULES(
|
||||
[JEMALLOC], [jemalloc],
|
||||
[
|
||||
found=true
|
||||
], [
|
||||
AC_CHECK_HEADERS([malloc_np.h jemalloc/jemalloc.h],
|
||||
[
|
||||
save_LIBS="$LIBS"
|
||||
save_LDFLAGS="$LDFLAGS"
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
AC_SEARCH_LIBS([mallocx], [jemalloc],
|
||||
[
|
||||
found=true
|
||||
AS_IF([test "$ac_cv_search_mallocx" != "none required"],
|
||||
[JEMALLOC_LIBS="$ac_cv_search_mallocx"])
|
||||
])
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
])
|
||||
|
||||
AS_IF([$found], [$1], [$2])
|
||||
|
||||
AC_SUBST([JEMALLOC_CFLAGS])
|
||||
AC_SUBST([JEMALLOC_LIBS])
|
||||
])
|
||||
@@ -1787,6 +1787,7 @@
|
||||
./lib/isc/include/pkcs11/pkcs11.h X 2019,2020,2021
|
||||
./lib/isc/interfaceiter.c C 1999,2000,2001,2002,2003,2004,2005,2007,2008,2014,2016,2017,2018,2019,2020,2021
|
||||
./lib/isc/iterated_hash.c C 2006,2008,2009,2016,2018,2019,2020,2021
|
||||
./lib/isc/jemalloc_shim.h C 2021
|
||||
./lib/isc/lex.c C 1998,1999,2000,2001,2002,2003,2004,2005,2007,2013,2014,2015,2016,2017,2018,2019,2020,2021
|
||||
./lib/isc/lib.c C 1999,2000,2001,2004,2005,2007,2009,2013,2014,2015,2016,2018,2019,2020,2021
|
||||
./lib/isc/log.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2009,2011,2012,2013,2014,2016,2017,2018,2019,2020,2021
|
||||
|
||||
Reference in New Issue
Block a user