Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfc13a3b93 | ||
|
|
8cf8033ad2 | ||
|
|
eb86910716 | ||
|
|
fb8216ebef | ||
|
|
346fb2a550 | ||
|
|
64cca12f56 | ||
|
|
e600053178 | ||
|
|
397ec5dd0b | ||
|
|
c61feee7c8 | ||
|
|
55ae397682 | ||
|
|
091ae19a94 | ||
|
|
0b098b562d |
+6
-20
@@ -170,7 +170,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;
|
||||
@@ -1426,15 +1425,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);
|
||||
}
|
||||
|
||||
@@ -1611,8 +1601,8 @@ clear_query(dig_query_t *query) {
|
||||
sockcount--;
|
||||
debug("sockcount=%d", sockcount);
|
||||
}
|
||||
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);
|
||||
isc_buffer_invalidate(&query->recvbuf);
|
||||
isc_buffer_invalidate(&query->lengthbuf);
|
||||
|
||||
@@ -1688,7 +1678,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) {
|
||||
@@ -2339,7 +2329,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
||||
check_result(result, "dns_message_settsigkey");
|
||||
}
|
||||
|
||||
lookup->sendspace = isc_mempool_get(commctx);
|
||||
lookup->sendspace = isc_mem_get(mctx, COMMSIZE);
|
||||
if (lookup->sendspace == NULL) {
|
||||
fatal("memory allocation failure");
|
||||
}
|
||||
@@ -2578,8 +2568,8 @@ setup_lookup(dig_lookup_t *lookup) {
|
||||
query->byte_count = 0;
|
||||
query->ixfr_axfr = false;
|
||||
query->sock = NULL;
|
||||
query->recvspace = isc_mempool_get(commctx);
|
||||
query->tmpsendspace = isc_mempool_get(commctx);
|
||||
query->recvspace = isc_mem_get(mctx, COMMSIZE);
|
||||
query->tmpsendspace = isc_mem_get(mctx, COMMSIZE);
|
||||
if (query->recvspace == NULL) {
|
||||
fatal("memory allocation failure");
|
||||
}
|
||||
@@ -4378,10 +4368,6 @@ destroy_libs(void) {
|
||||
check_result(result, "dns_name_settotextfilter");
|
||||
#endif /* HAVE_LIBIDN2 */
|
||||
|
||||
if (commctx != NULL) {
|
||||
debug("freeing commctx");
|
||||
isc_mempool_destroy(&commctx);
|
||||
}
|
||||
if (socketmgr != NULL) {
|
||||
debug("freeing socketmgr");
|
||||
isc_socketmgr_destroy(&socketmgr);
|
||||
|
||||
+1
-1
@@ -939,7 +939,7 @@ create_managers(void) {
|
||||
}
|
||||
|
||||
result = isc_socketmgr_create2(named_g_mctx, &named_g_socketmgr,
|
||||
maxsocks, named_g_cpus);
|
||||
maxsocks, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"isc_socketmgr_create() failed: %s",
|
||||
|
||||
@@ -75,12 +75,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.
|
||||
*/
|
||||
@@ -354,25 +348,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.
|
||||
*/
|
||||
@@ -428,10 +406,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);
|
||||
}
|
||||
@@ -513,10 +487,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;
|
||||
@@ -543,7 +514,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));
|
||||
}
|
||||
|
||||
/*%
|
||||
|
||||
@@ -21,15 +21,12 @@ main(int argc, char *argv[]) {
|
||||
void *tmp;
|
||||
isc_mempool_t *mp1, *mp2;
|
||||
unsigned int i, j;
|
||||
isc_mutex_t lock;
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
|
||||
isc_mutex_init(&lock);
|
||||
|
||||
mctx = NULL;
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
@@ -39,9 +36,6 @@ main(int argc, char *argv[]) {
|
||||
mp2 = NULL;
|
||||
isc_mempool_create(mctx, 31, &mp2);
|
||||
|
||||
isc_mempool_associatelock(mp1, &lock);
|
||||
isc_mempool_associatelock(mp2, &lock);
|
||||
|
||||
isc_mem_stats(mctx, stderr);
|
||||
|
||||
isc_mempool_setfreemax(mp1, 10);
|
||||
@@ -112,7 +106,5 @@ main(int argc, char *argv[]) {
|
||||
|
||||
isc_mem_destroy(&mctx);
|
||||
|
||||
isc_mutex_destroy(&lock);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -579,9 +579,6 @@
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to use default system tuning. */
|
||||
#undef TUNE_LARGE
|
||||
|
||||
/* define if we can use backtrace */
|
||||
#undef USE_BACKTRACE
|
||||
|
||||
|
||||
@@ -780,6 +780,8 @@ PANDOC
|
||||
W3M
|
||||
LN
|
||||
ARFLAGS
|
||||
JEMALLOC_LIBS
|
||||
JEMALLOC_CFLAGS
|
||||
XTARGETS
|
||||
PKG_CONFIG_LIBDIR
|
||||
PKG_CONFIG_PATH
|
||||
@@ -860,6 +862,7 @@ infodir
|
||||
docdir
|
||||
oldincludedir
|
||||
includedir
|
||||
runstatedir
|
||||
localstatedir
|
||||
sharedstatedir
|
||||
sysconfdir
|
||||
@@ -936,7 +939,6 @@ with_protobuf_c
|
||||
with_libfstrm
|
||||
with_libidn2
|
||||
with_cmocka
|
||||
with_tuning
|
||||
enable_querytrace
|
||||
enable_auto_validation
|
||||
with_dlopen
|
||||
@@ -967,6 +969,8 @@ LT_SYS_LIBRARY_PATH
|
||||
PKG_CONFIG
|
||||
PKG_CONFIG_PATH
|
||||
PKG_CONFIG_LIBDIR
|
||||
JEMALLOC_CFLAGS
|
||||
JEMALLOC_LIBS
|
||||
PYTHON
|
||||
MAXMINDDB_CFLAGS
|
||||
MAXMINDDB_LIBS
|
||||
@@ -1025,6 +1029,7 @@ datadir='${datarootdir}'
|
||||
sysconfdir='${prefix}/etc'
|
||||
sharedstatedir='${prefix}/com'
|
||||
localstatedir='${prefix}/var'
|
||||
runstatedir='${localstatedir}/run'
|
||||
includedir='${prefix}/include'
|
||||
oldincludedir='/usr/include'
|
||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||
@@ -1277,6 +1282,15 @@ do
|
||||
| -silent | --silent | --silen | --sile | --sil)
|
||||
silent=yes ;;
|
||||
|
||||
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
||||
| --runstate | --runstat | --runsta | --runst | --runs \
|
||||
| --run | --ru | --r)
|
||||
ac_prev=runstatedir ;;
|
||||
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
||||
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
||||
| --run=* | --ru=* | --r=*)
|
||||
runstatedir=$ac_optarg ;;
|
||||
|
||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||
ac_prev=sbindir ;;
|
||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||
@@ -1414,7 +1428,7 @@ fi
|
||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||
libdir localedir mandir
|
||||
libdir localedir mandir runstatedir
|
||||
do
|
||||
eval ac_val=\$$ac_var
|
||||
# Remove trailing slashes.
|
||||
@@ -1567,6 +1581,7 @@ Fine tuning of the installation directories:
|
||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||
--includedir=DIR C header files [PREFIX/include]
|
||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||
@@ -1687,7 +1702,6 @@ Optional Packages:
|
||||
--with-libidn2=PATH enable IDN support using GNU libidn2
|
||||
[yes|no(default)|path]
|
||||
--with-cmocka=detect enable CMocka based tests (default is detect)
|
||||
--with-tuning=ARG Specify server tuning (default or small)
|
||||
--with-dlopen=ARG support dynamically loadable DLZ and DYNDB drivers
|
||||
--with-dnsrps-libname DNSRPS provider library name (librpz.so)
|
||||
--with-dnsrps-dir path to DNSRPS provider library
|
||||
@@ -1725,6 +1739,10 @@ Some influential environment variables:
|
||||
directories to add to pkg-config's search path
|
||||
PKG_CONFIG_LIBDIR
|
||||
path overriding pkg-config's built-in search path
|
||||
JEMALLOC_CFLAGS
|
||||
C compiler flags for JEMALLOC, overriding pkg-config
|
||||
JEMALLOC_LIBS
|
||||
linker flags for JEMALLOC, overriding pkg-config
|
||||
PYTHON path to python executable
|
||||
MAXMINDDB_CFLAGS
|
||||
C compiler flags for MAXMINDDB, overriding pkg-config
|
||||
@@ -4011,7 +4029,7 @@ else
|
||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||
since some C++ compilers masquerading as C compilers
|
||||
incorrectly reject 9223372036854775807. */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4057,7 +4075,7 @@ else
|
||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||
since some C++ compilers masquerading as C compilers
|
||||
incorrectly reject 9223372036854775807. */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4081,7 +4099,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||
since some C++ compilers masquerading as C compilers
|
||||
incorrectly reject 9223372036854775807. */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4126,7 +4144,7 @@ else
|
||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||
since some C++ compilers masquerading as C compilers
|
||||
incorrectly reject 9223372036854775807. */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -4150,7 +4168,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||
since some C++ compilers masquerading as C compilers
|
||||
incorrectly reject 9223372036854775807. */
|
||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
||||
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||
&& LARGE_OFF_T % 2147483647 == 1)
|
||||
? 1 : -1];
|
||||
@@ -5408,7 +5426,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
|
||||
lt_cv_deplibs_check_method=pass_all
|
||||
;;
|
||||
|
||||
netbsd*)
|
||||
netbsd* | netbsdelf*-gnu)
|
||||
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
|
||||
lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
|
||||
else
|
||||
@@ -5770,7 +5788,7 @@ esac
|
||||
fi
|
||||
|
||||
: ${AR=ar}
|
||||
: ${AR_FLAGS=cru}
|
||||
: ${AR_FLAGS=cr}
|
||||
|
||||
|
||||
|
||||
@@ -6313,11 +6331,8 @@ _LT_EOF
|
||||
test $ac_status = 0; }; then
|
||||
# Now try to grab the symbols.
|
||||
nlist=conftest.nm
|
||||
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
|
||||
(eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; } && test -s "$nlist"; then
|
||||
$ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5
|
||||
if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then
|
||||
# Try sorting and uniquifying the output.
|
||||
if sort "$nlist" | uniq > "$nlist"T; then
|
||||
mv -f "$nlist"T "$nlist"
|
||||
@@ -7536,8 +7551,8 @@ int forced_loaded() { return 2;}
|
||||
_LT_EOF
|
||||
echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
|
||||
$LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
|
||||
echo "$AR cru libconftest.a conftest.o" >&5
|
||||
$AR cru libconftest.a conftest.o 2>&5
|
||||
echo "$AR cr libconftest.a conftest.o" >&5
|
||||
$AR cr libconftest.a conftest.o 2>&5
|
||||
echo "$RANLIB libconftest.a" >&5
|
||||
$RANLIB libconftest.a 2>&5
|
||||
cat > conftest.c << _LT_EOF
|
||||
@@ -7564,11 +7579,16 @@ $as_echo "$lt_cv_ld_force_load" >&6; }
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
|
||||
darwin1.*)
|
||||
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
|
||||
darwin*)
|
||||
case ${MACOSX_DEPLOYMENT_TARGET},$host in
|
||||
10.[012],*|,*powerpc*)
|
||||
darwin*) # darwin 5.x on
|
||||
# if running on 10.5 or later, the deployment target defaults
|
||||
# to the OS version, if on x86, and 10.4, the deployment
|
||||
# target defaults to 10.4. Don't you love it?
|
||||
case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
|
||||
10.0,*86*-darwin8*|10.0,*-darwin[912]*)
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
|
||||
10.[012][,.]*)
|
||||
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
|
||||
*)
|
||||
10.*|11.*)
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
|
||||
esac
|
||||
;;
|
||||
@@ -8394,6 +8414,12 @@ lt_prog_compiler_static=
|
||||
lt_prog_compiler_pic='-KPIC'
|
||||
lt_prog_compiler_static='-static'
|
||||
;;
|
||||
# flang / f18. f95 an alias for gfortran or flang on Debian
|
||||
flang* | f18* | f95*)
|
||||
lt_prog_compiler_wl='-Wl,'
|
||||
lt_prog_compiler_pic='-fPIC'
|
||||
lt_prog_compiler_static='-static'
|
||||
;;
|
||||
# icc used to be incompatible with GCC.
|
||||
# ICC 10 doesn't accept -KPIC any more.
|
||||
icc* | ifort*)
|
||||
@@ -8870,6 +8896,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
|
||||
openbsd* | bitrig*)
|
||||
with_gnu_ld=no
|
||||
;;
|
||||
linux* | k*bsd*-gnu | gnu*)
|
||||
link_all_deplibs=no
|
||||
;;
|
||||
esac
|
||||
|
||||
ld_shlibs=yes
|
||||
@@ -9124,7 +9153,7 @@ _LT_EOF
|
||||
fi
|
||||
;;
|
||||
|
||||
netbsd*)
|
||||
netbsd* | netbsdelf*-gnu)
|
||||
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
|
||||
archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
|
||||
wlarc=
|
||||
@@ -9794,6 +9823,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
|
||||
if test yes = "$lt_cv_irix_exported_symbol"; then
|
||||
archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
|
||||
fi
|
||||
link_all_deplibs=no
|
||||
else
|
||||
archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
|
||||
archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
|
||||
@@ -9815,7 +9845,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
|
||||
esac
|
||||
;;
|
||||
|
||||
netbsd*)
|
||||
netbsd* | netbsdelf*-gnu)
|
||||
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
|
||||
archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
|
||||
else
|
||||
@@ -10930,6 +10960,18 @@ fi
|
||||
dynamic_linker='GNU/Linux ld.so'
|
||||
;;
|
||||
|
||||
netbsdelf*-gnu)
|
||||
version_type=linux
|
||||
need_lib_prefix=no
|
||||
need_version=no
|
||||
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
|
||||
soname_spec='${libname}${release}${shared_ext}$major'
|
||||
shlibpath_var=LD_LIBRARY_PATH
|
||||
shlibpath_overrides_runpath=no
|
||||
hardcode_into_libs=yes
|
||||
dynamic_linker='NetBSD ld.elf_so'
|
||||
;;
|
||||
|
||||
netbsd*)
|
||||
version_type=sunos
|
||||
need_lib_prefix=no
|
||||
@@ -12321,6 +12363,104 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# Enforce jemalloc
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jemalloc" >&5
|
||||
$as_echo_n "checking for jemalloc... " >&6; }
|
||||
|
||||
pkg_failed=no
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jemalloc" >&5
|
||||
$as_echo_n "checking for jemalloc... " >&6; }
|
||||
|
||||
if test -n "$JEMALLOC_CFLAGS"; then
|
||||
pkg_cv_JEMALLOC_CFLAGS="$JEMALLOC_CFLAGS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jemalloc\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "jemalloc") 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_JEMALLOC_CFLAGS=`$PKG_CONFIG --cflags "jemalloc" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
if test -n "$JEMALLOC_LIBS"; then
|
||||
pkg_cv_JEMALLOC_LIBS="$JEMALLOC_LIBS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"jemalloc\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "jemalloc") 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_JEMALLOC_LIBS=`$PKG_CONFIG --libs "jemalloc" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
||||
_pkg_short_errors_supported=yes
|
||||
else
|
||||
_pkg_short_errors_supported=no
|
||||
fi
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
JEMALLOC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "jemalloc" 2>&1`
|
||||
else
|
||||
JEMALLOC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "jemalloc" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$JEMALLOC_PKG_ERRORS" >&5
|
||||
|
||||
as_fn_error $? "Package requirements (jemalloc) were not met:
|
||||
|
||||
$JEMALLOC_PKG_ERRORS
|
||||
|
||||
Consider adjusting the PKG_CONFIG_PATH environment variable if you
|
||||
installed software in a non-standard prefix.
|
||||
|
||||
Alternatively, you may set the environment variables JEMALLOC_CFLAGS
|
||||
and JEMALLOC_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details." "$LINENO" 5
|
||||
elif test $pkg_failed = untried; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
|
||||
is in your PATH or set the PKG_CONFIG environment variable to the full
|
||||
path to pkg-config.
|
||||
|
||||
Alternatively, you may set the environment variables JEMALLOC_CFLAGS
|
||||
and JEMALLOC_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details.
|
||||
|
||||
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
|
||||
See \`config.log' for more details" "$LINENO" 5; }
|
||||
else
|
||||
JEMALLOC_CFLAGS=$pkg_cv_JEMALLOC_CFLAGS
|
||||
JEMALLOC_LIBS=$pkg_cv_JEMALLOC_LIBS
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
|
||||
fi
|
||||
CFLAGS="$JEMALLOC_CFLAGS $CFLAGS"
|
||||
LDFLAGS="$JEMALLOC_LDFLAGS $LDFLAGS"
|
||||
LIBS="$JEMALLOC_LIBS $LIBS"
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable fuzzing mode" >&5
|
||||
$as_echo_n "checking whether to enable fuzzing mode... " >&6; }
|
||||
case $enable_fuzzing in #(
|
||||
@@ -22301,31 +22441,6 @@ fi
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# was --with-tuning specified?
|
||||
#
|
||||
# [pairwise: --with-tuning=small, --without-tuning]
|
||||
|
||||
# Check whether --with-tuning was given.
|
||||
if test "${with_tuning+set}" = set; then :
|
||||
withval=$with_tuning;
|
||||
else
|
||||
with_tuning=no
|
||||
fi
|
||||
|
||||
|
||||
case $with_tuning in #(
|
||||
small) :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: using small system tuning" >&5
|
||||
$as_echo "$as_me: using small system tuning" >&6;} ;; #(
|
||||
*) :
|
||||
|
||||
$as_echo "#define TUNE_LARGE 1" >>confdefs.h
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: using default system tuning" >&5
|
||||
$as_echo "$as_me: using default system tuning" >&6;} ;;
|
||||
esac
|
||||
|
||||
#
|
||||
# was --enable-querytrace specified?
|
||||
#
|
||||
@@ -25776,7 +25891,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
|
||||
cat <<_LT_EOF >> "$cfgfile"
|
||||
#! $SHELL
|
||||
# Generated automatically by $as_me ($PACKAGE) $VERSION
|
||||
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
|
||||
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
||||
|
||||
# Provide generalized library-building support services.
|
||||
|
||||
+7
-14
@@ -117,6 +117,13 @@ AC_ARG_ENABLE([fuzzing],
|
||||
[],
|
||||
[enable_fuzzing=no])
|
||||
|
||||
# Enforce jemalloc
|
||||
AC_MSG_CHECKING([for jemalloc])
|
||||
PKG_CHECK_MODULES([JEMALLOC], [jemalloc])
|
||||
CFLAGS="$JEMALLOC_CFLAGS $CFLAGS"
|
||||
LDFLAGS="$JEMALLOC_LDFLAGS $LDFLAGS"
|
||||
LIBS="$JEMALLOC_LIBS $LIBS"
|
||||
|
||||
AC_MSG_CHECKING([whether to enable fuzzing mode])
|
||||
AS_CASE([$enable_fuzzing],
|
||||
[no],[AC_MSG_RESULT([no])],
|
||||
@@ -2293,20 +2300,6 @@ AC_SUBST([LD_WRAP_TESTS])
|
||||
AC_CHECK_HEADERS(locale.h)
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
|
||||
#
|
||||
# was --with-tuning specified?
|
||||
#
|
||||
# [pairwise: --with-tuning=small, --without-tuning]
|
||||
AC_ARG_WITH([tuning],
|
||||
AS_HELP_STRING([--with-tuning=ARG],
|
||||
[Specify server tuning (default or small)]),
|
||||
[],[with_tuning=no])
|
||||
|
||||
AS_CASE([$with_tuning],
|
||||
[small],[AC_MSG_NOTICE(using small system tuning)],
|
||||
[AC_DEFINE(TUNE_LARGE, 1, [Define to use default system tuning.])
|
||||
AC_MSG_NOTICE(using default system tuning)])
|
||||
|
||||
#
|
||||
# was --enable-querytrace specified?
|
||||
#
|
||||
|
||||
+29
-126
@@ -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.
|
||||
@@ -631,12 +625,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.
|
||||
@@ -802,11 +790,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.
|
||||
@@ -1741,10 +1724,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);
|
||||
@@ -1802,7 +1782,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);
|
||||
@@ -1813,10 +1793,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;
|
||||
@@ -1837,7 +1815,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 *
|
||||
@@ -1845,10 +1825,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);
|
||||
@@ -1874,17 +1851,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;
|
||||
@@ -1954,7 +1928,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);
|
||||
@@ -1965,10 +1939,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.
|
||||
@@ -2003,10 +1975,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;
|
||||
@@ -2032,7 +2001,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
|
||||
@@ -2052,7 +2021,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));
|
||||
}
|
||||
|
||||
@@ -2065,10 +2036,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;
|
||||
@@ -2095,7 +2063,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));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2549,14 +2517,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);
|
||||
@@ -2582,7 +2542,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);
|
||||
@@ -2618,13 +2577,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;
|
||||
@@ -2680,7 +2632,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);
|
||||
@@ -2690,10 +2641,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);
|
||||
@@ -2706,10 +2653,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);
|
||||
@@ -2740,27 +2683,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.
|
||||
@@ -2796,7 +2720,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);
|
||||
@@ -2837,33 +2760,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);
|
||||
@@ -2928,7 +2829,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.
|
||||
@@ -3534,9 +3435,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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -959,7 +959,7 @@ dns_cache_setcachesize(dns_cache_t *cache, size_t size) {
|
||||
isc_mem_setwater(cache->mctx, water, cache, hiwater, lowater);
|
||||
}
|
||||
|
||||
dns_db_adjusthashsize(cache->db, size);
|
||||
/* dns_db_adjusthashsize(cache->db, size); */
|
||||
}
|
||||
|
||||
size_t
|
||||
|
||||
+46
-212
@@ -76,17 +76,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
|
||||
@@ -208,8 +198,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;
|
||||
@@ -234,7 +223,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', ' ')
|
||||
@@ -549,8 +537,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) {
|
||||
@@ -603,10 +590,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);
|
||||
@@ -635,7 +619,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,10 +689,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;
|
||||
@@ -834,7 +815,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));
|
||||
}
|
||||
|
||||
/*%
|
||||
@@ -913,7 +894,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) {
|
||||
@@ -927,9 +908,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);
|
||||
@@ -939,34 +920,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 *
|
||||
@@ -975,10 +947,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);
|
||||
@@ -1001,17 +970,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);
|
||||
|
||||
@@ -1629,25 +1597,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);
|
||||
}
|
||||
|
||||
@@ -1668,22 +1626,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);
|
||||
}
|
||||
@@ -1793,61 +1735,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);
|
||||
@@ -1872,14 +1770,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));
|
||||
@@ -1983,6 +1873,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
|
||||
@@ -2003,48 +1894,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) {
|
||||
@@ -2057,10 +1915,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);
|
||||
}
|
||||
@@ -2326,10 +2180,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;
|
||||
@@ -2353,7 +2205,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);
|
||||
@@ -2374,7 +2225,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);
|
||||
}
|
||||
@@ -2405,7 +2257,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) {
|
||||
@@ -2421,14 +2274,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
|
||||
@@ -2904,11 +2754,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;
|
||||
@@ -2936,15 +2781,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", NULL);
|
||||
|
||||
attributes &= ~DNS_DISPATCHATTR_TCP;
|
||||
attributes |= DNS_DISPATCHATTR_UDP;
|
||||
@@ -3160,14 +2998,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++;
|
||||
@@ -3222,7 +3054,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);
|
||||
}
|
||||
}
|
||||
@@ -3410,7 +3243,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 {
|
||||
|
||||
+12
-10
@@ -104,12 +104,14 @@ hexdump(const char *msg, const char *msg2, void *base, size_t len) {
|
||||
* of various block allocations used within the server.
|
||||
* XXXMLG These should come from a config setting.
|
||||
*/
|
||||
#define SCRATCHPAD_SIZE 512
|
||||
#define NAME_COUNT 64
|
||||
#define OFFSET_COUNT 4
|
||||
#define RDATA_COUNT 8
|
||||
#define RDATALIST_COUNT 8
|
||||
#define RDATASET_COUNT 64
|
||||
#define SCRATCHPAD_SIZE 1232
|
||||
#define NAME_FILLCOUNT 4
|
||||
#define NAME_FREEMAX 8 * NAME_FILLCOUNT
|
||||
#define OFFSET_COUNT 4
|
||||
#define RDATA_COUNT 8
|
||||
#define RDATALIST_COUNT 8
|
||||
#define RDATASET_FILLCOUNT 4
|
||||
#define RDATASET_FREEMAX 8 * RDATASET_FILLCOUNT
|
||||
|
||||
/*%
|
||||
* Text representation of the different items, for message_totext
|
||||
@@ -734,13 +736,13 @@ dns_message_create(isc_mem_t *mctx, unsigned int intent, dns_message_t **msgp) {
|
||||
ISC_LIST_INIT(m->freerdatalist);
|
||||
|
||||
isc_mempool_create(m->mctx, sizeof(dns_fixedname_t), &m->namepool);
|
||||
isc_mempool_setfillcount(m->namepool, NAME_COUNT);
|
||||
isc_mempool_setfreemax(m->namepool, NAME_COUNT);
|
||||
isc_mempool_setfillcount(m->namepool, NAME_FILLCOUNT);
|
||||
isc_mempool_setfreemax(m->namepool, NAME_FREEMAX);
|
||||
isc_mempool_setname(m->namepool, "msg:names");
|
||||
|
||||
isc_mempool_create(m->mctx, sizeof(dns_rdataset_t), &m->rdspool);
|
||||
isc_mempool_setfillcount(m->rdspool, RDATASET_COUNT);
|
||||
isc_mempool_setfreemax(m->rdspool, RDATASET_COUNT);
|
||||
isc_mempool_setfillcount(m->rdspool, RDATASET_FILLCOUNT);
|
||||
isc_mempool_setfreemax(m->rdspool, RDATASET_FREEMAX);
|
||||
isc_mempool_setname(m->rdspool, "msg:rdataset");
|
||||
|
||||
isc_buffer_allocate(mctx, &dynbuf, SCRATCHPAD_SIZE);
|
||||
|
||||
@@ -1082,6 +1082,8 @@ isc_result_t
|
||||
dns_rbt_adjusthashsize(dns_rbt_t *rbt, size_t size) {
|
||||
REQUIRE(VALID_RBT(rbt));
|
||||
|
||||
UNUSED(size);
|
||||
#if 0
|
||||
if (size > 0) {
|
||||
/*
|
||||
* Setting a new, finite size limit was requested for the RBT.
|
||||
@@ -1104,6 +1106,7 @@ dns_rbt_adjusthashsize(dns_rbt_t *rbt, size_t size) {
|
||||
*/
|
||||
rbt->maxhashbits = RBT_HASH_MAX_BITS;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
+76
-37
@@ -45,6 +45,7 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <isc/align.h>
|
||||
#include <isc/atomic.h>
|
||||
#include <isc/hp.h>
|
||||
#include <isc/mem.h>
|
||||
@@ -53,14 +54,12 @@
|
||||
#include <isc/thread.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#define HP_MAX_THREADS 128
|
||||
static int isc__hp_max_threads = HP_MAX_THREADS;
|
||||
#define HP_MAX_HPS 4 /* This is named 'K' in the HP paper */
|
||||
#define CLPAD (128 / sizeof(uintptr_t))
|
||||
#define HP_THRESHOLD_R 0 /* This is named 'R' in the HP paper */
|
||||
#define CACHELINE_SIZE 64
|
||||
|
||||
/* Maximum number of retired objects per thread */
|
||||
static int isc__hp_max_retired = HP_MAX_THREADS * HP_MAX_HPS;
|
||||
static int isc__hp_max_threads = 1;
|
||||
#define HP_MAX_HPS 4 /* This is named 'K' in the HP paper */
|
||||
#define CLPAD (CACHELINE_SIZE / sizeof(uintptr_t))
|
||||
#define HP_THRESHOLD_R 0 /* This is named 'R' in the HP paper */
|
||||
|
||||
typedef struct retirelist {
|
||||
int size;
|
||||
@@ -69,10 +68,11 @@ typedef struct retirelist {
|
||||
|
||||
struct isc_hp {
|
||||
int max_hps;
|
||||
int max_retired;
|
||||
isc_mem_t *mctx;
|
||||
atomic_uintptr_t **hp;
|
||||
retirelist_t **rl;
|
||||
isc_hp_deletefunc_t *deletefunc;
|
||||
alignas(CACHELINE_SIZE) atomic_uintptr_t **hp;
|
||||
alignas(CACHELINE_SIZE) retirelist_t **rl;
|
||||
};
|
||||
|
||||
static inline int
|
||||
@@ -82,35 +82,72 @@ tid(void) {
|
||||
|
||||
void
|
||||
isc_hp_init(int max_threads) {
|
||||
REQUIRE(max_threads > 0);
|
||||
|
||||
if (isc__hp_max_threads > max_threads) {
|
||||
return;
|
||||
}
|
||||
|
||||
isc__hp_max_threads = max_threads;
|
||||
isc__hp_max_retired = max_threads * HP_MAX_HPS;
|
||||
}
|
||||
|
||||
static size_t
|
||||
hp_clpad(size_t max_hps) {
|
||||
size_t hp_size = max_hps * sizeof(atomic_uintptr_t);
|
||||
size_t hp_padding = 0;
|
||||
while (hp_size > CACHELINE_SIZE) {
|
||||
hp_size -= CACHELINE_SIZE;
|
||||
}
|
||||
if (hp_size > 0) {
|
||||
hp_padding = CACHELINE_SIZE / hp_size;
|
||||
}
|
||||
|
||||
return (hp_size + hp_padding);
|
||||
}
|
||||
|
||||
isc_hp_t *
|
||||
isc_hp_new(isc_mem_t *mctx, size_t max_hps, isc_hp_deletefunc_t *deletefunc) {
|
||||
isc_hp_t *hp = isc_mem_get(mctx, sizeof(*hp));
|
||||
|
||||
REQUIRE(isc__hp_max_threads > 0);
|
||||
REQUIRE(max_hps <= HP_MAX_HPS);
|
||||
|
||||
if (max_hps == 0) {
|
||||
max_hps = HP_MAX_HPS;
|
||||
}
|
||||
|
||||
*hp = (isc_hp_t){ .max_hps = max_hps, .deletefunc = deletefunc };
|
||||
*hp = (isc_hp_t){
|
||||
.max_hps = max_hps,
|
||||
.max_retired = isc__hp_max_threads * max_hps,
|
||||
.deletefunc = deletefunc,
|
||||
};
|
||||
|
||||
isc_mem_attach(mctx, &hp->mctx);
|
||||
|
||||
hp->hp = isc_mem_get(mctx, isc__hp_max_threads * sizeof(hp->hp[0]));
|
||||
hp->rl = isc_mem_get(mctx, isc__hp_max_threads * sizeof(hp->rl[0]));
|
||||
|
||||
for (int i = 0; i < isc__hp_max_threads; i++) {
|
||||
hp->hp[i] = isc_mem_get(mctx, CLPAD * 2 * sizeof(hp->hp[i][0]));
|
||||
hp->rl[i] = isc_mem_get(mctx, sizeof(*hp->rl[0]));
|
||||
*hp->rl[i] = (retirelist_t){ .size = 0 };
|
||||
|
||||
hp->hp[i] = isc_mem_get(mctx, hp_clpad(hp->max_hps));
|
||||
for (int j = 0; j < hp->max_hps; j++) {
|
||||
atomic_init(&hp->hp[i][j], 0);
|
||||
}
|
||||
hp->rl[i]->list = isc_mem_get(
|
||||
hp->mctx, isc__hp_max_retired * sizeof(uintptr_t));
|
||||
}
|
||||
|
||||
/*
|
||||
* It's not nice that we have a lot of empty space, but we need padding
|
||||
* to avoid false sharing.
|
||||
*/
|
||||
hp->rl = isc_mem_get(mctx,
|
||||
(isc__hp_max_threads * CLPAD) * sizeof(hp->rl[0]));
|
||||
|
||||
for (int i = 0; i < isc__hp_max_threads; i++) {
|
||||
retirelist_t *rl;
|
||||
|
||||
rl = isc_mem_get(mctx, sizeof(*rl));
|
||||
rl->size = 0;
|
||||
rl->list = isc_mem_get(hp->mctx,
|
||||
hp->max_retired * sizeof(uintptr_t));
|
||||
|
||||
hp->rl[i * CLPAD] = rl;
|
||||
}
|
||||
|
||||
return (hp);
|
||||
@@ -119,19 +156,22 @@ isc_hp_new(isc_mem_t *mctx, size_t max_hps, isc_hp_deletefunc_t *deletefunc) {
|
||||
void
|
||||
isc_hp_destroy(isc_hp_t *hp) {
|
||||
for (int i = 0; i < isc__hp_max_threads; i++) {
|
||||
isc_mem_put(hp->mctx, hp->hp[i],
|
||||
CLPAD * 2 * sizeof(hp->hp[i][0]));
|
||||
retirelist_t *rl = hp->rl[i * CLPAD];
|
||||
|
||||
for (int j = 0; j < hp->rl[i]->size; j++) {
|
||||
void *data = (void *)hp->rl[i]->list[j];
|
||||
for (int j = 0; j < rl->size; j++) {
|
||||
void *data = (void *)rl->list[j];
|
||||
hp->deletefunc(data);
|
||||
}
|
||||
isc_mem_put(hp->mctx, hp->rl[i]->list,
|
||||
isc__hp_max_retired * sizeof(uintptr_t));
|
||||
isc_mem_put(hp->mctx, hp->rl[i], sizeof(*hp->rl[0]));
|
||||
isc_mem_put(hp->mctx, rl->list,
|
||||
hp->max_retired * sizeof(uintptr_t));
|
||||
isc_mem_put(hp->mctx, rl, sizeof(*rl));
|
||||
}
|
||||
for (int i = 0; i < isc__hp_max_threads; i++) {
|
||||
isc_mem_put(hp->mctx, hp->hp[i], hp_clpad(hp->max_hps));
|
||||
}
|
||||
isc_mem_put(hp->mctx, hp->hp, isc__hp_max_threads * sizeof(hp->hp[0]));
|
||||
isc_mem_put(hp->mctx, hp->rl, isc__hp_max_threads * sizeof(hp->rl[0]));
|
||||
isc_mem_put(hp->mctx, hp->rl,
|
||||
(isc__hp_max_threads * CLPAD) * sizeof(hp->rl[0]));
|
||||
|
||||
isc_mem_putanddetach(&hp->mctx, hp, sizeof(*hp));
|
||||
}
|
||||
@@ -173,15 +213,16 @@ isc_hp_protect_release(isc_hp_t *hp, int ihp, atomic_uintptr_t ptr) {
|
||||
|
||||
void
|
||||
isc_hp_retire(isc_hp_t *hp, uintptr_t ptr) {
|
||||
hp->rl[tid()]->list[hp->rl[tid()]->size++] = ptr;
|
||||
INSIST(hp->rl[tid()]->size < isc__hp_max_retired);
|
||||
retirelist_t *rl = hp->rl[tid() * CLPAD];
|
||||
rl->list[rl->size++] = ptr;
|
||||
INSIST(rl->size < hp->max_retired);
|
||||
|
||||
if (hp->rl[tid()]->size < HP_THRESHOLD_R) {
|
||||
if (rl->size < HP_THRESHOLD_R) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int iret = 0; iret < hp->rl[tid()]->size; iret++) {
|
||||
uintptr_t obj = hp->rl[tid()]->list[iret];
|
||||
for (int iret = 0; iret < rl->size; iret++) {
|
||||
uintptr_t obj = rl->list[iret];
|
||||
bool can_delete = true;
|
||||
for (int itid = 0; itid < isc__hp_max_threads && can_delete;
|
||||
itid++) {
|
||||
@@ -194,11 +235,9 @@ isc_hp_retire(isc_hp_t *hp, uintptr_t ptr) {
|
||||
}
|
||||
|
||||
if (can_delete) {
|
||||
size_t bytes = (hp->rl[tid()]->size - iret) *
|
||||
sizeof(hp->rl[tid()]->list[0]);
|
||||
memmove(&hp->rl[tid()]->list[iret],
|
||||
&hp->rl[tid()]->list[iret + 1], bytes);
|
||||
hp->rl[tid()]->size--;
|
||||
size_t bytes = (rl->size - iret) * sizeof(rl->list[0]);
|
||||
memmove(&rl->list[iret], &rl->list[iret + 1], bytes);
|
||||
rl->size--;
|
||||
hp->deletefunc((void *)obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
|
||||
#if !ISC_MEM_USE_INTERNAL_MALLOC
|
||||
#define ISC_MEMFLAG_DEFAULT 0
|
||||
#else /* if !ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
#define ISC_MEMFLAG_DEFAULT ISC_MEMFLAG_INTERNAL | ISC_MEMFLAG_FILL
|
||||
#define ISC_MEMFLAG_DEFAULT ISC_MEMFLAG_FILL
|
||||
#endif /* if !ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
/*%
|
||||
@@ -495,33 +495,6 @@ 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
|
||||
|
||||
+91
-161
@@ -62,6 +62,7 @@ LIBISC_EXTERNAL_DATA unsigned int isc_mem_defaultflags = ISC_MEMFLAG_DEFAULT;
|
||||
#define NUM_BASIC_BLOCKS 64 /*%< must be > 1 */
|
||||
#define TABLE_INCREMENT 1024
|
||||
#define DEBUG_TABLE_COUNT 512U
|
||||
#define STATS_BUCKETS 512U
|
||||
|
||||
/*
|
||||
* Types.
|
||||
@@ -105,10 +106,12 @@ typedef struct {
|
||||
} size_info;
|
||||
|
||||
struct stats {
|
||||
char *file;
|
||||
unsigned long gets;
|
||||
unsigned long totalgets;
|
||||
unsigned long blocks;
|
||||
unsigned long freefrags;
|
||||
atomic_size_t inuse;
|
||||
};
|
||||
|
||||
#define MEM_MAGIC ISC_MAGIC('M', 'e', 'm', 'C')
|
||||
@@ -145,6 +148,7 @@ struct isc__mem {
|
||||
size_t max_size;
|
||||
bool checkfree;
|
||||
struct stats *stats;
|
||||
struct stats file_stats[STATS_BUCKETS];
|
||||
isc_refcount_t references;
|
||||
char name[16];
|
||||
void *tag;
|
||||
@@ -185,19 +189,16 @@ struct isc__mem {
|
||||
|
||||
struct isc__mempool {
|
||||
/* always unlocked */
|
||||
isc_mempool_t common; /*%< common header of mempool's */
|
||||
isc_mutex_t *lock; /*%< optional lock */
|
||||
isc__mem_t *mctx; /*%< our memory context */
|
||||
/*%< locked via the memory context's lock */
|
||||
isc_mempool_t common; /*%< common header of mempool's */
|
||||
isc__mem_t *mctx; /*%< our memory context */
|
||||
ISC_LINK(isc__mempool_t) link; /*%< next pool in this mem context */
|
||||
/*%< optionally locked from here down */
|
||||
element *items; /*%< low water item list */
|
||||
size_t size; /*%< size of each item on this pool */
|
||||
unsigned int maxalloc; /*%< max number of items allowed */
|
||||
unsigned int allocated; /*%< # of items currently given out */
|
||||
unsigned int freecount; /*%< # of items on reserved list */
|
||||
unsigned int freemax; /*%< # of items allowed on free list */
|
||||
unsigned int fillcount; /*%< # of items to fetch on each fill */
|
||||
element *items; /*%< low water item list */
|
||||
size_t size; /*%< size of each item on this pool */
|
||||
unsigned int maxalloc; /*%< max number of items allowed */
|
||||
unsigned int allocated; /*%< # of items currently given out */
|
||||
unsigned int freecount; /*%< # of items on reserved list */
|
||||
unsigned int freemax; /*%< # of items allowed on free list */
|
||||
unsigned int fillcount; /*%< # of items to fetch on each fill */
|
||||
/*%< Stats only. */
|
||||
unsigned int gets; /*%< # of requests to this pool */
|
||||
/*%< Debugging only. */
|
||||
@@ -658,11 +659,29 @@ mem_put(isc__mem_t *ctx, void *mem, size_t size) {
|
||||
(ctx->memfree)(mem);
|
||||
}
|
||||
|
||||
static struct stats *
|
||||
stats_file_bucket(isc__mem_t *ctx, const char *file) {
|
||||
uint32_t h = isc_hash32(file, strlen(file), false);
|
||||
int idx = h % STATS_BUCKETS;
|
||||
|
||||
while (ctx->file_stats[idx].file != NULL &&
|
||||
strcmp(ctx->file_stats[idx].file, file) != 0)
|
||||
{
|
||||
idx = (idx + 1) % STATS_BUCKETS;
|
||||
}
|
||||
|
||||
if (ctx->file_stats[idx].file == NULL) {
|
||||
ctx->file_stats[idx].file = strdup(file);
|
||||
}
|
||||
|
||||
return (&ctx->file_stats[idx]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Update internal counters after a memory get.
|
||||
*/
|
||||
static inline void
|
||||
mem_getstats(isc__mem_t *ctx, size_t size) {
|
||||
mem_getstats(isc__mem_t *ctx, size_t size FLARG) {
|
||||
ctx->total += size;
|
||||
ctx->inuse += size;
|
||||
|
||||
@@ -681,13 +700,17 @@ mem_getstats(isc__mem_t *ctx, size_t size) {
|
||||
if (ctx->malloced > ctx->maxmalloced) {
|
||||
ctx->maxmalloced = ctx->malloced;
|
||||
}
|
||||
|
||||
UNUSED(line);
|
||||
struct stats *stats = stats_file_bucket(ctx, file);
|
||||
atomic_fetch_add_release(&stats->inuse, size);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Update internal counters after a memory put.
|
||||
*/
|
||||
static inline void
|
||||
mem_putstats(isc__mem_t *ctx, void *ptr, size_t size) {
|
||||
mem_putstats(isc__mem_t *ctx, void *ptr, size_t size FLARG) {
|
||||
UNUSED(ptr);
|
||||
|
||||
INSIST(ctx->inuse >= size);
|
||||
@@ -704,6 +727,10 @@ mem_putstats(isc__mem_t *ctx, void *ptr, size_t size) {
|
||||
size += 1;
|
||||
#endif /* if ISC_MEM_CHECKOVERRUN */
|
||||
ctx->malloced -= size;
|
||||
|
||||
UNUSED(line);
|
||||
struct stats *stats = stats_file_bucket(ctx, file);
|
||||
atomic_fetch_sub_release(&stats->inuse, size);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -815,6 +842,10 @@ mem_create(isc_mem_t **ctxp, unsigned int flags) {
|
||||
ctx->debuglist = NULL;
|
||||
ctx->debuglistcnt = 0;
|
||||
#endif /* if ISC_MEM_TRACKLINES */
|
||||
for (size_t i = 0; i < STATS_BUCKETS; i++) {
|
||||
ctx->file_stats[i] = (struct stats){ 0 };
|
||||
atomic_init(&ctx->file_stats[i].inuse, 0);
|
||||
}
|
||||
ISC_LIST_INIT(ctx->pools);
|
||||
ctx->poolcnt = 0;
|
||||
ctx->freelists = NULL;
|
||||
@@ -879,6 +910,11 @@ destroy(isc__mem_t *ctx) {
|
||||
ctx->common.magic = 0;
|
||||
|
||||
INSIST(ISC_LIST_EMPTY(ctx->pools));
|
||||
for (i = 0; i < (size_t)STATS_BUCKETS; i++) {
|
||||
if (ctx->file_stats[i].file != NULL) {
|
||||
free(ctx->file_stats[i].file);
|
||||
}
|
||||
}
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (ISC_UNLIKELY(ctx->debuglist != NULL)) {
|
||||
@@ -1011,7 +1047,7 @@ isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(ctx, ptr, size);
|
||||
} else {
|
||||
mem_putstats(ctx, ptr, size);
|
||||
mem_putstats(ctx, ptr, size FLARG_PASS);
|
||||
mem_put(ctx, ptr, size);
|
||||
}
|
||||
MCTXUNLOCK(ctx);
|
||||
@@ -1068,7 +1104,7 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
ptr = mem_get(ctx, size);
|
||||
MCTXLOCK(ctx);
|
||||
if (ptr != NULL) {
|
||||
mem_getstats(ctx, size);
|
||||
mem_getstats(ctx, size FLARG_PASS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1130,7 +1166,7 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(ctx, ptr, size);
|
||||
} else {
|
||||
mem_putstats(ctx, ptr, size);
|
||||
mem_putstats(ctx, ptr, size FLARG_PASS);
|
||||
mem_put(ctx, ptr, size);
|
||||
}
|
||||
|
||||
@@ -1259,8 +1295,7 @@ isc_mem_stats(isc_mem_t *ctx0, FILE *out) {
|
||||
#endif /* if ISC_MEMPOOL_NAMES */
|
||||
(unsigned long)pool->size, pool->maxalloc,
|
||||
pool->allocated, pool->freecount, pool->freemax,
|
||||
pool->fillcount, pool->gets,
|
||||
(pool->lock == NULL ? "N" : "Y"));
|
||||
pool->fillcount, pool->gets, "N");
|
||||
pool = ISC_LIST_NEXT(pool, link);
|
||||
}
|
||||
|
||||
@@ -1311,7 +1346,7 @@ isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
|
||||
MCTXLOCK(ctx);
|
||||
si = mem_allocateunlocked((isc_mem_t *)ctx, size);
|
||||
if (((ctx->flags & ISC_MEMFLAG_INTERNAL) == 0)) {
|
||||
mem_getstats(ctx, si[-1].u.size);
|
||||
mem_getstats(ctx, si[-1].u.size FLARG_PASS);
|
||||
}
|
||||
|
||||
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
|
||||
@@ -1410,7 +1445,7 @@ isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
|
||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(ctx, si, size);
|
||||
} else {
|
||||
mem_putstats(ctx, si, size);
|
||||
mem_putstats(ctx, si, size FLARG_PASS);
|
||||
mem_put(ctx, si, size);
|
||||
}
|
||||
|
||||
@@ -1655,7 +1690,6 @@ isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
|
||||
|
||||
mpctx->common.impmagic = MEMPOOL_MAGIC;
|
||||
mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
|
||||
mpctx->lock = NULL;
|
||||
mpctx->mctx = mctx;
|
||||
/*
|
||||
* Mempools are stored as a linked list of element.
|
||||
@@ -1691,15 +1725,7 @@ isc_mempool_setname(isc_mempool_t *mpctx0, const char *name) {
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
#if ISC_MEMPOOL_NAMES
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
strlcpy(mpctx->name, name, sizeof(mpctx->name));
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
#else /* if ISC_MEMPOOL_NAMES */
|
||||
UNUSED(mpctx);
|
||||
UNUSED(name);
|
||||
@@ -1713,7 +1739,6 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
|
||||
isc__mempool_t *mpctx;
|
||||
isc__mem_t *mctx;
|
||||
isc_mutex_t *lock;
|
||||
element *item;
|
||||
|
||||
mpctx = (isc__mempool_t *)*mpctxp;
|
||||
@@ -1729,12 +1754,6 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
|
||||
mctx = mpctx->mctx;
|
||||
|
||||
lock = mpctx->lock;
|
||||
|
||||
if (lock != NULL) {
|
||||
LOCK(lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return any items on the free list
|
||||
*/
|
||||
@@ -1748,7 +1767,8 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(mctx, item, mpctx->size);
|
||||
} else {
|
||||
mem_putstats(mctx, item, mpctx->size);
|
||||
mem_putstats(mctx, item, mpctx->size, __FILE__,
|
||||
__LINE__);
|
||||
mem_put(mctx, item, mpctx->size);
|
||||
}
|
||||
}
|
||||
@@ -1767,25 +1787,9 @@ isc_mempool_destroy(isc_mempool_t **mpctxp) {
|
||||
|
||||
isc_mem_put((isc_mem_t *)mpctx->mctx, mpctx, sizeof(isc__mempool_t));
|
||||
|
||||
if (lock != NULL) {
|
||||
UNLOCK(lock);
|
||||
}
|
||||
|
||||
*mpctxp = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
isc_mempool_associatelock(isc_mempool_t *mpctx0, isc_mutex_t *lock) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
REQUIRE(lock != NULL);
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
REQUIRE(mpctx->lock == NULL);
|
||||
|
||||
mpctx->lock = lock;
|
||||
}
|
||||
|
||||
#if __SANITIZE_ADDRESS__
|
||||
void *
|
||||
isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
@@ -1854,10 +1858,6 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
|
||||
mctx = mpctx->mctx;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't let the caller go over quota
|
||||
*/
|
||||
@@ -1878,7 +1878,8 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
} else {
|
||||
item = mem_get(mctx, mpctx->size);
|
||||
if (item != NULL) {
|
||||
mem_getstats(mctx, mpctx->size);
|
||||
mem_getstats(mctx,
|
||||
mpctx->size FLARG_PASS);
|
||||
}
|
||||
}
|
||||
if (ISC_UNLIKELY(item == NULL)) {
|
||||
@@ -1906,10 +1907,6 @@ isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
|
||||
mpctx->allocated++;
|
||||
|
||||
out:
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if (ISC_UNLIKELY(((isc_mem_debugging & TRACE_OR_RECORD) != 0) &&
|
||||
item != NULL)) {
|
||||
@@ -1932,10 +1929,6 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
isc__mem_t *mctx = mpctx->mctx;
|
||||
element *item;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
INSIST(mpctx->allocated > 0);
|
||||
mpctx->allocated--;
|
||||
|
||||
@@ -1955,13 +1948,10 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
if ((mctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
||||
mem_putunlocked(mctx, mem, mpctx->size);
|
||||
} else {
|
||||
mem_putstats(mctx, mem, mpctx->size);
|
||||
mem_putstats(mctx, mem, mpctx->size FLARG_PASS);
|
||||
mem_put(mctx, mem, mpctx->size);
|
||||
}
|
||||
MCTXUNLOCK(mctx);
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1972,10 +1962,6 @@ isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
|
||||
item = (element *)mem;
|
||||
item->next = mpctx->items;
|
||||
mpctx->items = item;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __SANITIZE_ADDRESS__ */
|
||||
@@ -1990,15 +1976,7 @@ isc_mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
mpctx->freemax = limit;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
@@ -2006,19 +1984,8 @@ isc_mempool_getfreemax(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int freemax;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
freemax = mpctx->freemax;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
return (freemax);
|
||||
return (mpctx->freemax);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
@@ -2026,19 +1993,8 @@ isc_mempool_getfreecount(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int freecount;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
freecount = mpctx->freecount;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
return (freecount);
|
||||
return (mpctx->freecount);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2048,15 +2004,7 @@ isc_mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
mpctx->maxalloc = limit;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
@@ -2064,19 +2012,8 @@ isc_mempool_getmaxalloc(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int maxalloc;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
maxalloc = mpctx->maxalloc;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
return (maxalloc);
|
||||
return (mpctx->maxalloc);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
@@ -2084,19 +2021,8 @@ isc_mempool_getallocated(isc_mempool_t *mpctx0) {
|
||||
REQUIRE(VALID_MEMPOOL(mpctx0));
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
unsigned int allocated;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
allocated = mpctx->allocated;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
return (allocated);
|
||||
return (mpctx->allocated);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2106,15 +2032,7 @@ isc_mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
mpctx->fillcount = limit;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
@@ -2123,19 +2041,7 @@ isc_mempool_getfillcount(isc_mempool_t *mpctx0) {
|
||||
|
||||
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
|
||||
|
||||
unsigned int fillcount;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
LOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
fillcount = mpctx->fillcount;
|
||||
|
||||
if (mpctx->lock != NULL) {
|
||||
UNLOCK(mpctx->lock);
|
||||
}
|
||||
|
||||
return (fillcount);
|
||||
return (mpctx->fillcount);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2379,7 +2285,7 @@ json_renderctx(isc__mem_t *ctx, summarystat_t *summary, json_object *array) {
|
||||
REQUIRE(summary != NULL);
|
||||
REQUIRE(array != NULL);
|
||||
|
||||
json_object *ctxobj, *obj;
|
||||
json_object *ctxobj, *obj, *fileobj, *filearray;
|
||||
char buf[1024];
|
||||
|
||||
MCTXLOCK(ctx);
|
||||
@@ -2406,6 +2312,30 @@ json_renderctx(isc__mem_t *ctx, summarystat_t *summary, json_object *array) {
|
||||
ctxobj = json_object_new_object();
|
||||
CHECKMEM(ctxobj);
|
||||
|
||||
filearray = json_object_new_array();
|
||||
CHECKMEM(filearray);
|
||||
|
||||
for (int i = 0; i < (int)STATS_BUCKETS; i++) {
|
||||
if (ctx->file_stats[i].file == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fileobj = json_object_new_object();
|
||||
CHECKMEM(fileobj);
|
||||
|
||||
obj = json_object_new_string(ctx->file_stats[i].file);
|
||||
CHECKMEM(obj);
|
||||
json_object_object_add(fileobj, "file", obj);
|
||||
|
||||
obj = json_object_new_int64(ctx->file_stats[i].inuse);
|
||||
CHECKMEM(obj);
|
||||
json_object_object_add(fileobj, "inuse", obj);
|
||||
|
||||
json_object_array_add(filearray, fileobj);
|
||||
}
|
||||
|
||||
json_object_object_add(ctxobj, "files", filearray);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%p", ctx);
|
||||
obj = json_object_new_string(buf);
|
||||
CHECKMEM(obj);
|
||||
|
||||
@@ -629,12 +629,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;
|
||||
|
||||
+8
-28
@@ -319,21 +319,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);
|
||||
|
||||
@@ -415,14 +400,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);
|
||||
isc_mutex_destroy(&worker->lock);
|
||||
@@ -452,12 +437,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));
|
||||
@@ -1046,7 +1025,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);
|
||||
@@ -1054,7 +1034,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);
|
||||
@@ -1260,7 +1240,7 @@ 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);
|
||||
@@ -2379,7 +2359,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 };
|
||||
@@ -2415,7 +2395,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) {
|
||||
|
||||
@@ -424,70 +424,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;
|
||||
size_t size = ITEM_SIZE;
|
||||
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]);
|
||||
size = size / 2;
|
||||
}
|
||||
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 */
|
||||
|
||||
/*
|
||||
@@ -507,8 +443,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,
|
||||
|
||||
@@ -398,7 +398,6 @@ isc_mem_stats
|
||||
isc_mem_total
|
||||
isc_mem_waterack
|
||||
isc_meminfo_totalphys
|
||||
isc_mempool_associatelock
|
||||
isc_mempool_create
|
||||
isc_mempool_destroy
|
||||
isc_mempool_getallocated
|
||||
|
||||
Reference in New Issue
Block a user