Compare commits

...
59 changed files with 1450 additions and 5060 deletions
Vendored
+10 -10
View File
@@ -1,6 +1,6 @@
# generated automatically by aclocal 1.16.1 -*- Autoconf -*-
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -12,9 +12,9 @@
# PARTICULAR PURPOSE.
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2)
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
dnl serial 11 (pkg-config-0.29.1)
dnl
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
dnl
@@ -55,7 +55,7 @@ dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.2])
[m4_define([PKG_MACROS_VERSION], [0.29.1])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
@@ -156,7 +156,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $2])
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -166,11 +166,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
@@ -187,7 +187,7 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[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
+1 -1
View File
@@ -263,7 +263,7 @@ received(unsigned int bytes, isc_sockaddr_t *from, dig_query_t *query) {
printf(";; Query time: %ld msec\n", (long) diff / 1000);
printf(";; SERVER: %s(%s)\n", fromtext, query->servname);
time(&tnow);
#if defined(ISC_PLATFORM_USETHREADS) && !defined(WIN32)
#if !defined(WIN32)
(void)localtime_r(&tnow, &tmnow);
#else
tmnow = *localtime(&tnow);
+3 -21
View File
@@ -720,11 +720,7 @@ parse_command_line(int argc, char *argv[]) {
printf("linked to zlib version: %s\n",
zlibVersion());
#endif
#ifdef ISC_PLATFORM_USETHREADS
printf("threads support is enabled\n");
#else
printf("threads support is disabled\n");
#endif
exit(0);
case 'x':
/* Obsolete. No longer in use. Ignore. */
@@ -776,18 +772,14 @@ create_managers(void) {
INSIST(named_g_cpus_detected > 0);
#ifdef ISC_PLATFORM_USETHREADS
if (named_g_cpus == 0)
named_g_cpus = named_g_cpus_detected;
named_g_cpus = named_g_cpus_detected * 1.5;
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
"found %u CPU%s, using %u worker thread%s",
named_g_cpus_detected,
named_g_cpus_detected == 1 ? "" : "s",
named_g_cpus, named_g_cpus == 1 ? "" : "s");
#else
named_g_cpus = 1;
#endif
#ifdef WIN32
named_g_udpdisp = 1;
#else
@@ -795,17 +787,15 @@ create_managers(void) {
if (named_g_cpus_detected == 1)
named_g_udpdisp = 1;
else
named_g_udpdisp = named_g_cpus_detected - 1;
named_g_udpdisp = named_g_cpus_detected;
}
if (named_g_udpdisp > named_g_cpus)
named_g_udpdisp = named_g_cpus;
#endif
#ifdef ISC_PLATFORM_USETHREADS
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
"using %u UDP listener%s per interface",
named_g_udpdisp, named_g_udpdisp == 1 ? "" : "s");
#endif
result = isc_taskmgr_create(named_g_mctx, named_g_cpus, 0,
&named_g_taskmgr);
@@ -832,7 +822,7 @@ create_managers(void) {
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
isc__socketmgr_maxudp(named_g_socketmgr, maxudp);
isc_socketmgr_maxudp(named_g_socketmgr, maxudp);
result = isc_socketmgr_getmaxsockets(named_g_socketmgr, &socks);
if (result == ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
@@ -917,12 +907,10 @@ setup(void) {
isc_mem_free(named_g_mctx, instance);
#endif /* HAVE_LIBSCF */
#ifdef ISC_PLATFORM_USETHREADS
/*
* Check for the number of cpu's before named_os_chroot().
*/
named_g_cpus_detected = isc_os_ncpus();
#endif
named_os_chroot(named_g_chrootdir);
@@ -1049,15 +1037,9 @@ setup(void) {
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
"linked to zlib version: %s", zlibVersion());
#endif
#ifdef ISC_PLATFORM_USETHREADS
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
"threads support is enabled");
#else
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
"threads support is disabled");
#endif
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_MAIN, ISC_LOG_NOTICE,
+1 -6
View File
@@ -8000,7 +8000,7 @@ load_configuration(const char *filename, named_server_t *server,
"less than 128 UDP sockets available after "
"applying 'reserved-sockets' and 'maxsockets'");
}
isc__socketmgr_setreserved(named_g_socketmgr, reserved);
isc_socketmgr_setreserved(named_g_socketmgr, reserved);
#ifdef HAVE_GEOIP
/*
@@ -11208,7 +11208,6 @@ named_server_status(named_server_t *server, isc_buffer_t **text) {
}
CHECK(putstr(text, line));
#ifdef ISC_PLATFORM_USETHREADS
snprintf(line, sizeof(line), "CPUs found: %u\n", named_g_cpus_detected);
CHECK(putstr(text, line));
@@ -11218,10 +11217,6 @@ named_server_status(named_server_t *server, isc_buffer_t **text) {
snprintf(line, sizeof(line), "UDP listeners per interface: %u\n",
named_g_udpdisp);
CHECK(putstr(text, line));
#else
snprintf(line, sizeof(line), "CPUs found: N/A (threads disabled)\n");
CHECK(putstr(text, line));
#endif
snprintf(line, sizeof(line), "number of zones: %u (%u automatic)\n",
zonecount, automatic);
-14
View File
@@ -25,8 +25,6 @@
#define sleep(x) Sleep(1000 * x)
#endif
#ifdef ISC_PLATFORM_USETHREADS
isc_rwlock_t lock;
static isc_threadresult_t
@@ -130,15 +128,3 @@ main(int argc, char *argv[]) {
return (0);
}
#else
int
main(int argc, char *argv[]) {
UNUSED(argc);
UNUSED(argv);
fprintf(stderr, "This test requires threads.\n");
return(1);
}
#endif
Vendored
+375 -142
View File
@@ -808,7 +808,6 @@ INSTALL_LIBRARY
ISC_THREAD_DIR
THREADOPTSRCS
THREADOPTOBJS
ISC_PLATFORM_USETHREADS
ALWAYS_DEFINES
CHECK_DSA
GEOIPLINKOBJS
@@ -907,6 +906,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1071,6 +1071,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}'
@@ -1323,6 +1324,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=* \
@@ -1460,7 +1470,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.
@@ -1613,6 +1623,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]
@@ -12092,11 +12103,6 @@ $as_echo "#define ENABLE_AFL 1" >>confdefs.h
fi
case "$enable_afl" in
yes)
LIBS="$LIBS -lpthread"
;;
esac
#
# Make very sure that these are the first files processed by
@@ -15687,8 +15693,274 @@ done
case "$host" in
*solaris-*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lrt" >&5
*-freebsd*)
CC="$CC -pthread"
CCOPT="$CCOPT -pthread"
CCNOOPT="$CCNOOPT -pthread"
STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
;;
*-openbsd*)
CC="$CC -pthread"
CCOPT="$CCOPT -pthread"
CCNOOPT="$CCNOOPT -pthread"
;;
*-solaris*)
LIBS="$LIBS -lthread"
;;
*-ibm-aix*)
STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
;;
esac
else
case $host in
*-dec-osf*)
CC="$CC -pthread"
CCOPT="$CCOPT -pthread"
CCNOOPT="$CCNOOPT -pthread"
;;
*-solaris*)
CC="$CC -mt"
CCOPT="$CCOPT -mt"
CCNOOPT="$CCNOOPT -mt"
;;
*-ibm-aix*)
STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
;;
*-sco-sysv*uw*|*-*-sysv*UnixWare*)
CC="$CC -Kthread"
CCOPT="$CCOPT -Kthread"
CCNOOPT="$CCNOOPT -Kthread"
;;
*-*-sysv*OpenUNIX*)
CC="$CC -Kpthread"
CCOPT="$CCOPT -Kpthread"
CCNOOPT="$CCNOOPT -Kpthread"
;;
esac
fi
ALWAYS_DEFINES="-D_REENTRANT"
THREADOPTOBJS='${THREADOPTOBJS}'
THREADOPTSRCS='${THREADOPTSRCS}'
thread_dir=pthreads
#
# We'd like to use sigwait() too
#
ac_fn_c_check_func "$LINENO" "sigwait" "ac_cv_func_sigwait"
if test "x$ac_cv_func_sigwait" = xyes; then :
$as_echo "#define HAVE_SIGWAIT 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigwait in -lc" >&5
$as_echo_n "checking for sigwait in -lc... " >&6; }
if ${ac_cv_lib_c_sigwait+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lc $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sigwait ();
int
main ()
{
return sigwait ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_c_sigwait=yes
else
ac_cv_lib_c_sigwait=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_sigwait" >&5
$as_echo "$ac_cv_lib_c_sigwait" >&6; }
if test "x$ac_cv_lib_c_sigwait" = xyes; then :
$as_echo "#define HAVE_SIGWAIT 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigwait in -lpthread" >&5
$as_echo_n "checking for sigwait in -lpthread... " >&6; }
if ${ac_cv_lib_pthread_sigwait+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sigwait ();
int
main ()
{
return sigwait ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pthread_sigwait=yes
else
ac_cv_lib_pthread_sigwait=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_sigwait" >&5
$as_echo "$ac_cv_lib_pthread_sigwait" >&6; }
if test "x$ac_cv_lib_pthread_sigwait" = xyes; then :
$as_echo "#define HAVE_SIGWAIT 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _Psigwait in -lpthread" >&5
$as_echo_n "checking for _Psigwait in -lpthread... " >&6; }
if ${ac_cv_lib_pthread__Psigwait+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char _Psigwait ();
int
main ()
{
return _Psigwait ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pthread__Psigwait=yes
else
ac_cv_lib_pthread__Psigwait=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread__Psigwait" >&5
$as_echo "$ac_cv_lib_pthread__Psigwait" >&6; }
if test "x$ac_cv_lib_pthread__Psigwait" = xyes; then :
$as_echo "#define HAVE_SIGWAIT 1" >>confdefs.h
fi
fi
fi
fi
ac_fn_c_check_func "$LINENO" "pthread_attr_getstacksize" "ac_cv_func_pthread_attr_getstacksize"
if test "x$ac_cv_func_pthread_attr_getstacksize" = xyes; then :
$as_echo "#define HAVE_PTHREAD_ATTR_GETSTACKSIZE 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "pthread_attr_setstacksize" "ac_cv_func_pthread_attr_setstacksize"
if test "x$ac_cv_func_pthread_attr_setstacksize" = xyes; then :
$as_echo "#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1" >>confdefs.h
fi
# Check whether --with-locktype was given.
if test "${with_locktype+set}" = set; then :
withval=$with_locktype; locktype="$withval"
else
locktype="adaptive"
fi
case "$locktype" in
adaptive)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_MUTEX_ADAPTIVE_NP" >&5
$as_echo_n "checking for PTHREAD_MUTEX_ADAPTIVE_NP... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <pthread.h>
int
main ()
{
return (PTHREAD_MUTEX_ADAPTIVE_NP);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using adaptive lock type" >&5
$as_echo "using adaptive lock type" >&6; }
$as_echo "#define HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using standard lock type" >&5
$as_echo "using standard lock type" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
standard)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using standard lock type" >&5
$as_echo "using standard lock type" >&6; }
;;
*)
as_fn_error $? "You must specify \"adaptive\" or \"standard\" for --with-locktype." "$LINENO" 5
;;
esac
for ac_header in sched.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default"
if test "x$ac_cv_header_sched_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SCHED_H 1
_ACEOF
fi
done
case "$host" in
*solaris-*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lrt" >&5
$as_echo_n "checking for sched_yield in -lrt... " >&6; }
if ${ac_cv_lib_rt_sched_yield+:} false; then :
$as_echo_n "(cached) " >&6
@@ -15733,10 +16005,10 @@ _ACEOF
fi
;;
esac
;;
esac
for ac_func in sched_yield pthread_yield pthread_yield_np
for ac_func in sched_yield pthread_yield pthread_yield_np
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -15749,15 +16021,15 @@ fi
done
#
# Additional OS-specific issues related to pthreads and sigwait.
#
case "$host" in
#
# Additional OS-specific issues related to pthreads and sigwait.
# One more place to look for sigwait.
#
case "$host" in
#
# One more place to look for sigwait.
#
*-freebsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigwait in -lc_r" >&5
*-freebsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigwait in -lc_r" >&5
$as_echo_n "checking for sigwait in -lc_r... " >&6; }
if ${ac_cv_lib_c_r_sigwait+:} false; then :
$as_echo_n "(cached) " >&6
@@ -15798,60 +16070,60 @@ if test "x$ac_cv_lib_c_r_sigwait" = xyes; then :
fi
case $host in
*-freebsd5.[012]|*-freebsd5.[012].*);;
*-freebsd5.[3456789]|*-freebsd5.[3456789].*)
$as_echo "#define NEED_PTHREAD_SCOPE_SYSTEM 1" >>confdefs.h
;;
*-freebsd6.*)
$as_echo "#define NEED_PTHREAD_SCOPE_SYSTEM 1" >>confdefs.h
;;
esac
;;
#
# BSDI 3.0 through 4.0.1 needs pthread_init() to be
# called before certain pthreads calls. This is deprecated
# in BSD/OS 4.1.
#
*-bsdi3.*|*-bsdi4.0*)
$as_echo "#define NEED_PTHREAD_INIT 1" >>confdefs.h
case $host in
*-freebsd5.[012]|*-freebsd5.[012].*);;
*-freebsd5.[3456789]|*-freebsd5.[3456789].*)
$as_echo "#define NEED_PTHREAD_SCOPE_SYSTEM 1" >>confdefs.h
;;
#
# LinuxThreads requires some changes to the way we
# deal with signals.
#
*-linux*)
$as_echo "#define HAVE_LINUXTHREADS 1" >>confdefs.h
*-freebsd6.*)
$as_echo "#define NEED_PTHREAD_SCOPE_SYSTEM 1" >>confdefs.h
;;
#
# Ensure the right sigwait() semantics on Solaris and make
# sure we call pthread_setconcurrency.
#
*-solaris*)
$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
esac
;;
#
# BSDI 3.0 through 4.0.1 needs pthread_init() to be
# called before certain pthreads calls. This is deprecated
# in BSD/OS 4.1.
#
*-bsdi3.*|*-bsdi4.0*)
$as_echo "#define NEED_PTHREAD_INIT 1" >>confdefs.h
ac_fn_c_check_func "$LINENO" "pthread_setconcurrency" "ac_cv_func_pthread_setconcurrency"
;;
#
# LinuxThreads requires some changes to the way we
# deal with signals.
#
*-linux*)
$as_echo "#define HAVE_LINUXTHREADS 1" >>confdefs.h
;;
#
# Ensure the right sigwait() semantics on Solaris and make
# sure we call pthread_setconcurrency.
#
*-solaris*)
$as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
ac_fn_c_check_func "$LINENO" "pthread_setconcurrency" "ac_cv_func_pthread_setconcurrency"
if test "x$ac_cv_func_pthread_setconcurrency" = xyes; then :
$as_echo "#define CALL_PTHREAD_SETCONCURRENCY 1" >>confdefs.h
fi
;;
#
# UnixWare does things its own way.
#
*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
$as_echo "#define HAVE_UNIXWARE_SIGWAIT 1" >>confdefs.h
;;
#
# UnixWare does things its own way.
#
*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
$as_echo "#define HAVE_UNIXWARE_SIGWAIT 1" >>confdefs.h
;;
esac
;;
esac
# Look for functions relating to thread naming
for ac_func in pthread_setname_np pthread_set_name_np
# Look for functions relating to thread naming
for ac_func in pthread_setname_np pthread_set_name_np
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -15863,7 +16135,7 @@ _ACEOF
fi
done
for ac_header in pthread_np.h
for ac_header in pthread_np.h
do :
ac_fn_c_check_header_compile "$LINENO" "pthread_np.h" "ac_cv_header_pthread_np_h" "#include <pthread.h>
"
@@ -15877,25 +16149,16 @@ fi
done
#
# Look for sysconf to allow detection of the number of processors.
#
ac_fn_c_check_func "$LINENO" "sysconf" "ac_cv_func_sysconf"
#
# Look for sysconf to allow detection of the number of processors.
#
ac_fn_c_check_func "$LINENO" "sysconf" "ac_cv_func_sysconf"
if test "x$ac_cv_func_sysconf" = xyes; then :
$as_echo "#define HAVE_SYSCONF 1" >>confdefs.h
fi
else
ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
thread_dir=nothreads
THREADOPTOBJS=""
THREADOPTSRCS=""
ALWAYS_DEFINES=""
fi
@@ -17531,23 +17794,6 @@ if test "x$ac_cv_func_getc_unlocked" = xyes; then :
fi
#
# Indicate what the final decision was regarding threads.
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with threads" >&5
$as_echo_n "checking whether to build with threads... " >&6; }
if $use_threads; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
#
# End of pthreads stuff.
#
#
# Large File
#
@@ -20287,14 +20533,12 @@ fi
#
# CPU relax (for spin locks)
#
if $use_threads
then
case "$host" in
i[3456]86-*)
# x86_32
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"rep; nop\"); works" >&5
case "$host" in
i[3456]86-*)
# x86_32
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"rep; nop\"); works" >&5
$as_echo_n "checking if asm(\"rep; nop\"); works... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
@@ -20308,18 +20552,18 @@ _ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
x86_64-*|amd64-*)
# x86_64
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"rep; nop\"); works" >&5
;;
x86_64-*|amd64-*)
# x86_64
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"rep; nop\"); works" >&5
$as_echo_n "checking if asm(\"rep; nop\"); works... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
@@ -20333,18 +20577,18 @@ _ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
ia64-*)
# ia64
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"hint @pause\"); works" >&5
;;
ia64-*)
# ia64
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if asm(\"hint @pause\"); works" >&5
$as_echo_n "checking if asm(\"hint @pause\"); works... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
@@ -20358,28 +20602,28 @@ _ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
;;
sparc-*)
# sparc
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if cpu_relax(); or __cpu_relax(); works" >&5
;;
sparc-*)
# sparc
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if cpu_relax(); or __cpu_relax(); works" >&5
$as_echo_n "checking if cpu_relax(); or __cpu_relax(); works... " >&6; }
ac_fn_c_check_func "$LINENO" "cpu_relax" "ac_cv_func_cpu_relax"
ac_fn_c_check_func "$LINENO" "cpu_relax" "ac_cv_func_cpu_relax"
if test "x$ac_cv_func_cpu_relax" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP cpu_relax()"
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP cpu_relax()"
else
ac_fn_c_check_func "$LINENO" "__cpu_relax" "ac_cv_func___cpu_relax"
if test "x$ac_cv_func___cpu_relax" = xyes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP __cpu_relax()"
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP __cpu_relax()"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
@@ -20387,9 +20631,8 @@ fi
fi
;;
esac
fi
;;
esac
@@ -20702,9 +20945,6 @@ DNSTAPOBJS=
DNSTAPTARGETS=
DNSTAP_PB_C_H=
if test "x$use_dnstap" != "xno"; then
if ! $use_threads; then
as_fn_error $? "Dnstap requires threads." "$LINENO" 5
fi
# Check whether --with-protobuf-c was given.
if test "${with_protobuf_c+set}" = set; then :
@@ -21843,8 +22083,8 @@ case $with_libidn2 in #(
yes) :
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libidn2" >&5
$as_echo_n "checking for libidn2... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBIDN2" >&5
$as_echo_n "checking for LIBIDN2... " >&6; }
if test -n "$LIBIDN2_CFLAGS"; then
pkg_cv_LIBIDN2_CFLAGS="$LIBIDN2_CFLAGS"
@@ -21884,7 +22124,7 @@ fi
if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -21911,7 +22151,7 @@ Alternatively, you may set the environment variables LIBIDN2_CFLAGS
and LIBIDN2_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 "$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;}
@@ -22051,8 +22291,8 @@ case $with_cmocka in #(
yes) :
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka" >&5
$as_echo_n "checking for cmocka... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CMOCKA" >&5
$as_echo_n "checking for CMOCKA... " >&6; }
if test -n "$CMOCKA_CFLAGS"; then
pkg_cv_CMOCKA_CFLAGS="$CMOCKA_CFLAGS"
@@ -22092,7 +22332,7 @@ fi
if test $pkg_failed = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -22119,7 +22359,7 @@ Alternatively, you may set the environment variables CMOCKA_CFLAGS
and CMOCKA_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 "$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;}
@@ -22392,9 +22632,6 @@ fi
case "$use_tuning" in
large)
if ! $use_threads; then
as_fn_error $? "Large-system tuning requires threads." "$LINENO" 5
fi
$as_echo "#define TUNE_LARGE 1" >>confdefs.h
@@ -26154,11 +26391,8 @@ report() {
echo "Configuration summary:"
echo "-------------------------------------------------------------------------------"
echo "Optional features enabled:"
if $use_threads; then
echo " Multiprocessing support (--enable-threads)"
if test "yes" = "$enable_full_report" -o "standard" = "$locktype"; then
echo " Mutex lock type: $locktype"
fi
if test "yes" = "$enable_full_report" -o "standard" = "$locktype"; then
echo " Mutex lock type: $locktype"
fi
test "large" = "$use_tuning" && echo " Large-system tuning (--with-tuning)"
test "no" = "$use_dnstap" || \
@@ -26223,7 +26457,6 @@ report() {
echo "-------------------------------------------------------------------------------"
echo "Features disabled or unavailable on this platform:"
$use_threads || echo " Multiprocessing support (--enable-threads)"
test "no" = "$enable_ipv6" -o "no" = "$found_ipv6" && \
echo " IPv6 support (--enable-ipv6)"
test "large" = "$use_tuning" || echo " Large-system tuning (--with-tuning)"
+208 -148
View File
@@ -105,11 +105,6 @@ AC_ARG_ENABLE(afl,
[default=no]]),
[AC_DEFINE([ENABLE_AFL], [1],
[Define to enable American Fuzzy Lop test harness])])
case "$enable_afl" in
yes)
LIBS="$LIBS -lpthread"
;;
esac
#
# Make very sure that these are the first files processed by
@@ -950,83 +945,175 @@ then
AC_CHECK_HEADERS(sched.h)
case "$host" in
*solaris-*)
AC_CHECK_LIB(rt, sched_yield)
*-freebsd*)
CC="$CC -pthread"
CCOPT="$CCOPT -pthread"
CCNOOPT="$CCNOOPT -pthread"
STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
;;
*-openbsd*)
CC="$CC -pthread"
CCOPT="$CCOPT -pthread"
CCNOOPT="$CCNOOPT -pthread"
;;
*-solaris*)
LIBS="$LIBS -lthread"
;;
*-ibm-aix*)
STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
;;
esac
AC_CHECK_FUNCS(sched_yield pthread_yield pthread_yield_np)
#
# Additional OS-specific issues related to pthreads and sigwait.
#
case "$host" in
#
# One more place to look for sigwait.
#
*-freebsd*)
AC_CHECK_LIB(c_r, sigwait, AC_DEFINE(HAVE_SIGWAIT),)
case $host in
*-freebsd5.[[012]]|*-freebsd5.[[012]].*);;
*-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*)
AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
;;
*-freebsd6.*)
AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
;;
esac
;;
#
# BSDI 3.0 through 4.0.1 needs pthread_init() to be
# called before certain pthreads calls. This is deprecated
# in BSD/OS 4.1.
#
*-bsdi3.*|*-bsdi4.0*)
AC_DEFINE(NEED_PTHREAD_INIT)
;;
#
# LinuxThreads requires some changes to the way we
# deal with signals.
#
*-linux*)
AC_DEFINE(HAVE_LINUXTHREADS)
;;
#
# Ensure the right sigwait() semantics on Solaris and make
# sure we call pthread_setconcurrency.
#
*-solaris*)
AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
AC_CHECK_FUNC(pthread_setconcurrency,
AC_DEFINE(CALL_PTHREAD_SETCONCURRENCY))
;;
#
# UnixWare does things its own way.
#
*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
AC_DEFINE(HAVE_UNIXWARE_SIGWAIT)
;;
esac
# Look for functions relating to thread naming
AC_CHECK_FUNCS(pthread_setname_np pthread_set_name_np)
AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
#
# Look for sysconf to allow detection of the number of processors.
#
AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
else
ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
thread_dir=nothreads
THREADOPTOBJS=""
THREADOPTSRCS=""
ALWAYS_DEFINES=""
case $host in
*-dec-osf*)
CC="$CC -pthread"
CCOPT="$CCOPT -pthread"
CCNOOPT="$CCNOOPT -pthread"
;;
*-solaris*)
CC="$CC -mt"
CCOPT="$CCOPT -mt"
CCNOOPT="$CCNOOPT -mt"
;;
*-ibm-aix*)
STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
;;
*-sco-sysv*uw*|*-*-sysv*UnixWare*)
CC="$CC -Kthread"
CCOPT="$CCOPT -Kthread"
CCNOOPT="$CCNOOPT -Kthread"
;;
*-*-sysv*OpenUNIX*)
CC="$CC -Kpthread"
CCOPT="$CCOPT -Kpthread"
CCNOOPT="$CCNOOPT -Kpthread"
;;
esac
fi
ALWAYS_DEFINES="-D_REENTRANT"
THREADOPTOBJS='${THREADOPTOBJS}'
THREADOPTSRCS='${THREADOPTSRCS}'
thread_dir=pthreads
#
# We'd like to use sigwait() too
#
AC_CHECK_FUNC(sigwait,
AC_DEFINE(HAVE_SIGWAIT),
AC_CHECK_LIB(c, sigwait,
AC_DEFINE(HAVE_SIGWAIT),
AC_CHECK_LIB(pthread, sigwait,
AC_DEFINE(HAVE_SIGWAIT),
AC_CHECK_LIB(pthread, _Psigwait,
AC_DEFINE(HAVE_SIGWAIT),))))
AC_CHECK_FUNC(pthread_attr_getstacksize,
AC_DEFINE(HAVE_PTHREAD_ATTR_GETSTACKSIZE),)
AC_CHECK_FUNC(pthread_attr_setstacksize,
AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE),)
AC_ARG_WITH(locktype,
AS_HELP_STRING([--with-locktype=ARG],
[Specify mutex lock type
(adaptive or standard)]),
locktype="$withval", locktype="adaptive")
case "$locktype" in
adaptive)
AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <pthread.h>
]], [[
return (PTHREAD_MUTEX_ADAPTIVE_NP);
]])],
[ AC_MSG_RESULT(using adaptive lock type)
AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
[Support for PTHREAD_MUTEX_ADAPTIVE_NP]) ],
[ AC_MSG_RESULT(using standard lock type) ])
;;
standard)
AC_MSG_RESULT(using standard lock type)
;;
*)
AC_MSG_ERROR([You must specify "adaptive" or "standard" for --with-locktype.])
;;
esac
AC_CHECK_HEADERS(sched.h)
case "$host" in
*solaris-*)
AC_CHECK_LIB(rt, sched_yield)
;;
esac
AC_CHECK_FUNCS(sched_yield pthread_yield pthread_yield_np)
#
# Additional OS-specific issues related to pthreads and sigwait.
#
case "$host" in
#
# One more place to look for sigwait.
#
*-freebsd*)
AC_CHECK_LIB(c_r, sigwait, AC_DEFINE(HAVE_SIGWAIT),)
case $host in
*-freebsd5.[[012]]|*-freebsd5.[[012]].*);;
*-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*)
AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
;;
*-freebsd6.*)
AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
;;
esac
;;
#
# BSDI 3.0 through 4.0.1 needs pthread_init() to be
# called before certain pthreads calls. This is deprecated
# in BSD/OS 4.1.
#
*-bsdi3.*|*-bsdi4.0*)
AC_DEFINE(NEED_PTHREAD_INIT)
;;
#
# LinuxThreads requires some changes to the way we
# deal with signals.
#
*-linux*)
AC_DEFINE(HAVE_LINUXTHREADS)
;;
#
# Ensure the right sigwait() semantics on Solaris and make
# sure we call pthread_setconcurrency.
#
*-solaris*)
AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
AC_CHECK_FUNC(pthread_setconcurrency,
AC_DEFINE(CALL_PTHREAD_SETCONCURRENCY))
;;
#
# UnixWare does things its own way.
#
*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
AC_DEFINE(HAVE_UNIXWARE_SIGWAIT)
;;
esac
# Look for functions relating to thread naming
AC_CHECK_FUNCS(pthread_setname_np pthread_set_name_np)
AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
#
# Look for sysconf to allow detection of the number of processors.
#
AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
AC_SUBST(ALWAYS_DEFINES)
AC_SUBST(ISC_PLATFORM_USETHREADS)
AC_SUBST(THREADOPTOBJS)
AC_SUBST(THREADOPTSRCS)
ISC_THREAD_DIR=$thread_dir
@@ -1807,20 +1894,6 @@ AC_CHECK_LIB(scf, smf_enable_instance)
AC_CHECK_FUNC(flockfile, AC_DEFINE(HAVE_FLOCKFILE),)
AC_CHECK_FUNC(getc_unlocked, AC_DEFINE(HAVE_GETCUNLOCKED),)
#
# Indicate what the final decision was regarding threads.
#
AC_MSG_CHECKING(whether to build with threads)
if $use_threads; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
#
# End of pthreads stuff.
#
#
# Large File
#
@@ -3304,52 +3377,49 @@ fi
#
# CPU relax (for spin locks)
#
if $use_threads
then
case "$host" in
[i[3456]86-*])
# x86_32
AC_MSG_CHECKING([if asm("rep; nop"); works])
AC_TRY_COMPILE(,[asm("rep; nop");],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT([cross compile, assume yes])
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
;;
x86_64-*|amd64-*)
# x86_64
AC_MSG_CHECKING([if asm("rep; nop"); works])
AC_TRY_COMPILE(,[asm("rep; nop");],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT([cross compile, assume yes])
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
;;
ia64-*)
# ia64
AC_MSG_CHECKING([if asm("hint @pause"); works])
AC_TRY_COMPILE(,[asm("hint @pause");],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT([cross compile, assume yes])
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"])
;;
sparc-*)
# sparc
AC_MSG_CHECKING([if cpu_relax(); or __cpu_relax(); works])
AC_CHECK_FUNC(cpu_relax,
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP cpu_relax()"],
[AC_CHECK_FUNC(__cpu_relax,
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP __cpu_relax()"],
[AC_MSG_RESULT(no)])])
;;
esac
fi
case "$host" in
[i[3456]86-*])
# x86_32
AC_MSG_CHECKING([if asm("rep; nop"); works])
AC_TRY_COMPILE(,[asm("rep; nop");],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT([cross compile, assume yes])
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
;;
x86_64-*|amd64-*)
# x86_64
AC_MSG_CHECKING([if asm("rep; nop"); works])
AC_TRY_COMPILE(,[asm("rep; nop");],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT([cross compile, assume yes])
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
;;
ia64-*)
# ia64
AC_MSG_CHECKING([if asm("hint @pause"); works])
AC_TRY_COMPILE(,[asm("hint @pause");],
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"],
[AC_MSG_RESULT(no)],
[AC_MSG_RESULT([cross compile, assume yes])
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"])
;;
sparc-*)
# sparc
AC_MSG_CHECKING([if cpu_relax(); or __cpu_relax(); works])
AC_CHECK_FUNC(cpu_relax,
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP cpu_relax()"],
[AC_CHECK_FUNC(__cpu_relax,
[AC_MSG_RESULT(yes)
ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP __cpu_relax()"],
[AC_MSG_RESULT(no)])])
;;
esac
AC_SUBST(ISC_PLATFORM_BUSYWAITNOP)
@@ -3484,9 +3554,6 @@ DNSTAPOBJS=
DNSTAPTARGETS=
DNSTAP_PB_C_H=
if test "x$use_dnstap" != "xno"; then
if ! $use_threads; then
AC_MSG_ERROR([Dnstap requires threads.])
fi
AC_ARG_WITH([protobuf-c],
AS_HELP_STRING([--with-protobuf-c=path],
[Path where protobuf-c is installed, for dnstap]), [
@@ -3858,9 +3925,6 @@ AC_ARG_WITH(tuning,
case "$use_tuning" in
large)
if ! $use_threads; then
AC_MSG_ERROR([Large-system tuning requires threads.])
fi
AC_DEFINE(TUNE_LARGE, 1, [Define to use large-system tuning.])
AC_MSG_RESULT(using large-system tuning)
;;
@@ -4480,11 +4544,8 @@ report() {
echo "Configuration summary:"
echo "-------------------------------------------------------------------------------"
echo "Optional features enabled:"
if $use_threads; then
echo " Multiprocessing support (--enable-threads)"
if test "yes" = "$enable_full_report" -o "standard" = "$locktype"; then
echo " Mutex lock type: $locktype"
fi
if test "yes" = "$enable_full_report" -o "standard" = "$locktype"; then
echo " Mutex lock type: $locktype"
fi
test "large" = "$use_tuning" && echo " Large-system tuning (--with-tuning)"
test "no" = "$use_dnstap" || \
@@ -4549,7 +4610,6 @@ report() {
echo "-------------------------------------------------------------------------------"
echo "Features disabled or unavailable on this platform:"
$use_threads || echo " Multiprocessing support (--enable-threads)"
test "no" = "$enable_ipv6" -o "no" = "$found_ipv6" && \
echo " IPv6 support (--enable-ipv6)"
test "large" = "$use_tuning" || echo " Large-system tuning (--with-tuning)"
-4
View File
@@ -66,11 +66,7 @@
static dns_sdlzimplementation_t *dlz_bdb = NULL;
/* should the bdb driver use threads. */
#ifdef ISC_PLATFORM_USETHREADS
#define bdb_threads DB_THREAD
#else
#define bdb_threads 0
#endif
/* BDB database names */
#define dlz_data "dns_data"
-4
View File
@@ -66,11 +66,7 @@
static dns_sdlzimplementation_t *dlz_bdbhpt = NULL;
/* should the bdb driver use threads. */
#ifdef ISC_PLATFORM_USETHREADS
#define bdbhpt_threads DB_THREAD
#else
#define bdbhpt_threads 0
#endif
/* bdbhpt database names */
#define dlz_data "dns_data"
-80
View File
@@ -94,11 +94,7 @@ static dns_sdlzimplementation_t *dlz_ldap = NULL;
*/
typedef struct {
#ifdef ISC_PLATFORM_USETHREADS
db_list_t *db; /*%< handle to a list of DB */
#else
dbinstance_t *db; /*%< handle to db */
#endif
int method; /*%< security authentication method */
char *user; /*%< who is authenticating */
char *cred; /*%< password for simple authentication method */
@@ -244,9 +240,6 @@ dlz_ldap_connect(ldap_instance_t *dbi, dbinstance_t *dbc) {
return (result);
}
#ifdef ISC_PLATFORM_USETHREADS
/*%
* Properly cleans up a list of database instances.
* This function is only used when the driver is compiled for
@@ -316,7 +309,6 @@ ldap_find_avail_conn(db_list_t *dblist) {
count);
return (NULL);
}
#endif /* ISC_PLATFORM_USETHREADS */
static isc_result_t
ldap_process_results(LDAP *dbc, LDAPMessage *msg, char ** attrs,
@@ -569,22 +561,10 @@ ldap_get_results(const char *zone, const char *record,
int entries;
/* get db instance / connection */
#ifdef ISC_PLATFORM_USETHREADS
/* find an available DBI from the list */
dbi = ldap_find_avail_conn((db_list_t *)
((ldap_instance_t *)dbdata)->db);
#else /* ISC_PLATFORM_USETHREADS */
/*
* only 1 DBI - no need to lock instance lock either
* only 1 thread in the whole process, no possible contention.
*/
dbi = (dbinstance_t *) ((ldap_instance_t *)dbdata)->db;
#endif /* ISC_PLATFORM_USETHREADS */
/* if DBI is null, can't do anything else */
if (dbi == NULL)
return (ISC_R_FAILURE);
@@ -845,13 +825,9 @@ ldap_get_results(const char *zone, const char *record,
if (dbi->client != NULL)
isc_mem_free(named_g_mctx, dbi->client);
#ifdef ISC_PLATFORM_USETHREADS
/* release the lock so another thread can use this dbi */
isc_mutex_unlock(&dbi->instance_lock);
#endif /* ISC_PLATFORM_USETHREADS */
/* release query string */
if (querystring != NULL)
isc_mem_free(named_g_mctx, querystring );
@@ -939,30 +915,19 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
dbinstance_t *dbi = NULL;
int protocol;
int method;
#ifdef ISC_PLATFORM_USETHREADS
/* if multi-threaded, we need a few extra variables. */
int dbcount;
char *endp;
/* db_list_t *dblist = NULL; */
int i;
#endif /* ISC_PLATFORM_USETHREADS */
UNUSED(dlzname);
UNUSED(driverarg);
#ifdef ISC_PLATFORM_USETHREADS
/* if debugging, let user know we are multithreaded. */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"LDAP driver running multithreaded");
#else /* ISC_PLATFORM_USETHREADS */
/* if debugging, let user know we are single threaded. */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"LDAP driver running single threaded");
#endif /* ISC_PLATFORM_USETHREADS */
if (argc < 9) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
@@ -1010,9 +975,6 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
return (ISC_R_FAILURE);
}
/* multithreaded build can have multiple DB connections */
#ifdef ISC_PLATFORM_USETHREADS
/* check how many db connections we should create */
dbcount = strtol(argv[1], &endp, 10);
if (*endp != '\0' || dbcount < 0) {
@@ -1022,7 +984,6 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
"must be positive.");
return (ISC_R_FAILURE);
}
#endif
/* check that LDAP URL parameters make sense */
switch(argc) {
@@ -1078,7 +1039,6 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
goto cleanup;
}
#ifdef ISC_PLATFORM_USETHREADS
/* allocate memory for database connection list */
ldap_inst->db = isc_mem_get(named_g_mctx, sizeof(db_list_t));
if (ldap_inst->db == NULL) {
@@ -1095,8 +1055,6 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
*/
for (i = 0; i < dbcount; i++) {
#endif /* ISC_PLATFORM_USETHREADS */
/* how many queries were passed in from config file? */
switch(argc) {
case 9:
@@ -1138,18 +1096,9 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
goto cleanup;
}
#ifdef ISC_PLATFORM_USETHREADS
/* when multithreaded, build a list of DBI's */
ISC_LINK_INIT(dbi, link);
ISC_LIST_APPEND(*(ldap_inst->db), dbi, link);
#else
/*
* when single threaded, hold onto the one connection
* instance.
*/
ldap_inst->db = dbi;
#endif
/* attempt to connect */
result = dlz_ldap_connect(ldap_inst, dbi);
@@ -1166,18 +1115,11 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
* allocate memory
*/
case ISC_R_NOMEMORY:
#ifdef ISC_PLATFORM_USETHREADS
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"LDAP driver could not allocate memory "
"for connection number %u",
i+1);
#else
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"LDAP driver could not allocate memory "
"for connection");
#endif
goto cleanup;
break;
/*
@@ -1194,18 +1136,11 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
break;
/* failure means couldn't connect to ldap server */
case ISC_R_FAILURE:
#ifdef ISC_PLATFORM_USETHREADS
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"LDAP driver could not "
"bind connection number %u to server.",
i+1);
#else
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"LDAP driver could not "
"bind connection to server.");
#endif
goto cleanup;
break;
/*
@@ -1221,15 +1156,10 @@ dlz_ldap_create(const char *dlzname, unsigned int argc, char *argv[],
break;
} /* end switch(result) */
#ifdef ISC_PLATFORM_USETHREADS
/* set DBI = null for next loop through. */
dbi = NULL;
} /* end for loop */
#endif /* ISC_PLATFORM_USETHREADS */
/* set dbdata to the ldap_instance we created. */
*dbdata = ldap_inst;
@@ -1248,20 +1178,10 @@ dlz_ldap_destroy(void *driverarg, void *dbdata) {
UNUSED(driverarg);
if (dbdata != NULL) {
#ifdef ISC_PLATFORM_USETHREADS
/* cleanup the list of DBI's */
ldap_destroy_dblist((db_list_t *)
((ldap_instance_t *)dbdata)->db);
#else /* ISC_PLATFORM_USETHREADS */
if (((ldap_instance_t *)dbdata)->db->dbconn != NULL)
ldap_unbind_s((LDAP *)
((ldap_instance_t *)dbdata)->db->dbconn);
/* destroy single DB instance */
destroy_sqldbinstance(((ldap_instance_t *)dbdata)->db);
#endif /* ISC_PLATFORM_USETHREADS */
if (((ldap_instance_t *)dbdata)->hosts != NULL)
isc_mem_free(named_g_mctx,
((ldap_instance_t *)dbdata)->hosts);
-114
View File
@@ -99,17 +99,7 @@ typedef struct{
*/
typedef struct {
#ifdef ISC_PLATFORM_USETHREADS
db_list_t *db; /* handle to a list of DB */
#else
dbinstance_t *db; /* handle to db */
#endif
SQLHENV sql_env; /* handle to SQL environment */
SQLCHAR *dsn;
SQLCHAR *user;
@@ -136,9 +126,6 @@ safeLen(void *a) {
static void
destroy_odbc_instance(odbc_instance_t *odbc_inst) {
#ifdef ISC_PLATFORM_USETHREADS
dbinstance_t *ndbi = NULL;
dbinstance_t *dbi = NULL;
@@ -180,34 +167,6 @@ destroy_odbc_instance(odbc_instance_t *odbc_inst) {
/* release memory for the list structure */
isc_mem_put(named_g_mctx, odbc_inst->db, sizeof(db_list_t));
#else /* ISC_PLATFORM_USETHREADS */
/* free statement handle */
if (((odbc_db_t *) (odbc_inst->db->dbconn))->stmnt != NULL) {
SQLFreeHandle(SQL_HANDLE_STMT,
((odbc_db_t *) (odbc_inst->db->dbconn))->stmnt);
((odbc_db_t *) (odbc_inst->db->dbconn))->stmnt = NULL;
}
/* disconnect from database, free connection handle */
if (((odbc_db_t *) (odbc_inst->db->dbconn))->dbc != NULL) {
SQLDisconnect(((odbc_db_t *) (odbc_inst->db->dbconn))->dbc);
SQLFreeHandle(SQL_HANDLE_DBC,
((odbc_db_t *) (odbc_inst->db->dbconn))->dbc);
((odbc_db_t *) (odbc_inst->db->dbconn))->dbc = NULL;
}
/* free mem for the odbc_db_t structure held in db */
if (((odbc_db_t *) odbc_inst->db->dbconn) != NULL) {
isc_mem_free(named_g_mctx, odbc_inst->db->dbconn);
odbc_inst->db->dbconn = NULL;
}
if (odbc_inst->db != NULL)
destroy_sqldbinstance(odbc_inst->db);
#endif /* ISC_PLATFORM_USETHREADS */
/* free sql environment */
if (odbc_inst->sql_env != NULL)
SQLFreeHandle(SQL_HANDLE_ENV, odbc_inst->sql_env);
@@ -327,8 +286,6 @@ odbc_connect(odbc_instance_t *dbi, odbc_db_t **dbc) {
* multithreaded operation.
*/
#ifdef ISC_PLATFORM_USETHREADS
static dbinstance_t *
odbc_find_avail_conn(db_list_t *dblist)
{
@@ -362,8 +319,6 @@ odbc_find_avail_conn(db_list_t *dblist)
return NULL;
}
#endif /* ISC_PLATFORM_USETHREADS */
/*% Allocates memory for a new string, and then constructs the new
* string by "escaping" the input string. The new string is
* safe to be used in queries. This is necessary because we cannot
@@ -482,21 +437,10 @@ odbc_get_resultset(const char *zone, const char *record,
REQUIRE(*r_dbi == NULL);
/* get db instance / connection */
#ifdef ISC_PLATFORM_USETHREADS
/* find an available DBI from the list */
dbi = odbc_find_avail_conn(((odbc_instance_t *) dbdata)->db);
#else /* ISC_PLATFORM_USETHREADS */
/*
* only 1 DBI - no need to lock instance lock either
* only 1 thread in the whole process, no possible contention.
*/
dbi = (dbinstance_t *) ((odbc_instance_t *) dbdata)->db;
#endif /* ISC_PLATFORM_USETHREADS */
/* if DBI is null, can't do anything else */
if (dbi == NULL) {
result = ISC_R_FAILURE;
@@ -698,14 +642,10 @@ odbc_get_resultset(const char *zone, const char *record,
if (dbi->client != NULL)
isc_mem_free(named_g_mctx, dbi->client);
#ifdef ISC_PLATFORM_USETHREADS
/* if we are done using this dbi, release the lock */
if (result != ISC_R_SUCCESS)
isc_mutex_unlock(&dbi->instance_lock);
#endif /* ISC_PLATFORM_USETHREADS */
/* release query string */
if (querystring != NULL)
isc_mem_free(named_g_mctx, querystring );
@@ -937,13 +877,9 @@ odbc_process_rs(dns_sdlzlookup_t *lookup, dbinstance_t *dbi)
/* close cursor */
SQLCloseCursor(((odbc_db_t *) (dbi->dbconn))->stmnt);
#ifdef ISC_PLATFORM_USETHREADS
/* free lock on dbi so someone else can use it. */
isc_mutex_unlock(&dbi->instance_lock);
#endif
return result;
}
@@ -980,11 +916,8 @@ odbc_findzone(void *driverarg, void *dbdata, const char *name,
/* get rid of result set, we are done with it. */
SQLCloseCursor(((odbc_db_t *) (dbi->dbconn))->stmnt);
#ifdef ISC_PLATFORM_USETHREADS
/* free lock on dbi so someone else can use it. */
isc_mutex_unlock(&dbi->instance_lock);
#endif
}
return result;
@@ -1032,11 +965,8 @@ odbc_allowzonexfr(void *driverarg, void *dbdata, const char *name,
/* get rid of result set, we are done with it. */
SQLCloseCursor(((odbc_db_t *) (dbi->dbconn))->stmnt);
#ifdef ISC_PLATFORM_USETHREADS
/* free lock on dbi so someone else can use it. */
isc_mutex_unlock(&dbi->instance_lock);
#endif
}
@@ -1167,13 +1097,9 @@ odbc_allnodes(const char *zone, void *driverarg, void *dbdata,
/* close cursor */
SQLCloseCursor(((odbc_db_t *) (dbi->dbconn))->stmnt);
#ifdef ISC_PLATFORM_USETHREADS
/* free lock on dbi so someone else can use it. */
isc_mutex_unlock(&dbi->instance_lock);
#endif
return result;
}
@@ -1252,29 +1178,17 @@ odbc_create(const char *dlzname, unsigned int argc, char *argv[],
odbc_instance_t *odbc_inst = NULL;
dbinstance_t *db = NULL;
SQLRETURN sqlRes;
#ifdef ISC_PLATFORM_USETHREADS
/* if multi-threaded, we need a few extra variables. */
int dbcount;
int i;
char *endp;
#endif /* ISC_PLATFORM_USETHREADS */
UNUSED(dlzname);
UNUSED(driverarg);
#ifdef ISC_PLATFORM_USETHREADS
/* if debugging, let user know we are multithreaded. */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"Odbc driver running multithreaded");
#else /* ISC_PLATFORM_USETHREADS */
/* if debugging, let user know we are single threaded. */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"Odbc driver running single threaded");
#endif /* ISC_PLATFORM_USETHREADS */
/* verify we have at least 5 arg's passed to the driver */
if (argc < 5) {
@@ -1295,8 +1209,6 @@ odbc_create(const char *dlzname, unsigned int argc, char *argv[],
}
/* multithreaded build can have multiple DB connections */
#ifdef ISC_PLATFORM_USETHREADS
/* check how many db connections we should create */
dbcount = strtol(argv[1], &endp, 10);
if (*endp != '\0' || dbcount < 0) {
@@ -1307,8 +1219,6 @@ odbc_create(const char *dlzname, unsigned int argc, char *argv[],
return (ISC_R_FAILURE);
}
#endif /* ISC_PLATFORM_USETHREADS */
/* allocate memory for odbc instance */
odbc_inst = isc_mem_get(named_g_mctx, sizeof(odbc_instance_t));
if (odbc_inst == NULL)
@@ -1361,8 +1271,6 @@ odbc_create(const char *dlzname, unsigned int argc, char *argv[],
}
}
#ifdef ISC_PLATFORM_USETHREADS
/* allocate memory for database connection list */
odbc_inst->db = isc_mem_get(named_g_mctx, sizeof(db_list_t));
if (odbc_inst->db == NULL) {
@@ -1378,8 +1286,6 @@ odbc_create(const char *dlzname, unsigned int argc, char *argv[],
/* append each new DBI to the end of the list */
for (i=0; i < dbcount; i++) {
#endif /* ISC_PLATFORM_USETHREADS */
/* how many queries were passed in from config file? */
switch(argc) {
case 5:
@@ -1416,20 +1322,14 @@ odbc_create(const char *dlzname, unsigned int argc, char *argv[],
goto cleanup;
}
#ifdef ISC_PLATFORM_USETHREADS
/* when multithreaded, build a list of DBI's */
ISC_LINK_INIT(db, link);
ISC_LIST_APPEND(*odbc_inst->db, db, link);
#endif
result = odbc_connect(odbc_inst, (odbc_db_t **) &(db->dbconn));
if (result != ISC_R_SUCCESS) {
#ifdef ISC_PLATFORM_USETHREADS
/*
* if multi threaded, let user know which
* connection failed. user could be
@@ -1442,28 +1342,14 @@ odbc_create(const char *dlzname, unsigned int argc, char *argv[],
"Odbc driver failed to create database "
"connection number %u after 3 attempts",
i+1);
#else
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Odbc driver failed to create database "
"connection after 3 attempts");
#endif
goto cleanup;
}
#ifdef ISC_PLATFORM_USETHREADS
/* set DB = null for next loop through. */
db = NULL;
} /* end for loop */
#else
/* tell odbc_inst about the db connection we just created. */
odbc_inst->db = db;
#endif
/* set dbdata to the odbc_instance we created. */
*dbdata = odbc_inst;
-82
View File
@@ -149,8 +149,6 @@ postgres_makesafe(char *to, const char *from, size_t length)
return target - to;
}
#ifdef ISC_PLATFORM_USETHREADS
/*%
* Properly cleans up a list of database instances.
* This function is only used when the driver is compiled for
@@ -225,8 +223,6 @@ postgres_find_avail_conn(db_list_t *dblist)
return NULL;
}
#endif /* ISC_PLATFORM_USETHREADS */
/*%
* Allocates memory for a new string, and then constructs the new
* string by "escaping" the input string. The new string is
@@ -298,21 +294,10 @@ postgres_get_resultset(const char *zone, const char *record,
#endif
/* get db instance / connection */
#ifdef ISC_PLATFORM_USETHREADS
/* find an available DBI from the list */
dbi = postgres_find_avail_conn((db_list_t *) dbdata);
#else /* ISC_PLATFORM_USETHREADS */
/*
* only 1 DBI - no need to lock instance lock either
* only 1 thread in the whole process, no possible contention.
*/
dbi = (dbinstance_t *) dbdata;
#endif /* ISC_PLATFORM_USETHREADS */
#if 0
/* temporary logging message */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
@@ -599,8 +584,6 @@ postgres_get_resultset(const char *zone, const char *record,
if (dbi->client != NULL)
isc_mem_free(named_g_mctx, dbi->client);
#ifdef ISC_PLATFORM_USETHREADS
#if 0
/* temporary logging message */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
@@ -611,8 +594,6 @@ postgres_get_resultset(const char *zone, const char *record,
/* release the lock so another thread can use this dbi */
isc_mutex_unlock(&dbi->instance_lock);
#endif /* ISC_PLATFORM_USETHREADS */
/* release query string */
if (querystring != NULL)
isc_mem_free(named_g_mctx, querystring );
@@ -1058,15 +1039,12 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
dbinstance_t *dbi = NULL;
unsigned int j;
#ifdef ISC_PLATFORM_USETHREADS
/* if multi-threaded, we need a few extra variables. */
int dbcount;
db_list_t *dblist = NULL;
int i;
char *endp;
#endif /* ISC_PLATFORM_USETHREADS */
UNUSED(driverarg);
UNUSED(dlzname);
@@ -1074,17 +1052,10 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
srand( (unsigned)time( NULL ) );
#ifdef ISC_PLATFORM_USETHREADS
/* if debugging, let user know we are multithreaded. */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"Postgres driver running multithreaded");
#else /* ISC_PLATFORM_USETHREADS */
/* if debugging, let user know we are single threaded. */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"Postgres driver running single threaded");
#endif /* ISC_PLATFORM_USETHREADS */
/* verify we have at least 5 arg's passed to the driver */
if (argc < 5) {
@@ -1105,7 +1076,6 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
}
/* multithreaded build can have multiple DB connections */
#ifdef ISC_PLATFORM_USETHREADS
/* check how many db connections we should create */
dbcount = strtol(argv[1], &endp, 10);
@@ -1131,8 +1101,6 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
*/
for (i=0; i < dbcount; i++) {
#endif /* ISC_PLATFORM_USETHREADS */
/* how many queries were passed in from config file? */
switch(argc) {
case 5:
@@ -1174,14 +1142,10 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
goto cleanup;
}
#ifdef ISC_PLATFORM_USETHREADS
/* when multithreaded, build a list of DBI's */
ISC_LINK_INIT(dbi, link);
ISC_LIST_APPEND(*dblist, dbi, link);
#endif
/* create and set db connection */
dbi->dbconn = PQconnectdb(argv[2]);
/*
@@ -1204,8 +1168,6 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
PQreset((PGconn *) dbi->dbconn);
#ifdef ISC_PLATFORM_USETHREADS
/*
* if multi threaded, let user know which connection
* failed. user could be attempting to create 10 db
@@ -1229,30 +1191,11 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
/* set dbdata to the list we created. */
*dbdata = dblist;
#else /* ISC_PLATFORM_USETHREADS */
/* if single threaded, just let user know we couldn't connect. */
if (PQstatus((PGconn *) dbi->dbconn) != CONNECTION_OK) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Postgres driver failed to create database "
"connection after 4 attempts");
goto cleanup;
}
/*
* single threaded build can only use 1 db connection, return
* it via dbdata
*/
*dbdata = dbi;
#endif /* ISC_PLATFORM_USETHREADS */
/* hey, we got through all of that ok, return success. */
return(ISC_R_SUCCESS);
cleanup:
#ifdef ISC_PLATFORM_USETHREADS
/*
* if multithreaded, we could fail because only 1 connection
* couldn't be made. We should cleanup the other successful
@@ -1260,11 +1203,6 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
*/
postgres_destroy_dblist(dblist);
#else /* ISC_PLATFORM_USETHREADS */
if (dbi != NULL)
destroy_sqldbinstance(dbi);
#endif /* ISC_PLATFORM_USETHREADS */
return(ISC_R_FAILURE);
}
@@ -1277,29 +1215,9 @@ postgres_create(const char *dlzname, unsigned int argc, char *argv[],
static void
postgres_destroy(void *driverarg, void *dbdata)
{
#ifdef ISC_PLATFORM_USETHREADS
UNUSED(driverarg);
/* cleanup the list of DBI's */
postgres_destroy_dblist((db_list_t *) dbdata);
#else /* ISC_PLATFORM_USETHREADS */
dbinstance_t *dbi;
UNUSED(driverarg);
dbi = (dbinstance_t *) dbdata;
/* release DB connection */
if (dbi->dbconn != NULL)
PQfinish((PGconn *) dbi->dbconn);
/* destroy single DB instance */
destroy_sqldbinstance(dbi);
#endif /* ISC_PLATFORM_USETHREADS */
}
/* pointers to all our runtime methods. */
@@ -68,11 +68,7 @@
#include "dlz_minimal.h"
/* should the bdb driver use threads. */
#ifdef ISC_PLATFORM_USETHREADS
#define bdbhpt_threads DB_THREAD
#else
#define bdbhpt_threads 0
#endif
/* bdbhpt database names */
#define dlz_data "dns_data"
+4 -2
View File
@@ -2873,7 +2873,7 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
dns_dispatch_t *disp;
isc_socket_t *sock = NULL;
int i = 0;
dup_socket = NULL;
/*
* dispatch_allocate() checks mgr for us.
*/
@@ -2950,7 +2950,9 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
}
goto kill_socket;
}
isc_task_setname(disp->task[i], "udpdispatch", disp);
char n[32];
sprintf(n, "UDPD-%d", i);
isc_task_setname(disp->task[i], n, disp);
}
disp->ctlevent = isc_event_allocate(mgr->mctx, disp,
-8
View File
@@ -1562,11 +1562,7 @@ issymmetric(const dst_key_t *key) {
static void
printtime(const dst_key_t *key, int type, const char *tag, FILE *stream) {
isc_result_t result;
#ifdef ISC_PLATFORM_USETHREADS
char output[26]; /* Minimum buffer as per ctime_r() specification. */
#else
const char *output;
#endif
isc_stdtime_t when;
time_t t;
char utc[sizeof("YYYYMMDDHHSSMM")];
@@ -1579,7 +1575,6 @@ printtime(const dst_key_t *key, int type, const char *tag, FILE *stream) {
/* time_t and isc_stdtime_t might be different sizes */
t = when;
#ifdef ISC_PLATFORM_USETHREADS
#ifdef WIN32
if (ctime_s(output, sizeof(output), &t) != 0)
goto error;
@@ -1587,9 +1582,6 @@ printtime(const dst_key_t *key, int type, const char *tag, FILE *stream) {
if (ctime_r(&t, output) == NULL)
goto error;
#endif
#else
output = ctime(&t);
#endif
isc_buffer_init(&b, utc, sizeof(utc));
result = dns_time32_totext(when, &b);
-15
View File
@@ -78,7 +78,6 @@ typedef struct geoip_state {
isc_mem_t *mctx;
} geoip_state_t;
#ifdef ISC_PLATFORM_USETHREADS
static isc_mutex_t key_mutex;
static bool state_key_initialized = false;
static isc_thread_key_t state_key;
@@ -133,9 +132,6 @@ state_key_init(void) {
return (result);
}
#else
static geoip_state_t saved_state;
#endif
static void
clean_state(geoip_state_t *state) {
@@ -165,7 +161,6 @@ set_state(unsigned int family, uint32_t ipnum, const geoipv6_t *ipnum6,
GeoIPRegion *region, char *name, const char *text, int id)
{
geoip_state_t *state = NULL;
#ifdef ISC_PLATFORM_USETHREADS
isc_result_t result;
result = state_key_init();
@@ -189,10 +184,6 @@ set_state(unsigned int family, uint32_t ipnum, const geoipv6_t *ipnum6,
isc_mem_attach(state_mctx, &state->mctx);
} else
clean_state(state);
#else
state = &saved_state;
clean_state(state);
#endif
if (family == AF_INET) {
state->ipnum = ipnum;
@@ -218,7 +209,6 @@ get_state_for(unsigned int family, uint32_t ipnum,
{
geoip_state_t *state;
#ifdef ISC_PLATFORM_USETHREADS
isc_result_t result;
result = state_key_init();
@@ -228,9 +218,6 @@ get_state_for(unsigned int family, uint32_t ipnum,
state = (geoip_state_t *) isc_thread_key_getspecific(state_key);
if (state == NULL)
return (NULL);
#else
state = &saved_state;
#endif
if (state->family == family &&
((state->family == AF_INET && state->ipnum == ipnum) ||
@@ -830,10 +817,8 @@ void
dns_geoip_shutdown(void) {
#ifdef HAVE_GEOIP
GeoIP_cleanup();
#ifdef ISC_PLATFORM_USETHREADS
if (state_mctx != NULL)
isc_mem_detach(&state_mctx);
#endif
#else
return;
#endif
-19
View File
@@ -165,15 +165,11 @@ LIBDNS_EXTERNAL_DATA const dns_name_t *dns_wildcardname = &wild;
/*
* dns_name_t to text post-conversion procedure.
*/
#ifdef ISC_PLATFORM_USETHREADS
static int thread_key_initialized = 0;
static isc_mutex_t thread_key_mutex;
static isc_mem_t *thread_key_mctx = NULL;
static isc_thread_key_t totext_filter_proc_key;
static isc_once_t once = ISC_ONCE_INIT;
#else
static dns_name_totextfilter_t totext_filter_proc = NULL;
#endif
static void
set_offsets(const dns_name_t *name, unsigned char *offsets,
@@ -1277,7 +1273,6 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
return (ISC_R_SUCCESS);
}
#ifdef ISC_PLATFORM_USETHREADS
static void
free_specific(void *arg) {
dns_name_totextfilter_t *mem = arg;
@@ -1324,7 +1319,6 @@ totext_filter_proc_key_init(void) {
}
return (result);
}
#endif
isc_result_t
dns_name_totext(const dns_name_t *name, bool omit_final_dot,
@@ -1354,11 +1348,9 @@ dns_name_totext2(const dns_name_t *name, unsigned int options,
unsigned int labels;
bool saw_root = false;
unsigned int oused = target->used;
#ifdef ISC_PLATFORM_USETHREADS
dns_name_totextfilter_t *mem;
dns_name_totextfilter_t totext_filter_proc = NULL;
isc_result_t result;
#endif
bool omit_final_dot = (options & DNS_NAME_OMITFINALDOT);
/*
@@ -1368,11 +1360,9 @@ dns_name_totext2(const dns_name_t *name, unsigned int options,
REQUIRE(VALID_NAME(name));
REQUIRE(ISC_BUFFER_VALID(target));
#ifdef ISC_PLATFORM_USETHREADS
result = totext_filter_proc_key_init();
if (result != ISC_R_SUCCESS)
return (result);
#endif
ndata = name->ndata;
nlen = name->length;
labels = name->labels;
@@ -1512,11 +1502,9 @@ dns_name_totext2(const dns_name_t *name, unsigned int options,
}
isc_buffer_add(target, tlen - trem);
#ifdef ISC_PLATFORM_USETHREADS
mem = isc_thread_key_getspecific(totext_filter_proc_key);
if (mem != NULL)
totext_filter_proc = *mem;
#endif
if (totext_filter_proc != NULL)
return ((*totext_filter_proc)(target, oused));
@@ -2338,7 +2326,6 @@ dns_name_print(const dns_name_t *name, FILE *stream) {
isc_result_t
dns_name_settotextfilter(dns_name_totextfilter_t proc) {
#ifdef ISC_PLATFORM_USETHREADS
isc_result_t result;
dns_name_totextfilter_t *mem;
int res;
@@ -2374,10 +2361,6 @@ dns_name_settotextfilter(dns_name_totextfilter_t proc) {
result = ISC_R_UNEXPECTED;
}
return (result);
#else
totext_filter_proc = proc;
return (ISC_R_SUCCESS);
#endif
}
void
@@ -2527,7 +2510,6 @@ dns_name_copy(const dns_name_t *source, dns_name_t *dest, isc_buffer_t *target)
void
dns_name_destroy(void) {
#ifdef ISC_PLATFORM_USETHREADS
RUNTIME_CHECK(isc_once_do(&once, thread_key_mutex_init)
== ISC_R_SUCCESS);
@@ -2539,7 +2521,6 @@ dns_name_destroy(void) {
}
UNLOCK(&thread_key_mutex);
#endif
}
/*
-4
View File
@@ -9856,7 +9856,6 @@ dns_resolver_create(dns_view_t *view,
}
res->buckets[i].mctx = NULL;
snprintf(name, sizeof(name), "res%u", i);
#ifdef ISC_PLATFORM_USETHREADS
/*
* Use a separate memory context for each bucket to reduce
* contention among multiple threads. Do this only when
@@ -9869,9 +9868,6 @@ dns_resolver_create(dns_view_t *view,
goto cleanup_buckets;
}
isc_mem_setname(res->buckets[i].mctx, name, NULL);
#else
isc_mem_attach(view->mctx, &res->buckets[i].mctx);
#endif
isc_task_setname(res->buckets[i].task, name, res);
ISC_LIST_INIT(res->buckets[i].fctxs);
res->buckets[i].exiting = false;
-4
View File
@@ -92,11 +92,7 @@ cleanup_managers(void) {
static isc_result_t
create_managers(void) {
isc_result_t result;
#ifdef ISC_PLATFORM_USETHREADS
ncpus = isc_os_ncpus();
#else
ncpus = 1;
#endif
CHECK(isc_taskmgr_create(mctx, ncpus, 0, &taskmgr));
CHECK(isc_timermgr_create(mctx, &timermgr));
-4
View File
@@ -648,7 +648,6 @@ ATF_TC_BODY(getlabelsequence, tc) {
}
}
#ifdef ISC_PLATFORM_USETHREADS
#ifdef DNS_BENCHMARK_TESTS
/*
@@ -744,7 +743,6 @@ ATF_TC_BODY(benchmark, tc) {
}
#endif /* DNS_BENCHMARK_TESTS */
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Main
@@ -762,11 +760,9 @@ ATF_TP_ADD_TCS(tp) {
ATF_TP_ADD_TC(tp, countlabels);
ATF_TP_ADD_TC(tp, getlabel);
ATF_TP_ADD_TC(tp, getlabelsequence);
#ifdef ISC_PLATFORM_USETHREADS
#ifdef DNS_BENCHMARK_TESTS
ATF_TP_ADD_TC(tp, benchmark);
#endif /* DNS_BENCHMARK_TESTS */
#endif /* ISC_PLATFORM_USETHREADS */
return (atf_no_error());
}
-4
View File
@@ -1263,7 +1263,6 @@ ATF_TC_BODY(rbt_nodechain, tc) {
dns_test_end();
}
#ifdef ISC_PLATFORM_USETHREADS
#ifdef DNS_BENCHMARK_TESTS
/*
@@ -1391,7 +1390,6 @@ ATF_TC_BODY(benchmark, tc) {
}
#endif /* DNS_BENCHMARK_TESTS */
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Main
@@ -1409,11 +1407,9 @@ ATF_TP_ADD_TCS(tp) {
ATF_TP_ADD_TC(tp, rbt_addname);
ATF_TP_ADD_TC(tp, rbt_deletename);
ATF_TP_ADD_TC(tp, rbt_nodechain);
#ifdef ISC_PLATFORM_USETHREADS
#ifdef DNS_BENCHMARK_TESTS
ATF_TP_ADD_TC(tp, benchmark);
#endif /* DNS_BENCHMARK_TESTS */
#endif /* ISC_PLATFORM_USETHREADS */
return (atf_no_error());
}
+1 -1
View File
@@ -2055,7 +2055,7 @@ static isc_stdtime_t
epoch_to_yyyymmdd(time_t when) {
struct tm *tm;
#if defined(ISC_PLATFORM_USETHREADS) && !defined(WIN32)
#if !defined(WIN32)
struct tm tm0;
tm = localtime_r(&when, &tm0);
#else
-18
View File
@@ -10154,9 +10154,6 @@ dns_zone_markdirty(dns_zone_t *zone) {
if (result != ISC_R_SUCCESS) {
UNLOCK_ZONE(zone);
secure = NULL;
#ifdef ISC_PLATFORM_USETHREADS
isc_thread_yield();
#endif
goto again;
}
@@ -10422,9 +10419,6 @@ dump_done(void *arg, isc_result_t result) {
if (result != ISC_R_SUCCESS) {
UNLOCK_ZONE(zone);
secure = NULL;
#if ISC_PLATFORM_USETHREADS
isc_thread_yield();
#endif
goto again;
}
}
@@ -14941,9 +14935,6 @@ dns_zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
if (result != ISC_R_SUCCESS) {
UNLOCK_ZONE(zone);
secure = NULL;
#if ISC_PLATFORM_USETHREADS
isc_thread_yield();
#endif
goto again;
}
}
@@ -15177,9 +15168,6 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) {
if (result != ISC_R_SUCCESS) {
UNLOCK_ZONE(zone);
secure = NULL;
#if ISC_PLATFORM_USETHREADS
isc_thread_yield();
#endif
goto again;
}
}
@@ -15442,9 +15430,6 @@ zone_loaddone(void *arg, isc_result_t result) {
if (result != ISC_R_SUCCESS) {
UNLOCK_ZONE(zone);
secure = NULL;
#if ISC_PLATFORM_USETHREADS
isc_thread_yield();
#endif
goto again;
}
}
@@ -18487,9 +18472,6 @@ dns_zone_dlzpostload(dns_zone_t *zone, dns_db_t *db)
if (result != ISC_R_SUCCESS) {
UNLOCK_ZONE(zone);
secure = NULL;
#if ISC_PLATFORM_USETHREADS
isc_thread_yield();
#endif
goto again;
}
}
-20
View File
@@ -45,14 +45,10 @@
#define DNS_CONF "/etc/dns.conf"
#endif
#ifndef ISC_PLATFORM_USETHREADS
irs_context_t *irs_g_context = NULL;
#else
static bool thread_key_initialized = false;
static isc_mutex_t thread_key_mutex;
static isc_thread_key_t irs_context_key;
static isc_once_t once = ISC_ONCE_INIT;
#endif
struct irs_context {
@@ -128,7 +124,6 @@ ctxs_init(isc_mem_t **mctxp, isc_appctx_t **actxp,
return (result);
}
#ifdef ISC_PLATFORM_USETHREADS
static void
free_specific_context(void *arg) {
irs_context_t *context = arg;
@@ -166,7 +161,6 @@ thread_key_init(void) {
return (result);
}
#endif /* ISC_PLATFORM_USETHREADS */
isc_result_t
irs_context_get(irs_context_t **contextp) {
@@ -175,15 +169,6 @@ irs_context_get(irs_context_t **contextp) {
REQUIRE(contextp != NULL && *contextp == NULL);
#ifndef ISC_PLATFORM_USETHREADS
if (irs_g_context == NULL) {
result = irs_context_create(&irs_g_context);
if (result != ISC_R_SUCCESS)
return (result);
}
context = irs_g_context;
#else
result = thread_key_init();
if (result != ISC_R_SUCCESS)
return (result);
@@ -199,7 +184,6 @@ irs_context_get(irs_context_t **contextp) {
return (result);
}
}
#endif /* ISC_PLATFORM_USETHREADS */
*contextp = context;
@@ -328,11 +312,7 @@ irs_context_destroy(irs_context_t **contextp) {
*contextp = NULL;
#ifndef ISC_PLATFORM_USETHREADS
irs_g_context = NULL;
#else
(void)isc_thread_key_setspecific(irs_context_key, NULL);
#endif
}
isc_mem_t *
-253
View File
@@ -1,253 +0,0 @@
/*
* 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 http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <config.h>
#include <stdbool.h>
#include <unistd.h>
#include <isc/app.h>
#include <isc/magic.h>
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/util.h>
static isc_mutex_t createlock;
static isc_once_t once = ISC_ONCE_INIT;
static isc_appctxcreatefunc_t appctx_createfunc = NULL;
static bool is_running = false;
#define ISCAPI_APPMETHODS_VALID(m) ISC_MAGIC_VALID(m, ISCAPI_APPMETHODS_MAGIC)
static void
initialize(void) {
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
}
isc_result_t
isc_app_register(isc_appctxcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
LOCK(&createlock);
if (appctx_createfunc == NULL)
appctx_createfunc = createfunc;
else
result = ISC_R_EXISTS;
UNLOCK(&createlock);
return (result);
}
isc_result_t
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc_result_t result;
if (isc_bind9)
return (isc__appctx_create(mctx, ctxp));
LOCK(&createlock);
REQUIRE(appctx_createfunc != NULL);
result = (*appctx_createfunc)(mctx, ctxp);
UNLOCK(&createlock);
return (result);
}
void
isc_appctx_destroy(isc_appctx_t **ctxp) {
REQUIRE(ctxp != NULL && ISCAPI_APPCTX_VALID(*ctxp));
if (isc_bind9)
isc__appctx_destroy(ctxp);
else
(*ctxp)->methods->ctxdestroy(ctxp);
ENSURE(*ctxp == NULL);
}
isc_result_t
isc_app_ctxstart(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxstart(ctx));
return (ctx->methods->ctxstart(ctx));
}
isc_result_t
isc_app_ctxrun(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxrun(ctx));
return (ctx->methods->ctxrun(ctx));
}
isc_result_t
isc_app_ctxonrun(isc_appctx_t *ctx, isc_mem_t *mctx,
isc_task_t *task, isc_taskaction_t action,
void *arg)
{
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxonrun(ctx, mctx, task, action, arg));
return (ctx->methods->ctxonrun(ctx, mctx, task, action, arg));
}
isc_result_t
isc_app_ctxsuspend(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxsuspend(ctx));
return (ctx->methods->ctxsuspend(ctx));
}
isc_result_t
isc_app_ctxshutdown(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
return (isc__app_ctxshutdown(ctx));
return (ctx->methods->ctxshutdown(ctx));
}
void
isc_app_ctxfinish(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
if (isc_bind9)
isc__app_ctxfinish(ctx);
ctx->methods->ctxfinish(ctx);
}
void
isc_appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(taskmgr != NULL);
if (isc_bind9)
isc__appctx_settaskmgr(ctx, taskmgr);
ctx->methods->settaskmgr(ctx, taskmgr);
}
void
isc_appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(socketmgr != NULL);
if (isc_bind9)
isc__appctx_setsocketmgr(ctx, socketmgr);
ctx->methods->setsocketmgr(ctx, socketmgr);
}
void
isc_appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(timermgr != NULL);
if (isc_bind9)
isc__appctx_settimermgr(ctx, timermgr);
ctx->methods->settimermgr(ctx, timermgr);
}
isc_result_t
isc_app_start(void) {
if (isc_bind9)
return (isc__app_start());
return (ISC_R_NOTIMPLEMENTED);
}
isc_result_t
isc_app_onrun(isc_mem_t *mctx, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
if (isc_bind9)
return (isc__app_onrun(mctx, task, action, arg));
return (ISC_R_NOTIMPLEMENTED);
}
isc_result_t
isc_app_run() {
if (isc_bind9) {
isc_result_t result;
is_running = true;
result = isc__app_run();
is_running = false;
return (result);
}
return (ISC_R_NOTIMPLEMENTED);
}
bool
isc_app_isrunning() {
return (is_running);
}
isc_result_t
isc_app_shutdown(void) {
if (isc_bind9)
return (isc__app_shutdown());
return (ISC_R_NOTIMPLEMENTED);
}
isc_result_t
isc_app_reload(void) {
if (isc_bind9)
return (isc__app_reload());
return (ISC_R_NOTIMPLEMENTED);
}
void
isc_app_finish(void) {
if (!isc_bind9)
return;
isc__app_finish();
}
void
isc_app_block(void) {
if (!isc_bind9)
return;
isc__app_block();
}
void
isc_app_unblock(void) {
if (!isc_bind9)
return;
isc__app_unblock();
}
-24
View File
@@ -94,29 +94,6 @@ typedef isc_event_t isc_appevent_t;
#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1)
#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535)
/*%
* app module methods. Only app driver implementations use this structure.
* Other clients should use the top-level interfaces (i.e., isc_app_xxx
* functions). magic must be ISCAPI_APPMETHODS_MAGIC.
*/
typedef struct isc_appmethods {
void (*ctxdestroy)(isc_appctx_t **ctxp);
isc_result_t (*ctxstart)(isc_appctx_t *ctx);
isc_result_t (*ctxrun)(isc_appctx_t *ctx);
isc_result_t (*ctxsuspend)(isc_appctx_t *ctx);
isc_result_t (*ctxshutdown)(isc_appctx_t *ctx);
void (*ctxfinish)(isc_appctx_t *ctx);
void (*settaskmgr)(isc_appctx_t *ctx,
isc_taskmgr_t *timermgr);
void (*setsocketmgr)(isc_appctx_t *ctx,
isc_socketmgr_t *timermgr);
void (*settimermgr)(isc_appctx_t *ctx,
isc_timermgr_t *timermgr);
isc_result_t (*ctxonrun)(isc_appctx_t *ctx, isc_mem_t *mctx,
isc_task_t *task, isc_taskaction_t action,
void *arg);
} isc_appmethods_t;
/*%
* This structure is actually just the common prefix of an application context
* implementation's version of an isc_appctx_t.
@@ -129,7 +106,6 @@ typedef struct isc_appmethods {
struct isc_appctx {
unsigned int impmagic;
unsigned int magic;
isc_appmethods_t *methods;
};
#define ISCAPI_APPCTX_MAGIC ISC_MAGIC('A','a','p','c')
-64
View File
@@ -181,44 +181,6 @@ LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
* \endcode
*/
/*% memory and memory pool methods */
typedef struct isc_memmethods {
void (*attach)(isc_mem_t *source, isc_mem_t **targetp);
void (*detach)(isc_mem_t **mctxp);
void (*destroy)(isc_mem_t **mctxp);
void *(*memget)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
void (*memput)(isc_mem_t *mctx, void *ptr, size_t size _ISC_MEM_FLARG);
void (*memputanddetach)(isc_mem_t **mctxp, void *ptr,
size_t size _ISC_MEM_FLARG);
void *(*memallocate)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
void *(*memreallocate)(isc_mem_t *mctx, void *ptr,
size_t size _ISC_MEM_FLARG);
char *(*memstrdup)(isc_mem_t *mctx, const char *s _ISC_MEM_FLARG);
void (*memfree)(isc_mem_t *mctx, void *ptr _ISC_MEM_FLARG);
void (*setdestroycheck)(isc_mem_t *mctx, bool flag);
void (*setwater)(isc_mem_t *ctx, isc_mem_water_t water,
void *water_arg, size_t hiwater, size_t lowater);
void (*waterack)(isc_mem_t *ctx, int flag);
size_t (*inuse)(isc_mem_t *mctx);
size_t (*maxinuse)(isc_mem_t *mctx);
size_t (*total)(isc_mem_t *mctx);
bool (*isovermem)(isc_mem_t *mctx);
isc_result_t (*mpcreate)(isc_mem_t *mctx, size_t size,
isc_mempool_t **mpctxp);
} isc_memmethods_t;
typedef struct isc_mempoolmethods {
void (*destroy)(isc_mempool_t **mpctxp);
void *(*get)(isc_mempool_t *mpctx _ISC_MEM_FLARG);
void (*put)(isc_mempool_t *mpctx, void *mem _ISC_MEM_FLARG);
unsigned int (*getallocated)(isc_mempool_t *mpctx);
void (*setmaxalloc)(isc_mempool_t *mpctx, unsigned int limit);
void (*setfreemax)(isc_mempool_t *mpctx, unsigned int limit);
void (*setname)(isc_mempool_t *mpctx, const char *name);
void (*associatelock)(isc_mempool_t *mpctx, isc_mutex_t *lock);
void (*setfillcount)(isc_mempool_t *mpctx, unsigned int limit);
} isc_mempoolmethods_t;
/*%
* This structure is actually just the common prefix of a memory context
* implementation's version of an isc_mem_t.
@@ -231,7 +193,6 @@ typedef struct isc_mempoolmethods {
struct isc_mem {
unsigned int impmagic;
unsigned int magic;
isc_memmethods_t *methods;
};
#define ISCAPI_MCTX_MAGIC ISC_MAGIC('A','m','c','x')
@@ -245,7 +206,6 @@ struct isc_mem {
struct isc_mempool {
unsigned int impmagic;
unsigned int magic;
isc_mempoolmethods_t *methods;
};
#define ISCAPI_MPOOL_MAGIC ISC_MAGIC('A','m','p','l')
@@ -702,30 +662,6 @@ ISCMEMPOOLFUNC(get)(isc_mempool_t * _ISC_MEM_FLARG);
void
ISCMEMPOOLFUNC(put)(isc_mempool_t *, void * _ISC_MEM_FLARG);
/*%<
* See isc_mem_create2() above.
*/
typedef isc_result_t
(*isc_memcreatefunc_t)(size_t init_max_size, size_t target_size,
isc_mem_t **ctxp, unsigned int flags);
isc_result_t
isc_mem_register(isc_memcreatefunc_t createfunc);
/*%<
* Register a new memory management implementation and add it to the list of
* supported implementations. This function must be called when a different
* memory management library is used than the one contained in the ISC library.
*/
isc_result_t
isc__mem_register(void);
/*%<
* A short cut function that specifies the memory management module in the ISC
* library for isc_mem_register(). An application that uses the ISC library
* usually do not have to care about this function: it would call
* isc_lib_register(), which internally calls this function.
*/
void
isc__mem_printactive(isc_mem_t *mctx, FILE *file);
/*%<
-5
View File
@@ -194,11 +194,6 @@
*** Miscellaneous.
***/
/*
* Defined if we are using threads.
*/
@ISC_PLATFORM_USETHREADS@
/*
* Defined if unistd.h does not cause fd_set to be delared.
*/
-39
View File
@@ -94,7 +94,6 @@ ISC_LANG_BEGINDECLS
/*
* Sample implementations
*/
#ifdef ISC_PLATFORM_USETHREADS
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) || defined(ISC_PLATFORM_HAVEXADD)
#define ISC_REFCOUNT_HAVEATOMIC 1
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE))
@@ -253,44 +252,6 @@ typedef struct isc_refcount {
} while (0)
#endif /* (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) || defined(ISC_PLATFORM_HAVEXADD) */
#else /* ISC_PLATFORM_USETHREADS */
typedef struct isc_refcount {
int refs;
} isc_refcount_t;
#define isc_refcount_destroy(rp) ISC_REQUIRE((rp)->refs == 0)
#define isc_refcount_current(rp) ((unsigned int)((rp)->refs))
#define isc_refcount_increment0(rp, tp) \
do { \
unsigned int *_tmp = (unsigned int *)(tp); \
int _n = ++(rp)->refs; \
if (_tmp != NULL) \
*_tmp = _n; \
} while (0)
#define isc_refcount_increment(rp, tp) \
do { \
unsigned int *_tmp = (unsigned int *)(tp); \
int _n; \
ISC_REQUIRE((rp)->refs > 0); \
_n = ++(rp)->refs; \
if (_tmp != NULL) \
*_tmp = _n; \
} while (0)
#define isc_refcount_decrement(rp, tp) \
do { \
unsigned int *_tmp = (unsigned int *)(tp); \
int _n; \
ISC_REQUIRE((rp)->refs > 0); \
_n = --(rp)->refs; \
if (_tmp != NULL) \
*_tmp = _n; \
} while (0)
#endif /* ISC_PLATFORM_USETHREADS */
isc_result_t
isc_refcount_init(isc_refcount_t *ref, unsigned int n);
-9
View File
@@ -34,7 +34,6 @@ typedef enum {
isc_rwlocktype_write
} isc_rwlocktype_t;
#ifdef ISC_PLATFORM_USETHREADS
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) || (defined(ISC_PLATFORM_HAVEXADD) && defined(ISC_PLATFORM_HAVECMPXCHG))
#define ISC_RWLOCK_USEATOMIC 1
#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE))
@@ -108,14 +107,6 @@ struct isc_rwlock {
isc_rwlocktype_t original;
#endif /* ISC_RWLOCK_USEATOMIC */
};
#else /* ISC_PLATFORM_USETHREADS */
struct isc_rwlock {
unsigned int magic;
isc_rwlocktype_t type;
unsigned int active;
};
#endif /* ISC_PLATFORM_USETHREADS */
isc_result_t
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
+3 -125
View File
@@ -62,55 +62,6 @@
#include <isc/types.h>
#include <isc/xml.h>
#ifdef WIN32
/* from the old namespace.h */
#define isc_socket_create isc__socket_create
#define isc_socket_dup isc__socket_dup
#define isc_socket_attach isc__socket_attach
#define isc_socket_detach isc__socket_detach
#define isc_socketmgr_create isc__socketmgr_create
#define isc_socketmgr_create2 isc__socketmgr_create2
#define isc_socketmgr_destroy isc__socketmgr_destroy
#define isc_socket_open isc__socket_open
#define isc_socket_close isc__socket_close
#define isc_socket_recvv isc__socket_recvv
#define isc_socket_recv isc__socket_recv
#define isc_socket_recv2 isc__socket_recv2
#define isc_socket_send isc__socket_send
#define isc_socket_sendto isc__socket_sendto
#define isc_socket_sendv isc__socket_sendv
#define isc_socket_sendtov isc__socket_sendtov
#define isc_socket_sendtov2 isc__socket_sendtov2
#define isc_socket_sendto2 isc__socket_sendto2
#define isc_socket_cleanunix isc__socket_cleanunix
#define isc_socket_permunix isc__socket_permunix
#define isc_socket_bind isc__socket_bind
#define isc_socket_filter isc__socket_filter
#define isc_socket_listen isc__socket_listen
#define isc_socket_accept isc__socket_accept
#define isc_socket_connect isc__socket_connect
#define isc_socket_getfd isc__socket_getfd
#define isc_socket_getname isc__socket_getname
#define isc_socket_gettag isc__socket_gettag
#define isc_socket_getpeername isc__socket_getpeername
#define isc_socket_getsockname isc__socket_getsockname
#define isc_socket_cancel isc__socket_cancel
#define isc_socket_gettype isc__socket_gettype
#define isc_socket_isbound isc__socket_isbound
#define isc_socket_ipv6only isc__socket_ipv6only
#define isc_socket_setname isc__socket_setname
#define isc_socketmgr_getmaxsockets isc__socketmgr_getmaxsockets
#define isc_socketmgr_setstats isc__socketmgr_setstats
#define isc_socketmgr_setreserved isc__socketmgr_setreserved
#define isc__socketmgr_maxudp isc___socketmgr_maxudp
#define isc_socket_fdwatchcreate isc__socket_fdwatchcreate
#define isc_socket_fdwatchpoke isc__socket_fdwatchpoke
#define isc_socket_dscp isc__socket_dscp
#endif
ISC_LANG_BEGINDECLS
/***
@@ -333,60 +284,6 @@ typedef enum {
#define ISC_SOCKFDWATCH_WRITE 0x00000002 /*%< watch for writable */
/*@}*/
/*% Socket and socket manager methods */
typedef struct isc_socketmgrmethods {
void (*destroy)(isc_socketmgr_t **managerp);
isc_result_t (*socketcreate)(isc_socketmgr_t *manager, int pf,
isc_sockettype_t type,
isc_socket_t **socketp);
isc_result_t (*fdwatchcreate)(isc_socketmgr_t *manager, int fd,
int flags,
isc_sockfdwatch_t callback,
void *cbarg, isc_task_t *task,
isc_socket_t **socketp);
} isc_socketmgrmethods_t;
typedef struct isc_socketmethods {
void (*attach)(isc_socket_t *socket,
isc_socket_t **socketp);
void (*detach)(isc_socket_t **socketp);
isc_result_t (*bind)(isc_socket_t *sock,
const isc_sockaddr_t *sockaddr,
unsigned int options);
isc_result_t (*sendto)(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task, isc_taskaction_t action,
void *arg,
const isc_sockaddr_t *address,
struct in6_pktinfo *pktinfo);
isc_result_t (*sendto2)(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task,
const isc_sockaddr_t *address,
struct in6_pktinfo *pktinfo,
isc_socketevent_t *event,
unsigned int flags);
isc_result_t (*connect)(isc_socket_t *sock,
const isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action,
void *arg);
isc_result_t (*recv)(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_taskaction_t action, void *arg);
isc_result_t (*recv2)(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_socketevent_t *event, unsigned int flags);
void (*cancel)(isc_socket_t *sock, isc_task_t *task,
unsigned int how);
isc_result_t (*getsockname)(isc_socket_t *sock,
isc_sockaddr_t *addressp);
isc_sockettype_t (*gettype)(isc_socket_t *sock);
void (*ipv6only)(isc_socket_t *sock, bool yes);
isc_result_t (*fdwatchpoke)(isc_socket_t *sock, int flags);
isc_result_t (*dup)(isc_socket_t *socket,
isc_socket_t **socketp);
int (*getfd)(isc_socket_t *socket);
void (*dscp)(isc_socket_t *socket, isc_dscp_t dscp);
} isc_socketmethods_t;
/*%
* This structure is actually just the common prefix of a socket manager
* object implementation's version of an isc_socketmgr_t.
@@ -404,7 +301,6 @@ typedef struct isc_socketmethods {
struct isc_socketmgr {
unsigned int impmagic;
unsigned int magic;
isc_socketmgrmethods_t *methods;
};
#endif
@@ -420,7 +316,6 @@ struct isc_socketmgr {
struct isc_socket {
unsigned int impmagic;
unsigned int magic;
isc_socketmethods_t *methods;
};
#endif
@@ -1138,7 +1033,7 @@ isc_socket_gettype(isc_socket_t *sock);
/*@{*/
bool
isc__socket_isbound(isc_socket_t *sock);
isc_socket_isbound(isc_socket_t *sock);
/*%
* Intended for internal use in BIND9 only
*/
@@ -1231,13 +1126,13 @@ int isc_socket_getfd(isc_socket_t *socket);
*/
void
isc__socketmgr_setreserved(isc_socketmgr_t *mgr, uint32_t);
isc_socketmgr_setreserved(isc_socketmgr_t *mgr, uint32_t);
/*%<
* Temporary. For use by named only.
*/
void
isc__socketmgr_maxudp(isc_socketmgr_t *mgr, int maxudp);
isc_socketmgr_maxudp(isc_socketmgr_t *mgr, int maxudp);
/*%<
* Test interface. Drop UDP packet > 'maxudp'.
*/
@@ -1264,23 +1159,6 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr, json_object *stats);
typedef isc_result_t
(*isc_socketmgrcreatefunc_t)(isc_mem_t *mctx, isc_socketmgr_t **managerp);
isc_result_t
isc_socket_register(isc_socketmgrcreatefunc_t createfunc);
/*%<
* Register a new socket I/O implementation and add it to the list of
* supported implementations. This function must be called when a different
* event library is used than the one contained in the ISC library.
*/
isc_result_t
isc__socket_register(void);
/*%<
* A short cut function that specifies the socket I/O module in the ISC
* library for isc_socket_register(). An application that uses the ISC library
* usually do not have to care about this function: it would call
* isc_lib_register(), which internally calls this function.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_SOCKET_H */
+2 -46
View File
@@ -102,42 +102,6 @@ typedef enum {
isc_taskmgrmode_privileged
} isc_taskmgrmode_t;
/*% Task and task manager methods */
typedef struct isc_taskmgrmethods {
void (*destroy)(isc_taskmgr_t **managerp);
void (*setmode)(isc_taskmgr_t *manager,
isc_taskmgrmode_t mode);
isc_taskmgrmode_t (*mode)(isc_taskmgr_t *manager);
isc_result_t (*taskcreate)(isc_taskmgr_t *manager,
unsigned int quantum,
isc_task_t **taskp);
void (*setexcltask)(isc_taskmgr_t *mgr, isc_task_t *task);
isc_result_t (*excltask)(isc_taskmgr_t *mgr, isc_task_t **taskp);
} isc_taskmgrmethods_t;
typedef struct isc_taskmethods {
void (*attach)(isc_task_t *source, isc_task_t **targetp);
void (*detach)(isc_task_t **taskp);
void (*destroy)(isc_task_t **taskp);
void (*send)(isc_task_t *task, isc_event_t **eventp);
void (*sendanddetach)(isc_task_t **taskp, isc_event_t **eventp);
unsigned int (*unsend)(isc_task_t *task, void *sender, isc_eventtype_t type,
void *tag, isc_eventlist_t *events);
isc_result_t (*onshutdown)(isc_task_t *task, isc_taskaction_t action,
void *arg);
void (*shutdown)(isc_task_t *task);
void (*setname)(isc_task_t *task, const char *name, void *tag);
unsigned int (*purgeevents)(isc_task_t *task, void *sender,
isc_eventtype_t type, void *tag);
unsigned int (*purgerange)(isc_task_t *task, void *sender,
isc_eventtype_t first, isc_eventtype_t last,
void *tag);
isc_result_t (*beginexclusive)(isc_task_t *task);
void (*endexclusive)(isc_task_t *task);
void (*setprivilege)(isc_task_t *task, bool priv);
bool (*privilege)(isc_task_t *task);
} isc_taskmethods_t;
/*%
* This structure is actually just the common prefix of a task manager
* object implementation's version of an isc_taskmgr_t.
@@ -150,7 +114,6 @@ typedef struct isc_taskmethods {
struct isc_taskmgr {
unsigned int impmagic;
unsigned int magic;
isc_taskmgrmethods_t *methods;
};
#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A','t','m','g')
@@ -164,7 +127,6 @@ struct isc_taskmgr {
struct isc_task {
unsigned int impmagic;
unsigned int magic;
isc_taskmethods_t *methods;
};
#define ISCAPI_TASK_MAGIC ISC_MAGIC('A','t','s','t')
@@ -246,6 +208,8 @@ isc_task_detach(isc_task_t **taskp);
void
isc_task_send(isc_task_t *task, isc_event_t **eventp);
void
isc_task_sendto(isc_task_t *task, isc_event_t **eventp, int id);
/*%<
* Send '*event' to 'task'.
*
@@ -826,19 +790,11 @@ isc__task_register(void);
* These functions allow unit tests to manipulate the processing
* of the task queue. They are not intended as part of the public API.
*/
#if defined(ISC_PLATFORM_USETHREADS)
void
isc__taskmgr_pause(isc_taskmgr_t *taskmgr);
void
isc__taskmgr_resume(isc_taskmgr_t *taskmgr);
#else
bool
isc__taskmgr_ready(isc_taskmgr_t *taskmgr);
isc_result_t
isc__taskmgr_dispatch(isc_taskmgr_t *taskmgr);
#endif /* !ISC_PLATFORM_USETHREADS */
ISC_LANG_ENDDECLS
-25
View File
@@ -99,29 +99,6 @@ typedef struct isc_timerevent {
#define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
#define ISC_TIMEREVENT_LASTEVENT (ISC_EVENTCLASS_TIMER + 65535)
/*% Timer and timer manager methods */
typedef struct {
void (*destroy)(isc_timermgr_t **managerp);
isc_result_t (*timercreate)(isc_timermgr_t *manager,
isc_timertype_t type,
const isc_time_t *expires,
const isc_interval_t *interval,
isc_task_t *task,
isc_taskaction_t action,
void *arg,
isc_timer_t **timerp);
} isc_timermgrmethods_t;
typedef struct {
void (*attach)(isc_timer_t *timer, isc_timer_t **timerp);
void (*detach)(isc_timer_t **timerp);
isc_result_t (*reset)(isc_timer_t *timer, isc_timertype_t type,
const isc_time_t *expires,
const isc_interval_t *interval,
bool purge);
isc_result_t (*touch)(isc_timer_t *timer);
} isc_timermethods_t;
/*%
* This structure is actually just the common prefix of a timer manager
* object implementation's version of an isc_timermgr_t.
@@ -134,7 +111,6 @@ typedef struct {
struct isc_timermgr {
unsigned int impmagic;
unsigned int magic;
isc_timermgrmethods_t *methods;
};
#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A','t','m','g')
@@ -148,7 +124,6 @@ struct isc_timermgr {
struct isc_timer {
unsigned int impmagic;
unsigned int magic;
isc_timermethods_t *methods;
};
#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A','t','m','r')
+1 -15
View File
@@ -77,21 +77,7 @@ isc_lib_initmsgcat(void) {
}
}
static isc_once_t register_once = ISC_ONCE_INIT;
static void
do_register(void) {
isc_bind9 = false;
RUNTIME_CHECK(isc__mem_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__app_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__task_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__socket_register() == ISC_R_SUCCESS);
RUNTIME_CHECK(isc__timer_register() == ISC_R_SUCCESS);
}
void
isc_lib_register(void) {
RUNTIME_CHECK(isc_once_do(&register_once, do_register)
== ISC_R_SUCCESS);
isc_bind9 = false;
}
+31 -531
View File
@@ -110,7 +110,6 @@ static ISC_LIST(isc__mem_t) contexts;
static isc_once_t once = ISC_ONCE_INIT;
static isc_mutex_t contextslock;
static isc_mutex_t createlock;
/*%
* Total size of lost memory due to a bug of external library.
@@ -217,163 +216,6 @@ struct isc__mempool {
static void
print_active(isc__mem_t *ctx, FILE *out);
#endif /* ISC_MEM_TRACKLINES */
/*%
* The following are intended for internal use (indicated by "isc__"
* prefix) but are not declared as static, allowing direct access
* from unit tests, etc.
*/
isc_result_t
isc__mem_create2(size_t init_max_size, size_t target_size,
isc_mem_t **ctxp, unsigned int flags);
void
isc__mem_attach(isc_mem_t *source, isc_mem_t **targetp);
void
isc__mem_detach(isc_mem_t **ctxp);
void
isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG);
void
isc__mem_destroy(isc_mem_t **ctxp);
void *
isc___mem_get(isc_mem_t *ctx, size_t size FLARG);
void
isc___mem_put(isc_mem_t *ctx, void *ptr, size_t size FLARG);
void
isc__mem_stats(isc_mem_t *ctx, FILE *out);
void *
isc___mem_allocate(isc_mem_t *ctx, size_t size FLARG);
void *
isc___mem_reallocate(isc_mem_t *ctx, void *ptr, size_t size FLARG);
void
isc___mem_free(isc_mem_t *ctx, void *ptr FLARG);
char *
isc___mem_strdup(isc_mem_t *mctx, const char *s FLARG);
void
isc__mem_setdestroycheck(isc_mem_t *ctx, bool flag);
void
isc__mem_setquota(isc_mem_t *ctx, size_t quota);
size_t
isc__mem_getquota(isc_mem_t *ctx);
size_t
isc__mem_inuse(isc_mem_t *ctx);
size_t
isc__mem_maxinuse(isc_mem_t *ctx);
size_t
isc__mem_total(isc_mem_t *ctx);
bool
isc__mem_isovermem(isc_mem_t *ctx);
void
isc__mem_setwater(isc_mem_t *ctx, isc_mem_water_t water, void *water_arg,
size_t hiwater, size_t lowater);
void
isc__mem_waterack(isc_mem_t *ctx0, int flag);
void
isc__mem_setname(isc_mem_t *ctx, const char *name, void *tag);
const char *
isc__mem_getname(isc_mem_t *ctx);
void *
isc__mem_gettag(isc_mem_t *ctx);
isc_result_t
isc__mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
void
isc__mempool_setname(isc_mempool_t *mpctx, const char *name);
void
isc__mempool_destroy(isc_mempool_t **mpctxp);
void
isc__mempool_associatelock(isc_mempool_t *mpctx, isc_mutex_t *lock);
void *
isc___mempool_get(isc_mempool_t *mpctx FLARG);
void
isc___mempool_put(isc_mempool_t *mpctx, void *mem FLARG);
void
isc__mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit);
unsigned int
isc__mempool_getfreemax(isc_mempool_t *mpctx);
unsigned int
isc__mempool_getfreecount(isc_mempool_t *mpctx);
void
isc__mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit);
unsigned int
isc__mempool_getmaxalloc(isc_mempool_t *mpctx);
unsigned int
isc__mempool_getallocated(isc_mempool_t *mpctx);
void
isc__mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit);
unsigned int
isc__mempool_getfillcount(isc_mempool_t *mpctx);
void
isc__mem_printactive(isc_mem_t *ctx0, FILE *file);
unsigned int
isc__mem_references(isc_mem_t *ctx0);
static struct isc__memmethods {
isc_memmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *createx, *create, *create2, *stats,
*setquota, *getquota, *setname, *getname, *gettag;
} memmethods = {
{
isc__mem_attach,
isc__mem_detach,
isc__mem_destroy,
isc___mem_get,
isc___mem_put,
isc___mem_putanddetach,
isc___mem_allocate,
isc___mem_reallocate,
isc___mem_strdup,
isc___mem_free,
isc__mem_setdestroycheck,
isc__mem_setwater,
isc__mem_waterack,
isc__mem_inuse,
isc__mem_maxinuse,
isc__mem_total,
isc__mem_isovermem,
isc__mempool_create
},
(void *)isc_mem_createx,
(void *)isc_mem_create,
(void *)isc_mem_create2,
(void *)isc_mem_stats,
(void *)isc_mem_setquota,
(void *)isc_mem_getquota,
(void *)isc_mem_setname,
(void *)isc_mem_getname,
(void *)isc_mem_gettag
};
static struct isc__mempoolmethods {
isc_mempoolmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *getfreemax, *getfreecount, *getmaxalloc, *getfillcount;
} mempoolmethods = {
{
isc__mempool_destroy,
isc___mempool_get,
isc___mempool_put,
isc__mempool_getallocated,
isc__mempool_setmaxalloc,
isc__mempool_setfreemax,
isc__mempool_setname,
isc__mempool_associatelock,
isc__mempool_setfillcount
},
(void *)isc_mempool_getfreemax,
(void *)isc_mempool_getfreecount,
(void *)isc_mempool_getmaxalloc,
(void *)isc_mempool_getfillcount
};
#if ISC_MEM_TRACKLINES
/*!
* mctx must be locked.
*/
@@ -852,7 +694,6 @@ default_memfree(void *arg, void *ptr) {
static void
initialize_action(void) {
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_mutex_init(&contextslock) == ISC_R_SUCCESS);
ISC_LIST_INIT(contexts);
totallost = 0;
@@ -922,7 +763,6 @@ isc_mem_createx2(size_t init_max_size, size_t target_size,
ctx->water_arg = NULL;
ctx->common.impmagic = MEM_MAGIC;
ctx->common.magic = ISCAPI_MCTX_MAGIC;
ctx->common.methods = (isc_memmethods_t *)&memmethods;
ctx->memalloc = memalloc;
ctx->memfree = memfree;
ctx->arg = arg;
@@ -1092,7 +932,7 @@ destroy(isc__mem_t *ctx) {
}
void
isc__mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
isc_mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
isc__mem_t *source = (isc__mem_t *)source0;
REQUIRE(VALID_CONTEXT(source));
@@ -1106,7 +946,7 @@ isc__mem_attach(isc_mem_t *source0, isc_mem_t **targetp) {
}
void
isc__mem_detach(isc_mem_t **ctxp) {
isc_mem_detach(isc_mem_t **ctxp) {
isc__mem_t *ctx;
bool want_destroy = false;
@@ -1138,7 +978,7 @@ isc__mem_detach(isc_mem_t **ctxp) {
*/
void
isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
isc__mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
isc__mem_t *ctx;
bool want_destroy = false;
size_info *si;
@@ -1201,7 +1041,7 @@ isc___mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size FLARG) {
}
void
isc__mem_destroy(isc_mem_t **ctxp) {
isc_mem_destroy(isc_mem_t **ctxp) {
isc__mem_t *ctx;
/*
@@ -1228,7 +1068,7 @@ isc__mem_destroy(isc_mem_t **ctxp) {
}
void *
isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
isc__mem_get(isc_mem_t *ctx0, size_t size FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
void *ptr;
bool call_water = false;
@@ -1272,7 +1112,7 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
}
void
isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
isc__mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
bool call_water = false;
size_info *si;
@@ -1324,7 +1164,7 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
}
void
isc__mem_waterack(isc_mem_t *ctx0, int flag) {
isc_mem_waterack(isc_mem_t *ctx0, int flag) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
@@ -1486,7 +1326,7 @@ mem_allocateunlocked(isc_mem_t *ctx0, size_t size) {
}
void *
isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
isc__mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_info *si;
bool call_water = false;
@@ -1526,7 +1366,7 @@ isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
}
void *
isc___mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
isc__mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
void *new_ptr = NULL;
size_t oldsize, copysize;
@@ -1567,7 +1407,7 @@ isc___mem_reallocate(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
}
void
isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
isc__mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_info *si;
size_t size;
@@ -1625,7 +1465,7 @@ isc___mem_free(isc_mem_t *ctx0, void *ptr FLARG) {
*/
char *
isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
isc__mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
isc__mem_t *mctx = (isc__mem_t *)mctx0;
size_t len;
char *ns;
@@ -1644,7 +1484,7 @@ isc___mem_strdup(isc_mem_t *mctx0, const char *s FLARG) {
}
void
isc__mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
isc_mem_setdestroycheck(isc_mem_t *ctx0, bool flag) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
@@ -1687,7 +1527,7 @@ isc_mem_getquota(isc_mem_t *ctx0) {
}
size_t
isc__mem_inuse(isc_mem_t *ctx0) {
isc_mem_inuse(isc_mem_t *ctx0) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_t inuse;
@@ -1702,7 +1542,7 @@ isc__mem_inuse(isc_mem_t *ctx0) {
}
size_t
isc__mem_maxinuse(isc_mem_t *ctx0) {
isc_mem_maxinuse(isc_mem_t *ctx0) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_t maxinuse;
@@ -1717,7 +1557,7 @@ isc__mem_maxinuse(isc_mem_t *ctx0) {
}
size_t
isc__mem_total(isc_mem_t *ctx0) {
isc_mem_total(isc_mem_t *ctx0) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
size_t total;
@@ -1732,7 +1572,7 @@ isc__mem_total(isc_mem_t *ctx0) {
}
void
isc__mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
isc_mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
size_t hiwater, size_t lowater)
{
isc__mem_t *ctx = (isc__mem_t *)ctx0;
@@ -1769,7 +1609,7 @@ isc__mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
}
bool
isc__mem_isovermem(isc_mem_t *ctx0) {
isc_mem_isovermem(isc_mem_t *ctx0) {
isc__mem_t *ctx = (isc__mem_t *)ctx0;
REQUIRE(VALID_CONTEXT(ctx));
@@ -1820,7 +1660,7 @@ isc_mem_gettag(isc_mem_t *ctx0) {
*/
isc_result_t
isc__mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
isc_mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
isc__mem_t *mctx = (isc__mem_t *)mctx0;
isc__mempool_t *mpctx;
@@ -1836,7 +1676,6 @@ isc__mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
if (mpctx == NULL)
return (ISC_R_NOMEMORY);
mpctx->common.methods = (isc_mempoolmethods_t *)&mempoolmethods;
mpctx->common.impmagic = MEMPOOL_MAGIC;
mpctx->common.magic = ISCAPI_MPOOL_MAGIC;
mpctx->lock = NULL;
@@ -1864,7 +1703,7 @@ isc__mempool_create(isc_mem_t *mctx0, size_t size, isc_mempool_t **mpctxp) {
}
void
isc__mempool_setname(isc_mempool_t *mpctx0, const char *name) {
isc_mempool_setname(isc_mempool_t *mpctx0, const char *name) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(name != NULL);
@@ -1885,7 +1724,7 @@ isc__mempool_setname(isc_mempool_t *mpctx0, const char *name) {
}
void
isc__mempool_destroy(isc_mempool_t **mpctxp) {
isc_mempool_destroy(isc_mempool_t **mpctxp) {
isc__mempool_t *mpctx;
isc__mem_t *mctx;
isc_mutex_t *lock;
@@ -1949,7 +1788,7 @@ isc__mempool_destroy(isc_mempool_t **mpctxp) {
}
void
isc__mempool_associatelock(isc_mempool_t *mpctx0, isc_mutex_t *lock) {
isc_mempool_associatelock(isc_mempool_t *mpctx0, isc_mutex_t *lock) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(VALID_MEMPOOL(mpctx));
@@ -1960,7 +1799,7 @@ isc__mempool_associatelock(isc_mempool_t *mpctx0, isc_mutex_t *lock) {
}
void *
isc___mempool_get(isc_mempool_t *mpctx0 FLARG) {
isc__mempool_get(isc_mempool_t *mpctx0 FLARG) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
element *item;
isc__mem_t *mctx;
@@ -2036,7 +1875,7 @@ isc___mempool_get(isc_mempool_t *mpctx0 FLARG) {
/* coverity[+free : arg-1] */
void
isc___mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
isc__mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
isc__mem_t *mctx;
element *item;
@@ -2094,7 +1933,7 @@ isc___mempool_put(isc_mempool_t *mpctx0, void *mem FLARG) {
*/
void
isc__mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
isc_mempool_setfreemax(isc_mempool_t *mpctx0, unsigned int limit) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(VALID_MEMPOOL(mpctx));
@@ -2145,7 +1984,7 @@ isc_mempool_getfreecount(isc_mempool_t *mpctx0) {
}
void
isc__mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
isc_mempool_setmaxalloc(isc_mempool_t *mpctx0, unsigned int limit) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(limit > 0);
@@ -2180,7 +2019,7 @@ isc_mempool_getmaxalloc(isc_mempool_t *mpctx0) {
}
unsigned int
isc__mempool_getallocated(isc_mempool_t *mpctx0) {
isc_mempool_getallocated(isc_mempool_t *mpctx0) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
unsigned int allocated;
@@ -2198,7 +2037,7 @@ isc__mempool_getallocated(isc_mempool_t *mpctx0) {
}
void
isc__mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
isc_mempool_setfillcount(isc_mempool_t *mpctx0, unsigned int limit) {
isc__mempool_t *mpctx = (isc__mempool_t *)mpctx0;
REQUIRE(limit > 0);
@@ -2232,13 +2071,8 @@ isc_mempool_getfillcount(isc_mempool_t *mpctx0) {
return (fillcount);
}
isc_result_t
isc__mem_register(void) {
return (isc_mem_register(isc_mem_create2));
}
void
isc__mem_printactive(isc_mem_t *ctx0, FILE *file) {
isc_mem_printactive(isc_mem_t *ctx0, FILE *file) {
#if ISC_MEM_TRACKLINES
isc__mem_t *ctx = (isc__mem_t *)ctx0;
@@ -2683,352 +2517,18 @@ isc_mem_renderjson(json_object *memobj) {
}
#endif /* HAVE_JSON */
static isc_memcreatefunc_t mem_createfunc = NULL;
isc_result_t
isc_mem_register(isc_memcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
LOCK(&createlock);
if (mem_createfunc == NULL)
mem_createfunc = createfunc;
else
result = ISC_R_EXISTS;
UNLOCK(&createlock);
return (result);
}
isc_result_t
isc__mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
unsigned int flags)
{
isc_result_t result;
LOCK(&createlock);
REQUIRE(mem_createfunc != NULL);
result = (*mem_createfunc)(init_max_size, target_size, mctxp, flags);
UNLOCK(&createlock);
return (result);
}
isc_result_t
isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) {
isc_result_t result;
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, isc_mem_defaultflags));
LOCK(&createlock);
REQUIRE(mem_createfunc != NULL);
result = (*mem_createfunc)(init_max_size, target_size, mctxp,
isc_mem_defaultflags);
UNLOCK(&createlock);
return (result);
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, isc_mem_defaultflags));
}
isc_result_t
isc_mem_create2(size_t init_max_size, size_t target_size, isc_mem_t **mctxp,
unsigned int flags)
{
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, flags));
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, flags));
}
void
isc_mem_attach(isc_mem_t *source, isc_mem_t **targetp) {
REQUIRE(ISCAPI_MCTX_VALID(source));
REQUIRE(targetp != NULL && *targetp == NULL);
if (isc_bind9)
isc__mem_attach(source, targetp);
else
source->methods->attach(source, targetp);
ENSURE(*targetp == source);
}
void
isc_mem_detach(isc_mem_t **mctxp) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc__mem_detach(mctxp);
else
(*mctxp)->methods->detach(mctxp);
ENSURE(*mctxp == NULL);
}
void
isc_mem_destroy(isc_mem_t **mctxp) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc__mem_destroy(mctxp);
else
(*mctxp)->methods->destroy(mctxp);
ENSURE(*mctxp == NULL);
}
void
isc_mem_setdestroycheck(isc_mem_t *mctx, bool flag) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
mctx->methods->setdestroycheck(mctx, flag);
}
void
isc_mem_setwater(isc_mem_t *ctx, isc_mem_water_t water, void *water_arg,
size_t hiwater, size_t lowater)
{
REQUIRE(ISCAPI_MCTX_VALID(ctx));
if (isc_bind9)
isc__mem_setwater(ctx, water, water_arg, hiwater, lowater);
else
ctx->methods->setwater(ctx, water, water_arg, hiwater, lowater);
}
void
isc_mem_waterack(isc_mem_t *ctx, int flag) {
REQUIRE(ISCAPI_MCTX_VALID(ctx));
if (isc_bind9)
isc__mem_waterack(ctx, flag);
else
ctx->methods->waterack(ctx, flag);
}
size_t
isc_mem_inuse(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_inuse(mctx));
return (mctx->methods->inuse(mctx));
}
size_t
isc_mem_maxinuse(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_maxinuse(mctx));
return (mctx->methods->maxinuse(mctx));
}
size_t
isc_mem_total(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_total(mctx));
return (mctx->methods->total(mctx));
}
bool
isc_mem_isovermem(isc_mem_t *mctx) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc__mem_isovermem(mctx));
return (mctx->methods->isovermem(mctx));
}
isc_result_t
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
return (mctx->methods->mpcreate(mctx, size, mpctxp));
}
void
isc_mempool_destroy(isc_mempool_t **mpctxp) {
REQUIRE(mpctxp != NULL && ISCAPI_MPOOL_VALID(*mpctxp));
if (isc_bind9)
isc__mempool_destroy(mpctxp);
else
(*mpctxp)->methods->destroy(mpctxp);
ENSURE(*mpctxp == NULL);
}
unsigned int
isc_mempool_getallocated(isc_mempool_t *mpctx) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
return (isc__mempool_getallocated(mpctx));
return (mpctx->methods->getallocated(mpctx));
}
void
isc_mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setmaxalloc(mpctx, limit);
else
mpctx->methods->setmaxalloc(mpctx, limit);
}
void
isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setfreemax(mpctx, limit);
else
mpctx->methods->setfreemax(mpctx, limit);
}
void
isc_mempool_setname(isc_mempool_t *mpctx, const char *name) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setname(mpctx, name);
else
mpctx->methods->setname(mpctx, name);
}
void
isc_mempool_associatelock(isc_mempool_t *mpctx, isc_mutex_t *lock) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_associatelock(mpctx, lock);
else
mpctx->methods->associatelock(mpctx, lock);
}
void
isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc__mempool_setfillcount(mpctx, limit);
else
mpctx->methods->setfillcount(mpctx, limit);
}
void *
isc__mem_get(isc_mem_t *mctx, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_get(mctx, size FLARG_PASS));
return (mctx->methods->memget(mctx, size FLARG_PASS));
}
void
isc__mem_put(isc_mem_t *mctx, void *ptr, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
isc___mem_put(mctx, ptr, size FLARG_PASS);
else
mctx->methods->memput(mctx, ptr, size FLARG_PASS);
}
void
isc__mem_putanddetach(isc_mem_t **mctxp, void *ptr, size_t size FLARG) {
REQUIRE(mctxp != NULL && ISCAPI_MCTX_VALID(*mctxp));
if (isc_bind9)
isc___mem_putanddetach(mctxp, ptr, size FLARG_PASS);
else
(*mctxp)->methods->memputanddetach(mctxp, ptr, size FLARG_PASS);
/*
* XXX: We cannot always ensure *mctxp == NULL here
* (see lib/isc/mem.c).
*/
}
void *
isc__mem_allocate(isc_mem_t *mctx, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_allocate(mctx, size FLARG_PASS));
return (mctx->methods->memallocate(mctx, size FLARG_PASS));
}
void *
isc__mem_reallocate(isc_mem_t *mctx, void *ptr, size_t size FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_reallocate(mctx, ptr, size FLARG_PASS));
return (mctx->methods->memreallocate(mctx, ptr, size FLARG_PASS));
}
char *
isc__mem_strdup(isc_mem_t *mctx, const char *s FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
return (isc___mem_strdup(mctx, s FLARG_PASS));
return (mctx->methods->memstrdup(mctx, s FLARG_PASS));
}
void
isc__mem_free(isc_mem_t *mctx, void *ptr FLARG) {
REQUIRE(ISCAPI_MCTX_VALID(mctx));
if (isc_bind9)
isc___mem_free(mctx, ptr FLARG_PASS);
else
mctx->methods->memfree(mctx, ptr FLARG_PASS);
}
void *
isc__mempool_get(isc_mempool_t *mpctx FLARG) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
return (isc___mempool_get(mpctx FLARG_PASS));
return (mpctx->methods->get(mpctx FLARG_PASS));
}
void
isc__mempool_put(isc_mempool_t *mpctx, void *mem FLARG) {
REQUIRE(ISCAPI_MPOOL_VALID(mpctx));
if (isc_bind9)
isc___mempool_put(mpctx, mem FLARG_PASS);
else
mpctx->methods->put(mpctx, mem FLARG_PASS);
}
+1 -1
View File
@@ -62,7 +62,7 @@
*/
#include "xoshiro128starstar.c"
static isc_once_t isc_random_once = ISC_ONCE_INIT;
static thread_local isc_once_t isc_random_once = ISC_ONCE_INIT;
static void
isc_random_initialize(void) {
+1 -1
View File
@@ -24,7 +24,7 @@ isc_refcount_init(isc_refcount_t *ref, unsigned int n) {
REQUIRE(ref != NULL);
ref->refs = n;
#if defined(ISC_PLATFORM_USETHREADS) && !defined(ISC_REFCOUNT_HAVEATOMIC)
#if !defined(ISC_REFCOUNT_HAVEATOMIC)
return (isc_mutex_init(&ref->lock));
#else
return (ISC_R_SUCCESS);
-90
View File
@@ -29,8 +29,6 @@
#define RWLOCK_MAGIC ISC_MAGIC('R', 'W', 'L', 'k')
#define VALID_RWLOCK(rwl) ISC_MAGIC_VALID(rwl, RWLOCK_MAGIC)
#ifdef ISC_PLATFORM_USETHREADS
#ifndef RWLOCK_DEFAULT_READ_QUOTA
#define RWLOCK_DEFAULT_READ_QUOTA 4
#endif
@@ -892,91 +890,3 @@ isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
}
#endif /* ISC_RWLOCK_USEATOMIC */
#else /* ISC_PLATFORM_USETHREADS */
isc_result_t
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
unsigned int write_quota)
{
REQUIRE(rwl != NULL);
UNUSED(read_quota);
UNUSED(write_quota);
rwl->type = isc_rwlocktype_read;
rwl->active = 0;
rwl->magic = RWLOCK_MAGIC;
return (ISC_R_SUCCESS);
}
isc_result_t
isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
REQUIRE(VALID_RWLOCK(rwl));
if (type == isc_rwlocktype_read) {
if (rwl->type != isc_rwlocktype_read && rwl->active != 0)
return (ISC_R_LOCKBUSY);
rwl->type = isc_rwlocktype_read;
rwl->active++;
} else {
if (rwl->active != 0)
return (ISC_R_LOCKBUSY);
rwl->type = isc_rwlocktype_write;
rwl->active = 1;
}
return (ISC_R_SUCCESS);
}
isc_result_t
isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
return (isc_rwlock_lock(rwl, type));
}
isc_result_t
isc_rwlock_tryupgrade(isc_rwlock_t *rwl) {
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(VALID_RWLOCK(rwl));
REQUIRE(rwl->type == isc_rwlocktype_read);
REQUIRE(rwl->active != 0);
/* If we are the only reader then succeed. */
if (rwl->active == 1)
rwl->type = isc_rwlocktype_write;
else
result = ISC_R_LOCKBUSY;
return (result);
}
void
isc_rwlock_downgrade(isc_rwlock_t *rwl) {
REQUIRE(VALID_RWLOCK(rwl));
REQUIRE(rwl->type == isc_rwlocktype_write);
REQUIRE(rwl->active == 1);
rwl->type = isc_rwlocktype_read;
}
isc_result_t
isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
REQUIRE(VALID_RWLOCK(rwl));
REQUIRE(rwl->type == type);
UNUSED(type);
INSIST(rwl->active > 0);
rwl->active--;
return (ISC_R_SUCCESS);
}
void
isc_rwlock_destroy(isc_rwlock_t *rwl) {
REQUIRE(rwl != NULL);
REQUIRE(rwl->active == 0);
rwl->magic = 0;
}
#endif /* ISC_PLATFORM_USETHREADS */
-400
View File
@@ -1,400 +0,0 @@
/*
* 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 http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <config.h>
#include <inttypes.h>
#include <stdbool.h>
#include <isc/app.h>
#include <isc/magic.h>
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/socket.h>
#include <isc/util.h>
static isc_mutex_t createlock;
static isc_once_t once = ISC_ONCE_INIT;
static isc_socketmgrcreatefunc_t socketmgr_createfunc = NULL;
static void
initialize(void) {
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
}
isc_result_t
isc_socket_register(isc_socketmgrcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
LOCK(&createlock);
if (socketmgr_createfunc == NULL)
socketmgr_createfunc = createfunc;
else
result = ISC_R_EXISTS;
UNLOCK(&createlock);
return (result);
}
isc_result_t
isc_socketmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
isc_socketmgr_t **managerp)
{
isc_result_t result;
LOCK(&createlock);
REQUIRE(socketmgr_createfunc != NULL);
result = (*socketmgr_createfunc)(mctx, managerp);
UNLOCK(&createlock);
if (result == ISC_R_SUCCESS)
isc_appctx_setsocketmgr(actx, *managerp);
return (result);
}
isc_result_t
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
isc_result_t result;
if (isc_bind9)
return (isc__socketmgr_create(mctx, managerp));
LOCK(&createlock);
REQUIRE(socketmgr_createfunc != NULL);
result = (*socketmgr_createfunc)(mctx, managerp);
UNLOCK(&createlock);
return (result);
}
void
isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
REQUIRE(managerp != NULL && ISCAPI_SOCKETMGR_VALID(*managerp));
if (isc_bind9)
isc__socketmgr_destroy(managerp);
else
(*managerp)->methods->destroy(managerp);
ENSURE(*managerp == NULL);
}
isc_result_t
isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
isc_socket_t **socketp)
{
REQUIRE(ISCAPI_SOCKETMGR_VALID(manager));
if (isc_bind9)
return (isc__socket_create(manager, pf, type, socketp));
return (manager->methods->socketcreate(manager, pf, type, socketp));
}
void
isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
if (isc_bind9)
isc__socket_attach(sock, socketp);
else
sock->methods->attach(sock, socketp);
ENSURE(*socketp == sock);
}
void
isc_socket_detach(isc_socket_t **socketp) {
REQUIRE(socketp != NULL && ISCAPI_SOCKET_VALID(*socketp));
if (isc_bind9)
isc__socket_detach(socketp);
else
(*socketp)->methods->detach(socketp);
ENSURE(*socketp == NULL);
}
isc_result_t
isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
unsigned int options)
{
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_bind(sock, sockaddr, options));
return (sock->methods->bind(sock, sockaddr, options));
}
isc_result_t
isc_socket_sendto(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo)
{
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_sendto(sock, region, task,
action, arg, address, pktinfo));
return (sock->methods->sendto(sock, region, task, action, arg, address,
pktinfo));
}
isc_result_t
isc_socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_connect(sock, addr, task, action, arg));
return (sock->methods->connect(sock, addr, task, action, arg));
}
isc_result_t
isc_socket_recv(isc_socket_t *sock, isc_region_t *region, unsigned int minimum,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_recv(sock, region, minimum,
task, action, arg));
return (sock->methods->recv(sock, region, minimum, task, action, arg));
}
void
isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
isc__socket_cancel(sock, task, how);
else
sock->methods->cancel(sock, task, how);
}
isc_result_t
isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_getsockname(sock, addressp));
return (sock->methods->getsockname(sock, addressp));
}
void
isc_socket_ipv6only(isc_socket_t *sock, bool yes) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
isc__socket_ipv6only(sock, yes);
else
sock->methods->ipv6only(sock, yes);
}
void
isc_socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
sock->methods->dscp(sock, dscp);
}
isc_sockettype_t
isc_socket_gettype(isc_socket_t *sock) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_gettype(sock));
return (sock->methods->gettype(sock));
}
void
isc_socket_setname(isc_socket_t *sock, const char *name, void *tag) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
UNUSED(sock); /* in case REQUIRE() is empty */
UNUSED(name);
UNUSED(tag);
}
isc_result_t
isc_socket_fdwatchcreate(isc_socketmgr_t *manager, int fd, int flags,
isc_sockfdwatch_t callback, void *cbarg,
isc_task_t *task, isc_socket_t **socketp)
{
REQUIRE(ISCAPI_SOCKETMGR_VALID(manager));
if (isc_bind9)
return (isc__socket_fdwatchcreate(manager, fd, flags,
callback, cbarg,
task, socketp));
return (manager->methods->fdwatchcreate(manager, fd, flags,
callback, cbarg, task,
socketp));
}
isc_result_t
isc_socket_fdwatchpoke(isc_socket_t *sock, int flags)
{
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_fdwatchpoke(sock, flags));
return (sock->methods->fdwatchpoke(sock, flags));
}
isc_result_t
isc_socket_dup(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
if (isc_bind9)
return (isc__socket_dup(sock, socketp));
return (sock->methods->dup(sock, socketp));
}
int
isc_socket_getfd(isc_socket_t *sock) {
REQUIRE(ISCAPI_SOCKET_VALID(sock));
if (isc_bind9)
return (isc__socket_getfd(sock));
return (sock->methods->getfd(sock));
}
isc_result_t
isc_socket_open(isc_socket_t *sock) {
return (isc__socket_open(sock));
}
isc_result_t
isc_socket_close(isc_socket_t *sock) {
return (isc__socket_close(sock));
}
isc_result_t
isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks)
{
return (isc__socketmgr_create2(mctx, managerp, maxsocks));
}
isc_result_t
isc_socket_recvv(isc_socket_t *sock, isc_bufferlist_t *buflist,
unsigned int minimum, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
return (isc__socket_recvv(sock, buflist, minimum, task, action, arg));
}
isc_result_t
isc_socket_recv2(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_socketevent_t *event, unsigned int flags)
{
return (isc__socket_recv2(sock, region, minimum, task, event, flags));
}
isc_result_t
isc_socket_send(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
return (isc__socket_send(sock, region, task, action, arg));
}
isc_result_t
isc_socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
return (isc__socket_sendv(sock, buflist, task, action, arg));
}
isc_result_t
isc_socket_sendtov(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo)
{
return (isc__socket_sendtov(sock, buflist, task, action, arg,
address, pktinfo));
}
isc_result_t
isc_socket_sendtov2(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
unsigned int flags)
{
return (isc__socket_sendtov2(sock, buflist, task, action, arg,
address, pktinfo, flags));
}
isc_result_t
isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
isc_socketevent_t *event, unsigned int flags)
{
return (isc__socket_sendto2(sock, region, task, address, pktinfo,
event, flags));
}
void
isc_socket_cleanunix(const isc_sockaddr_t *sockaddr, bool active) {
isc__socket_cleanunix(sockaddr, active);
}
isc_result_t
isc_socket_permunix(const isc_sockaddr_t *sockaddr, uint32_t perm,
uint32_t owner, uint32_t group)
{
return (isc__socket_permunix(sockaddr, perm, owner, group));
}
isc_result_t
isc_socket_filter(isc_socket_t *sock, const char *filter) {
return (isc__socket_filter(sock, filter));
}
isc_result_t
isc_socket_listen(isc_socket_t *sock, unsigned int backlog) {
return (isc__socket_listen(sock, backlog));
}
isc_result_t
isc_socket_accept(isc_socket_t *sock, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
return (isc__socket_accept(sock, task, action, arg));
}
isc_result_t
isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
return (isc__socket_getpeername(sock, addressp));
}
+179 -698
View File
File diff suppressed because it is too large Load Diff
-8
View File
@@ -72,11 +72,7 @@ create_managers(unsigned int workers) {
char *p;
if (workers == 0) {
#ifdef ISC_PLATFORM_USETHREADS
workers = isc_os_ncpus();
#else
workers = 1;
#endif
}
p = getenv("ISC_TASK_WORKERS");
@@ -125,11 +121,7 @@ isc_test_begin(FILE *logfile, bool start_managers,
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
}
#ifdef ISC_PLATFORM_USETHREADS
ncpus = isc_os_ncpus();
#else
ncpus = 1;
#endif
if (start_managers) {
CHECK(create_managers(workers));
+3 -3
View File
@@ -273,7 +273,7 @@ ATF_TC_BODY(isc_mem_noflags, tc) {
isc_mem_debugging = 0;
ptr = isc_mem_get(mctx2, 2048);
ATF_CHECK(ptr != NULL);
isc__mem_printactive(mctx2, f);
isc_mem_printactive(mctx2, f);
isc_mem_put(mctx2, ptr, 2048);
isc_mem_destroy(&mctx2);
isc_stdio_close(f);
@@ -324,7 +324,7 @@ ATF_TC_BODY(isc_mem_recordflag, tc) {
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
ptr = isc_mem_get(mctx2, 2048);
ATF_CHECK(ptr != NULL);
isc__mem_printactive(mctx2, f);
isc_mem_printactive(mctx2, f);
isc_mem_put(mctx2, ptr, 2048);
isc_mem_destroy(&mctx2);
isc_stdio_close(f);
@@ -375,7 +375,7 @@ ATF_TC_BODY(isc_mem_traceflag, tc) {
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
ptr = isc_mem_get(mctx2, 2048);
ATF_CHECK(ptr != NULL);
isc__mem_printactive(mctx2, f);
isc_mem_printactive(mctx2, f);
isc_mem_put(mctx2, ptr, 2048);
isc_mem_destroy(&mctx2);
isc_stdio_close(f);
-17
View File
@@ -86,10 +86,6 @@ static isc_result_t
waitfor(completion_t *completion) {
int i = 0;
while (!completion->done && i++ < 5000) {
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#endif
isc_test_nap(1000);
}
if (completion->done)
@@ -112,19 +108,6 @@ waitfor(completion_t *completion) {
static void
waitbody(void) {
#ifndef ISC_PLATFORM_USETHREADS
struct timeval tv;
isc_socketwait_t *swait = NULL;
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
if (socketmgr != NULL) {
tv.tv_sec = 0;
tv.tv_usec = 1000 ;
if (isc__socketmgr_waitevents(socketmgr, &tv, &swait) > 0)
isc__socketmgr_dispatch(socketmgr, swait);
} else
#endif
isc_test_nap(1000);
}
-31
View File
@@ -40,9 +40,7 @@ int counter = 0;
static int active[10];
static bool done = false;
#ifdef ISC_PLATFORM_USETHREADS
static isc_condition_t cv;
#endif
static void
set(isc_task_t *task, isc_event_t *event) {
@@ -138,10 +136,6 @@ ATF_TC_BODY(all_events, tc) {
isc_task_send(task, &event);
while ((a == 0 || b == 0) && i++ < 5000) {
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#endif
isc_test_nap(1000);
}
@@ -175,13 +169,11 @@ ATF_TC_BODY(privileged_events, tc) {
result = isc_test_begin(NULL, true, 0);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
#ifdef ISC_PLATFORM_USETHREADS
/*
* Pause the task manager so we can fill up the work queue
* without things happening while we do it.
*/
isc__taskmgr_pause(taskmgr);
#endif
result = isc_task_create(taskmgr, 0, &task1);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
@@ -239,16 +231,10 @@ ATF_TC_BODY(privileged_events, tc) {
isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_privileged);
ATF_CHECK_EQ(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_privileged);
#ifdef ISC_PLATFORM_USETHREADS
isc__taskmgr_resume(taskmgr);
#endif
/* We're waiting for *all* variables to be set */
while ((a == 0 || b == 0 || c == 0 || d == 0 || e == 0) && i++ < 5000) {
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#endif
isc_test_nap(1000);
}
@@ -304,13 +290,11 @@ ATF_TC_BODY(privilege_drop, tc) {
result = isc_test_begin(NULL, true, 0);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
#ifdef ISC_PLATFORM_USETHREADS
/*
* Pause the task manager so we can fill up the work queue
* without things happening while we do it.
*/
isc__taskmgr_pause(taskmgr);
#endif
result = isc_task_create(taskmgr, 0, &task1);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
@@ -368,17 +352,11 @@ ATF_TC_BODY(privilege_drop, tc) {
isc_taskmgr_setmode(taskmgr, isc_taskmgrmode_privileged);
ATF_CHECK_EQ(isc_taskmgr_mode(taskmgr), isc_taskmgrmode_privileged);
#ifdef ISC_PLATFORM_USETHREADS
isc__taskmgr_resume(taskmgr);
#endif
/* We're waiting for all variables to be set. */
while ((a == -1 || b == -1 || c == -1 || d == -1 || e == -1) &&
i++ < 5000) {
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#endif
isc_test_nap(1000);
}
@@ -645,10 +623,6 @@ ATF_TC_BODY(task_exclusive, tc) {
isc_test_end();
}
/*
* The remainder of these tests require threads
*/
#ifdef ISC_PLATFORM_USETHREADS
/*
* Max tasks test:
* The task system can create and execute many tasks. Tests with 10000.
@@ -1446,7 +1420,6 @@ ATF_TC_HEAD(purgeevent_notpurge, tc) {
ATF_TC_BODY(purgeevent_notpurge, tc) {
try_purgeevent(false);
}
#endif
/*
* Main
@@ -1458,8 +1431,6 @@ ATF_TP_ADD_TCS(tp) {
ATF_TP_ADD_TC(tp, privilege_drop);
ATF_TP_ADD_TC(tp, basic);
ATF_TP_ADD_TC(tp, task_exclusive);
#ifdef ISC_PLATFORM_USETHREADS
ATF_TP_ADD_TC(tp, manytasks);
ATF_TP_ADD_TC(tp, shutdown);
ATF_TP_ADD_TC(tp, post_shutdown);
@@ -1467,8 +1438,6 @@ ATF_TP_ADD_TCS(tp) {
ATF_TP_ADD_TC(tp, purgerange);
ATF_TP_ADD_TC(tp, purgeevent);
ATF_TP_ADD_TC(tp, purgeevent_notpurge);
#endif
return (atf_no_error());
}
-20
View File
@@ -29,11 +29,6 @@
#include "isctest.h"
/*
* This entire test requires threads.
*/
#ifdef ISC_PLATFORM_USETHREADS
/*
* Helper functions
*/
@@ -564,30 +559,15 @@ ATF_TC_BODY(purge, tc) {
isc_test_end();
}
#else
ATF_TC(untested);
ATF_TC_HEAD(untested, tc) {
atf_tc_set_md_var(tc, "descr", "skipping nsec3 test");
}
ATF_TC_BODY(untested, tc) {
UNUSED(tc);
atf_tc_skip("DNSSEC not available");
}
#endif
/*
* Main
*/
ATF_TP_ADD_TCS(tp) {
#ifdef ISC_PLATFORM_USETHREADS
ATF_TP_ADD_TC(tp, ticker);
ATF_TP_ADD_TC(tp, once_life);
ATF_TP_ADD_TC(tp, once_idle);
ATF_TP_ADD_TC(tp, reset);
ATF_TP_ADD_TC(tp, purge);
#else
ATF_TP_ADD_TC(tp, untested);
#endif
return (atf_no_error());
}
+11 -313
View File
@@ -36,17 +36,6 @@
#include <openssl/err.h>
#endif
/* See task.c about the following definition: */
#ifdef ISC_PLATFORM_USETHREADS
#define USE_TIMER_THREAD
#else
#define USE_SHARED_MANAGER
#endif /* ISC_PLATFORM_USETHREADS */
#ifndef USE_TIMER_THREAD
#include "timer_p.h"
#endif /* USE_TIMER_THREAD */
#ifdef ISC_TIMER_TRACE
#define XTRACE(s) fprintf(stderr, "%s\n", (s))
#define XTRACEID(s, t) fprintf(stderr, "%s %p\n", (s), (t))
@@ -103,80 +92,13 @@ struct isc__timermgr {
LIST(isc__timer_t) timers;
unsigned int nscheduled;
isc_time_t due;
#ifdef USE_TIMER_THREAD
isc_condition_t wakeup;
isc_thread_t thread;
#endif /* USE_TIMER_THREAD */
#ifdef USE_SHARED_MANAGER
unsigned int refs;
#endif /* USE_SHARED_MANAGER */
isc_heap_t * heap;
};
/*%
* The following are intended for internal use (indicated by "isc__"
* prefix) but are not declared as static, allowing direct access from
* unit tests etc.
*/
isc_result_t
isc__timer_create(isc_timermgr_t *manager, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp);
isc_result_t
isc__timer_reset(isc_timer_t *timer, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
bool purge);
isc_timertype_t
isc_timer_gettype(isc_timer_t *timer);
isc_result_t
isc__timer_touch(isc_timer_t *timer);
void
isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp);
void
isc__timer_detach(isc_timer_t **timerp);
isc_result_t
isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
void
isc_timermgr_poke(isc_timermgr_t *manager0);
void
isc__timermgr_destroy(isc_timermgr_t **managerp);
static struct isc__timermethods {
isc_timermethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *gettype;
} timermethods = {
{
isc__timer_attach,
isc__timer_detach,
isc__timer_reset,
isc__timer_touch
},
(void *)isc_timer_gettype
};
static struct isc__timermgrmethods {
isc_timermgrmethods_t methods;
void *poke; /* see above */
} timermgrmethods = {
{
isc__timermgr_destroy,
isc__timer_create
},
(void *)isc_timermgr_poke
};
#ifdef USE_SHARED_MANAGER
/*!
* If the manager is supposed to be shared, there can be only one.
*/
static isc__timermgr_t *timermgr = NULL;
#endif /* USE_SHARED_MANAGER */
static inline isc_result_t
schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
@@ -184,9 +106,7 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
isc__timermgr_t *manager;
isc_time_t due;
int cmp;
#ifdef USE_TIMER_THREAD
bool timedwait;
#endif
/*!
* Note: the caller must ensure locking.
@@ -194,20 +114,16 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
REQUIRE(timer->type != isc_timertype_inactive);
#ifndef USE_TIMER_THREAD
UNUSED(signal_ok);
#endif /* USE_TIMER_THREAD */
manager = timer->manager;
#ifdef USE_TIMER_THREAD
/*!
* If the manager was timed wait, we may need to signal the
* manager to force a wakeup.
*/
timedwait = (manager->nscheduled > 0 &&
isc_time_seconds(&manager->due) != 0);
#endif
/*
* Compute the new due time.
@@ -270,7 +186,6 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
* the current "next" timer. We do this either by waking up the
* run thread, or explicitly setting the value in the manager.
*/
#ifdef USE_TIMER_THREAD
/*
* This is a temporary (probably) hack to fix a bug on tru64 5.1
@@ -303,20 +218,13 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) {
"signal (schedule)"));
SIGNAL(&manager->wakeup);
}
#else /* USE_TIMER_THREAD */
if (timer->index == 1 &&
isc_time_compare(&timer->due, &manager->due) < 0)
manager->due = timer->due;
#endif /* USE_TIMER_THREAD */
return (ISC_R_SUCCESS);
}
static inline void
deschedule(isc__timer_t *timer) {
#ifdef USE_TIMER_THREAD
bool need_wakeup = false;
#endif
isc__timermgr_t *manager;
/*
@@ -325,22 +233,18 @@ deschedule(isc__timer_t *timer) {
manager = timer->manager;
if (timer->index > 0) {
#ifdef USE_TIMER_THREAD
if (timer->index == 1)
need_wakeup = true;
#endif
isc_heap_delete(manager->heap, timer->index);
timer->index = 0;
INSIST(manager->nscheduled > 0);
manager->nscheduled--;
#ifdef USE_TIMER_THREAD
if (need_wakeup) {
XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER,
ISC_MSG_SIGNALDESCHED,
"signal (deschedule)"));
SIGNAL(&manager->wakeup);
}
#endif /* USE_TIMER_THREAD */
}
}
@@ -372,10 +276,10 @@ destroy(isc__timer_t *timer) {
}
isc_result_t
isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp)
isc_timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp)
{
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
isc__timer_t *timer;
@@ -461,7 +365,6 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
ISC_LINK_INIT(timer, link);
timer->common.impmagic = TIMER_MAGIC;
timer->common.magic = ISCAPI_TIMER_MAGIC;
timer->common.methods = (isc_timermethods_t *)&timermethods;
LOCK(&manager->lock);
@@ -494,7 +397,7 @@ isc__timer_create(isc_timermgr_t *manager0, isc_timertype_t type,
}
isc_result_t
isc__timer_reset(isc_timer_t *timer0, isc_timertype_t type,
isc_timer_reset(isc_timer_t *timer0, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
bool purge)
{
@@ -584,7 +487,7 @@ isc_timer_gettype(isc_timer_t *timer0) {
}
isc_result_t
isc__timer_touch(isc_timer_t *timer0) {
isc_timer_touch(isc_timer_t *timer0) {
isc__timer_t *timer = (isc__timer_t *)timer0;
isc_result_t result;
isc_time_t now;
@@ -615,7 +518,7 @@ isc__timer_touch(isc_timer_t *timer0) {
}
void
isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
isc_timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
isc__timer_t *timer = (isc__timer_t *)timer0;
/*
@@ -633,7 +536,7 @@ isc__timer_attach(isc_timer_t *timer0, isc_timer_t **timerp) {
}
void
isc__timer_detach(isc_timer_t **timerp) {
isc_timer_detach(isc_timer_t **timerp) {
isc__timer_t *timer;
bool free_timer = false;
@@ -777,7 +680,6 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) {
}
}
#ifdef USE_TIMER_THREAD
static isc_threadresult_t
#ifdef _WIN32 /* XXXDCL */
WINAPI
@@ -822,7 +724,6 @@ run(void *uap) {
return ((isc_threadresult_t)0);
}
#endif /* USE_TIMER_THREAD */
static bool
sooner(void *v1, void *v2) {
@@ -849,7 +750,7 @@ set_index(void *what, unsigned int index) {
}
isc_result_t
isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
isc__timermgr_t *manager;
isc_result_t result;
@@ -859,21 +760,12 @@ isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
REQUIRE(managerp != NULL && *managerp == NULL);
#ifdef USE_SHARED_MANAGER
if (timermgr != NULL) {
timermgr->refs++;
*managerp = (isc_timermgr_t *)timermgr;
return (ISC_R_SUCCESS);
}
#endif /* USE_SHARED_MANAGER */
manager = isc_mem_get(mctx, sizeof(*manager));
if (manager == NULL)
return (ISC_R_NOMEMORY);
manager->common.impmagic = TIMER_MANAGER_MAGIC;
manager->common.magic = ISCAPI_TIMERMGR_MAGIC;
manager->common.methods = (isc_timermgrmethods_t *)&timermgrmethods;
manager->mctx = NULL;
manager->done = false;
INIT_LIST(manager->timers);
@@ -893,7 +785,6 @@ isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
return (result);
}
isc_mem_attach(mctx, &manager->mctx);
#ifdef USE_TIMER_THREAD
if (isc_condition_init(&manager->wakeup) != ISC_R_SUCCESS) {
isc_mem_detach(&manager->mctx);
DESTROYLOCK(&manager->lock);
@@ -919,11 +810,6 @@ isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
return (ISC_R_UNEXPECTED);
}
isc_thread_setname(manager->thread, "isc-timer");
#endif
#ifdef USE_SHARED_MANAGER
manager->refs = 1;
timermgr = manager;
#endif /* USE_SHARED_MANAGER */
*managerp = (isc_timermgr_t *)manager;
@@ -932,19 +818,15 @@ isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
void
isc_timermgr_poke(isc_timermgr_t *manager0) {
#ifdef USE_TIMER_THREAD
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
REQUIRE(VALID_MANAGER(manager));
SIGNAL(&manager->wakeup);
#else
UNUSED(manager0);
#endif
}
void
isc__timermgr_destroy(isc_timermgr_t **managerp) {
isc_timermgr_destroy(isc_timermgr_t **managerp) {
isc__timermgr_t *manager;
isc_mem_t *mctx;
@@ -958,32 +840,15 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
LOCK(&manager->lock);
#ifdef USE_SHARED_MANAGER
manager->refs--;
if (manager->refs > 0) {
UNLOCK(&manager->lock);
*managerp = NULL;
return;
}
timermgr = NULL;
#endif /* USE_SHARED_MANAGER */
#ifndef USE_TIMER_THREAD
isc__timermgr_dispatch((isc_timermgr_t *)manager);
#endif
REQUIRE(EMPTY(manager->timers));
manager->done = true;
#ifdef USE_TIMER_THREAD
XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER,
ISC_MSG_SIGNALDESTROY, "signal (destroy)"));
SIGNAL(&manager->wakeup);
#endif /* USE_TIMER_THREAD */
UNLOCK(&manager->lock);
#ifdef USE_TIMER_THREAD
/*
* Wait for thread to exit.
*/
@@ -992,14 +857,11 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
"isc_thread_join() %s",
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_FAILED, "failed"));
#endif /* USE_TIMER_THREAD */
/*
* Clean up.
*/
#ifdef USE_TIMER_THREAD
(void)isc_condition_destroy(&manager->wakeup);
#endif /* USE_TIMER_THREAD */
DESTROYLOCK(&manager->lock);
isc_heap_destroy(&manager->heap);
manager->common.impmagic = 0;
@@ -1010,70 +872,6 @@ isc__timermgr_destroy(isc_timermgr_t **managerp) {
*managerp = NULL;
#ifdef USE_SHARED_MANAGER
timermgr = NULL;
#endif
}
#ifndef USE_TIMER_THREAD
isc_result_t
isc__timermgr_nextevent(isc_timermgr_t *manager0, isc_time_t *when) {
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
#ifdef USE_SHARED_MANAGER
if (manager == NULL)
manager = timermgr;
#endif
if (manager == NULL || manager->nscheduled == 0)
return (ISC_R_NOTFOUND);
*when = manager->due;
return (ISC_R_SUCCESS);
}
void
isc__timermgr_dispatch(isc_timermgr_t *manager0) {
isc__timermgr_t *manager = (isc__timermgr_t *)manager0;
isc_time_t now;
#ifdef USE_SHARED_MANAGER
if (manager == NULL)
manager = timermgr;
#endif
if (manager == NULL)
return;
TIME_NOW(&now);
dispatch(manager, &now);
}
#endif /* USE_TIMER_THREAD */
isc_result_t
isc__timer_register(void) {
return (isc_timer_register(isc__timermgr_create));
}
static isc_mutex_t createlock;
static isc_once_t once = ISC_ONCE_INIT;
static isc_timermgrcreatefunc_t timermgr_createfunc = NULL;
static void
initialize(void) {
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
}
isc_result_t
isc_timer_register(isc_timermgrcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
LOCK(&createlock);
if (timermgr_createfunc == NULL)
timermgr_createfunc = createfunc;
else
result = ISC_R_EXISTS;
UNLOCK(&createlock);
return (result);
}
isc_result_t
@@ -1082,110 +880,10 @@ isc_timermgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
{
isc_result_t result;
LOCK(&createlock);
REQUIRE(timermgr_createfunc != NULL);
result = (*timermgr_createfunc)(mctx, managerp);
UNLOCK(&createlock);
result = isc_timermgr_create(mctx, managerp);
if (result == ISC_R_SUCCESS)
isc_appctx_settimermgr(actx, *managerp);
return (result);
}
isc_result_t
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
isc_result_t result;
if (isc_bind9)
return (isc__timermgr_create(mctx, managerp));
LOCK(&createlock);
REQUIRE(timermgr_createfunc != NULL);
result = (*timermgr_createfunc)(mctx, managerp);
UNLOCK(&createlock);
return (result);
}
void
isc_timermgr_destroy(isc_timermgr_t **managerp) {
REQUIRE(*managerp != NULL && ISCAPI_TIMERMGR_VALID(*managerp));
if (isc_bind9)
isc__timermgr_destroy(managerp);
else
(*managerp)->methods->destroy(managerp);
ENSURE(*managerp == NULL);
}
isc_result_t
isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_timer_t **timerp)
{
REQUIRE(ISCAPI_TIMERMGR_VALID(manager));
if (isc_bind9)
return (isc__timer_create(manager, type, expires, interval,
task, action, arg, timerp));
return (manager->methods->timercreate(manager, type, expires,
interval, task, action, arg,
timerp));
}
void
isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp) {
REQUIRE(ISCAPI_TIMER_VALID(timer));
REQUIRE(timerp != NULL && *timerp == NULL);
if (isc_bind9)
isc__timer_attach(timer, timerp);
else
timer->methods->attach(timer, timerp);
ENSURE(*timerp == timer);
}
void
isc_timer_detach(isc_timer_t **timerp) {
REQUIRE(timerp != NULL && ISCAPI_TIMER_VALID(*timerp));
if (isc_bind9)
isc__timer_detach(timerp);
else
(*timerp)->methods->detach(timerp);
ENSURE(*timerp == NULL);
}
isc_result_t
isc_timer_reset(isc_timer_t *timer, isc_timertype_t type,
const isc_time_t *expires, const isc_interval_t *interval,
bool purge)
{
REQUIRE(ISCAPI_TIMER_VALID(timer));
if (isc_bind9)
return (isc__timer_reset(timer, type, expires,
interval, purge));
return (timer->methods->reset(timer, type, expires, interval, purge));
}
isc_result_t
isc_timer_touch(isc_timer_t *timer) {
REQUIRE(ISCAPI_TIMER_VALID(timer));
if (isc_bind9)
return (isc__timer_touch(timer));
return (timer->methods->touch(timer));
}
+35 -312
View File
@@ -41,9 +41,7 @@
#include <isc/time.h>
#include <isc/util.h>
#ifdef ISC_PLATFORM_USETHREADS
#include <pthread.h>
#endif
/*%
* For BIND9 internal applications built with threads, we use a single app
@@ -51,42 +49,8 @@
* For other cases (including BIND9 built without threads) an app context acts
* as an event loop dispatching various events.
*/
#ifndef ISC_PLATFORM_USETHREADS
#include "../timer_p.h"
#include "socket_p.h"
#endif /* ISC_PLATFORM_USETHREADS */
#ifdef ISC_PLATFORM_USETHREADS
static pthread_t blockedthread;
#endif /* ISC_PLATFORM_USETHREADS */
/*%
* The following are intended for internal use (indicated by "isc__"
* prefix) but are not declared as static, allowing direct access from
* unit tests etc.
*/
isc_result_t isc__app_start(void);
isc_result_t isc__app_ctxstart(isc_appctx_t *ctx);
isc_result_t isc__app_onrun(isc_mem_t *mctx, isc_task_t *task,
isc_taskaction_t action, void *arg);
isc_result_t isc__app_ctxrun(isc_appctx_t *ctx);
isc_result_t isc__app_run(void);
isc_result_t isc__app_ctxshutdown(isc_appctx_t *ctx);
isc_result_t isc__app_shutdown(void);
isc_result_t isc__app_reload(void);
isc_result_t isc__app_ctxsuspend(isc_appctx_t *ctx);
void isc__app_ctxfinish(isc_appctx_t *ctx);
void isc__app_finish(void);
void isc__app_block(void);
void isc__app_unblock(void);
isc_result_t isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp);
void isc__appctx_destroy(isc_appctx_t **ctxp);
void isc__appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr);
void isc__appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr);
void isc__appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr);
isc_result_t isc__app_ctxonrun(isc_appctx_t *ctx, isc_mem_t *mctx,
isc_task_t *task, isc_taskaction_t action,
void *arg);
static bool is_running;
/*
* The application context of this module. This implementation actually
@@ -117,43 +81,12 @@ typedef struct isc__appctx {
isc_taskmgr_t *taskmgr;
isc_socketmgr_t *socketmgr;
isc_timermgr_t *timermgr;
#ifdef ISC_PLATFORM_USETHREADS
isc_mutex_t readylock;
isc_condition_t ready;
#endif /* ISC_PLATFORM_USETHREADS */
} isc__appctx_t;
static isc__appctx_t isc_g_appctx;
static struct {
isc_appmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *run, *shutdown, *start, *reload, *finish, *block, *unblock;
} appmethods = {
{
isc__appctx_destroy,
isc__app_ctxstart,
isc__app_ctxrun,
isc__app_ctxsuspend,
isc__app_ctxshutdown,
isc__app_ctxfinish,
isc__appctx_settaskmgr,
isc__appctx_setsocketmgr,
isc__appctx_settimermgr,
isc__app_ctxonrun
},
(void *)isc__app_run,
(void *)isc__app_shutdown,
(void *)isc__app_start,
(void *)isc__app_reload,
(void *)isc__app_finish,
(void *)isc__app_block,
(void *)isc__app_unblock
};
#ifdef HAVE_LINUXTHREADS
/*!
* Linux has sigwait(), but it appears to prevent signal handlers from
@@ -205,7 +138,7 @@ handle_signal(int sig, void (*handler)(int)) {
}
isc_result_t
isc__app_ctxstart(isc_appctx_t *ctx0) {
isc_app_ctxstart(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
isc_result_t result;
int presult;
@@ -231,7 +164,6 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
}
#endif
#ifdef ISC_PLATFORM_USETHREADS
#ifdef HAVE_LINUXTHREADS
main_thread = pthread_self();
#endif /* HAVE_LINUXTHREADS */
@@ -244,14 +176,9 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
if (result != ISC_R_SUCCESS)
goto cleanup_rlock;
result = isc_mutex_init(&ctx->lock);
if (result != ISC_R_SUCCESS)
goto cleanup_rcond;
#else /* ISC_PLATFORM_USETHREADS */
result = isc_mutex_init(&ctx->lock);
if (result != ISC_R_SUCCESS)
goto cleanup;
#endif /* ISC_PLATFORM_USETHREADS */
ISC_LIST_INIT(ctx->on_run);
@@ -306,7 +233,6 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
goto cleanup;
#endif
#ifdef ISC_PLATFORM_USETHREADS
/*
* Block SIGHUP, SIGINT, SIGTERM.
*
@@ -335,68 +261,37 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
result = ISC_R_UNEXPECTED;
goto cleanup;
}
#else /* ISC_PLATFORM_USETHREADS */
/*
* Unblock SIGHUP, SIGINT, SIGTERM.
*
* If we're not using threads, we need to make sure that SIGHUP,
* SIGINT and SIGTERM are not inherited as blocked from the parent
* process.
*/
if (sigemptyset(&sset) != 0 ||
sigaddset(&sset, SIGHUP) != 0 ||
sigaddset(&sset, SIGINT) != 0 ||
sigaddset(&sset, SIGTERM) != 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_start() sigsetops: %s", strbuf);
result = ISC_R_UNEXPECTED;
goto cleanup;
}
presult = sigprocmask(SIG_UNBLOCK, &sset, NULL);
if (presult != 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_start() sigprocmask: %s", strbuf);
result = ISC_R_UNEXPECTED;
goto cleanup;
}
#endif /* ISC_PLATFORM_USETHREADS */
return (ISC_R_SUCCESS);
cleanup:
#ifdef ISC_PLATFORM_USETHREADS
cleanup_rcond:
(void)isc_condition_destroy(&ctx->ready);
cleanup_rlock:
(void)isc_mutex_destroy(&ctx->readylock);
#endif /* ISC_PLATFORM_USETHREADS */
return (result);
}
isc_result_t
isc__app_start(void) {
isc_app_start(void) {
isc_g_appctx.common.impmagic = APPCTX_MAGIC;
isc_g_appctx.common.magic = ISCAPI_APPCTX_MAGIC;
isc_g_appctx.common.methods = &appmethods.methods;
isc_g_appctx.mctx = NULL;
/* The remaining members will be initialized in ctxstart() */
return (isc__app_ctxstart((isc_appctx_t *)&isc_g_appctx));
return (isc_app_ctxstart((isc_appctx_t *)&isc_g_appctx));
}
isc_result_t
isc__app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
void *arg)
{
return (isc__app_ctxonrun((isc_appctx_t *)&isc_g_appctx, mctx,
return (isc_app_ctxonrun((isc_appctx_t *)&isc_g_appctx, mctx,
task, action, arg));
}
isc_result_t
isc__app_ctxonrun(isc_appctx_t *ctx0, isc_mem_t *mctx, isc_task_t *task,
isc_app_ctxonrun(isc_appctx_t *ctx0, isc_mem_t *mctx, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
@@ -434,159 +329,17 @@ isc__app_ctxonrun(isc_appctx_t *ctx0, isc_mem_t *mctx, isc_task_t *task,
return (result);
}
#ifndef ISC_PLATFORM_USETHREADS
/*!
* Event loop for nonthreaded programs.
*/
static isc_result_t
evloop(isc__appctx_t *ctx) {
isc_result_t result;
while (!ctx->want_shutdown) {
int n;
isc_time_t when, now;
struct timeval tv, *tvp;
isc_socketwait_t *swait;
bool readytasks;
bool call_timer_dispatch = false;
/*
* Check the reload (or suspend) case first for exiting the
* loop as fast as possible in case:
* - the direct call to isc__taskmgr_dispatch() in
* isc__app_ctxrun() completes all the tasks so far,
* - there is thus currently no active task, and
* - there is a timer event
*/
if (ctx->want_reload) {
ctx->want_reload = false;
return (ISC_R_RELOAD);
}
readytasks = isc__taskmgr_ready(ctx->taskmgr);
if (readytasks) {
tv.tv_sec = 0;
tv.tv_usec = 0;
tvp = &tv;
call_timer_dispatch = true;
} else {
result = isc__timermgr_nextevent(ctx->timermgr, &when);
if (result != ISC_R_SUCCESS)
tvp = NULL;
else {
uint64_t us;
TIME_NOW(&now);
us = isc_time_microdiff(&when, &now);
if (us == 0)
call_timer_dispatch = true;
tv.tv_sec = us / 1000000;
tv.tv_usec = us % 1000000;
tvp = &tv;
}
}
swait = NULL;
n = isc__socketmgr_waitevents(ctx->socketmgr, tvp, &swait);
if (n == 0 || call_timer_dispatch) {
/*
* We call isc__timermgr_dispatch() only when
* necessary, in order to reduce overhead. If the
* select() call indicates a timeout, we need the
* dispatch. Even if not, if we set the 0-timeout
* for the select() call, we need to check the timer
* events. In the 'readytasks' case, there may be no
* timeout event actually, but there is no other way
* to reduce the overhead.
* Note that we do not have to worry about the case
* where a new timer is inserted during the select()
* call, since this loop only runs in the non-thread
* mode.
*/
isc__timermgr_dispatch(ctx->timermgr);
}
if (n > 0)
(void)isc__socketmgr_dispatch(ctx->socketmgr, swait);
(void)isc__taskmgr_dispatch(ctx->taskmgr);
}
return (ISC_R_SUCCESS);
}
/*
* This is a gross hack to support waiting for condition
* variables in nonthreaded programs in a limited way;
* see lib/isc/nothreads/include/isc/condition.h.
* We implement isc_condition_wait() by entering the
* event loop recursively until the want_shutdown flag
* is set by isc_condition_signal().
*/
/*!
* \brief True if we are currently executing in the recursive
* event loop.
*/
static bool in_recursive_evloop = false;
/*!
* \brief True if we are exiting the event loop as the result of
* a call to isc_condition_signal() rather than a shutdown
* or reload.
*/
static bool signalled = false;
isc_result_t
isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp) {
isc_result_t result;
UNUSED(cp);
UNUSED(mp);
INSIST(!in_recursive_evloop);
in_recursive_evloop = true;
INSIST(*mp == 1); /* Mutex must be locked on entry. */
--*mp;
result = evloop(&isc_g_appctx);
if (result == ISC_R_RELOAD)
isc_g_appctx.want_reload = true;
if (signalled) {
isc_g_appctx.want_shutdown = false;
signalled = false;
}
++*mp;
in_recursive_evloop = false;
return (ISC_R_SUCCESS);
}
isc_result_t
isc__nothread_signal_hack(isc_condition_t *cp) {
UNUSED(cp);
INSIST(in_recursive_evloop);
isc_g_appctx.want_shutdown = true;
signalled = true;
return (ISC_R_SUCCESS);
}
#endif /* ISC_PLATFORM_USETHREADS */
isc_result_t
isc__app_ctxrun(isc_appctx_t *ctx0) {
isc_app_ctxrun(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
int result;
isc_event_t *event, *next_event;
isc_task_t *task;
#ifdef ISC_PLATFORM_USETHREADS
sigset_t sset;
char strbuf[ISC_STRERRORSIZE];
#ifdef HAVE_SIGWAIT
int sig;
#endif /* HAVE_SIGWAIT */
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(VALID_APPCTX(ctx));
@@ -616,17 +369,6 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
UNLOCK(&ctx->lock);
#ifndef ISC_PLATFORM_USETHREADS
if (isc_bind9 && ctx == &isc_g_appctx) {
result = handle_signal(SIGHUP, reload_action);
if (result != ISC_R_SUCCESS)
return (ISC_R_SUCCESS);
}
(void) isc__taskmgr_dispatch(ctx->taskmgr);
result = evloop(ctx);
return (result);
#else /* ISC_PLATFORM_USETHREADS */
/*
* BIND9 internal tools using multiple contexts do not
* rely on signal.
@@ -746,21 +488,27 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
}
return (ISC_R_SUCCESS);
#endif /* ISC_PLATFORM_USETHREADS */
}
isc_result_t
isc__app_run(void) {
return (isc__app_ctxrun((isc_appctx_t *)&isc_g_appctx));
isc_app_run(void) {
isc_result_t result;
is_running = true;
result = isc_app_ctxrun((isc_appctx_t *)&isc_g_appctx);
is_running = false;
return result;
}
bool
isc_app_isrunning() {
return (is_running);
}
isc_result_t
isc__app_ctxshutdown(isc_appctx_t *ctx0) {
isc_app_ctxshutdown(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
bool want_kill = true;
#ifdef ISC_PLATFORM_USETHREADS
char strbuf[ISC_STRERRORSIZE];
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(VALID_APPCTX(ctx));
@@ -780,9 +528,6 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
/* BIND9 internal, but using multiple contexts */
ctx->want_shutdown = true;
else {
#ifndef ISC_PLATFORM_USETHREADS
ctx->want_shutdown = true;
#else /* ISC_PLATFORM_USETHREADS */
#ifdef HAVE_LINUXTHREADS
if (isc_bind9) {
/* BIND9 internal, single context */
@@ -819,7 +564,6 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
UNLOCK(&ctx->readylock);
SIGNAL(&ctx->ready);
}
#endif /* ISC_PLATFORM_USETHREADS */
}
}
@@ -827,17 +571,15 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
}
isc_result_t
isc__app_shutdown(void) {
return (isc__app_ctxshutdown((isc_appctx_t *)&isc_g_appctx));
isc_app_shutdown(void) {
return (isc_app_ctxshutdown((isc_appctx_t *)&isc_g_appctx));
}
isc_result_t
isc__app_ctxsuspend(isc_appctx_t *ctx0) {
isc_app_ctxsuspend(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
bool want_kill = true;
#ifdef ISC_PLATFORM_USETHREADS
char strbuf[ISC_STRERRORSIZE];
#endif
REQUIRE(VALID_APPCTX(ctx));
@@ -858,9 +600,7 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
/* BIND9 internal, but using multiple contexts */
ctx->want_reload = true;
else {
#ifndef ISC_PLATFORM_USETHREADS
ctx->want_reload = true;
#else /* ISC_PLATFORM_USETHREADS */
#ifdef HAVE_LINUXTHREADS
if (isc_bind9) {
/* BIND9 internal, single context */
@@ -897,7 +637,6 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
UNLOCK(&ctx->readylock);
SIGNAL(&ctx->ready);
}
#endif /* ISC_PLATFORM_USETHREADS */
}
}
@@ -905,12 +644,12 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
}
isc_result_t
isc__app_reload(void) {
return (isc__app_ctxsuspend((isc_appctx_t *)&isc_g_appctx));
isc_app_reload(void) {
return (isc_app_ctxsuspend((isc_appctx_t *)&isc_g_appctx));
}
void
isc__app_ctxfinish(isc_appctx_t *ctx0) {
isc_app_ctxfinish(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
@@ -919,51 +658,43 @@ isc__app_ctxfinish(isc_appctx_t *ctx0) {
}
void
isc__app_finish(void) {
isc__app_ctxfinish((isc_appctx_t *)&isc_g_appctx);
isc_app_finish(void) {
isc_app_ctxfinish((isc_appctx_t *)&isc_g_appctx);
}
void
isc__app_block(void) {
#ifdef ISC_PLATFORM_USETHREADS
isc_app_block(void) {
sigset_t sset;
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(isc_g_appctx.running);
REQUIRE(!isc_g_appctx.blocked);
isc_g_appctx.blocked = true;
#ifdef ISC_PLATFORM_USETHREADS
blockedthread = pthread_self();
RUNTIME_CHECK(sigemptyset(&sset) == 0 &&
sigaddset(&sset, SIGINT) == 0 &&
sigaddset(&sset, SIGTERM) == 0);
RUNTIME_CHECK(pthread_sigmask(SIG_UNBLOCK, &sset, NULL) == 0);
#endif /* ISC_PLATFORM_USETHREADS */
}
void
isc__app_unblock(void) {
#ifdef ISC_PLATFORM_USETHREADS
isc_app_unblock(void) {
sigset_t sset;
#endif /* ISC_PLATFORM_USETHREADS */
REQUIRE(isc_g_appctx.running);
REQUIRE(isc_g_appctx.blocked);
isc_g_appctx.blocked = false;
#ifdef ISC_PLATFORM_USETHREADS
REQUIRE(blockedthread == pthread_self());
RUNTIME_CHECK(sigemptyset(&sset) == 0 &&
sigaddset(&sset, SIGINT) == 0 &&
sigaddset(&sset, SIGTERM) == 0);
RUNTIME_CHECK(pthread_sigmask(SIG_BLOCK, &sset, NULL) == 0);
#endif /* ISC_PLATFORM_USETHREADS */
}
isc_result_t
isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc__appctx_t *ctx;
REQUIRE(mctx != NULL);
@@ -975,7 +706,6 @@ isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
ctx->common.impmagic = APPCTX_MAGIC;
ctx->common.magic = ISCAPI_APPCTX_MAGIC;
ctx->common.methods = &appmethods.methods;
ctx->mctx = NULL;
isc_mem_attach(mctx, &ctx->mctx);
@@ -990,7 +720,7 @@ isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
}
void
isc__appctx_destroy(isc_appctx_t **ctxp) {
isc_appctx_destroy(isc_appctx_t **ctxp) {
isc__appctx_t *ctx;
REQUIRE(ctxp != NULL);
@@ -1003,7 +733,7 @@ isc__appctx_destroy(isc_appctx_t **ctxp) {
}
void
isc__appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
isc_appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
@@ -1012,7 +742,7 @@ isc__appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
}
void
isc__appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
isc_appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
@@ -1021,17 +751,10 @@ isc__appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
}
void
isc__appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
isc_appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
ctx->timermgr = timermgr;
}
isc_result_t
isc__app_register(void) {
return (isc_app_register(isc__appctx_create));
}
#include "../app_api.c"
+371 -944
View File
File diff suppressed because it is too large Load Diff
-42
View File
@@ -381,9 +381,7 @@ void
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
#ifdef ISC_PLATFORM_USETHREADS
struct tm tm;
#endif
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -391,11 +389,7 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
REQUIRE(len > 0);
now = (time_t) t->seconds;
#ifdef ISC_PLATFORM_USETHREADS
flen = strftime(buf, len, "%d-%b-%Y %X", localtime_r(&now, &tm));
#else
flen = strftime(buf, len, "%d-%b-%Y %X", localtime(&now));
#endif
INSIST(flen < len);
if (flen != 0)
snprintf(buf + flen, len - flen,
@@ -409,9 +403,7 @@ void
isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
#ifdef ISC_PLATFORM_USETHREADS
struct tm tm;
#endif
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -422,12 +414,8 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) {
* 5 spaces, 1 comma, 3 GMT, 2 %d, 4 %Y, 8 %H:%M:%S, 3+ %a, 3+ %b (29+)
*/
now = (time_t)t->seconds;
#ifdef ISC_PLATFORM_USETHREADS
flen = strftime(buf, len, "%a, %d %b %Y %H:%M:%S GMT",
gmtime_r(&now, &tm));
#else
flen = strftime(buf, len, "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now));
#endif
INSIST(flen < len);
}
@@ -454,9 +442,7 @@ void
isc_time_formatISO8601L(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
#ifdef ISC_PLATFORM_USETHREADS
struct tm tm;
#endif
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -464,11 +450,7 @@ isc_time_formatISO8601L(const isc_time_t *t, char *buf, unsigned int len) {
REQUIRE(len > 0);
now = (time_t)t->seconds;
#ifdef ISC_PLATFORM_USETHREADS
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%S", localtime_r(&now, &tm));
#else
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%S", localtime(&now));
#endif
INSIST(flen < len);
}
@@ -476,9 +458,7 @@ void
isc_time_formatISO8601Lms(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
#ifdef ISC_PLATFORM_USETHREADS
struct tm tm;
#endif
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -486,11 +466,7 @@ isc_time_formatISO8601Lms(const isc_time_t *t, char *buf, unsigned int len) {
REQUIRE(len > 0);
now = (time_t)t->seconds;
#ifdef ISC_PLATFORM_USETHREADS
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%S", localtime_r(&now, &tm));
#else
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%S", localtime(&now));
#endif
INSIST(flen < len);
if (flen > 0U && len - flen >= 6) {
snprintf(buf + flen, len - flen, ".%03u",
@@ -502,9 +478,7 @@ void
isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
#ifdef ISC_PLATFORM_USETHREADS
struct tm tm;
#endif
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -512,11 +486,7 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
REQUIRE(len > 0);
now = (time_t)t->seconds;
#ifdef ISC_PLATFORM_USETHREADS
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%SZ", gmtime_r(&now, &tm));
#else
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%SZ", gmtime(&now));
#endif
INSIST(flen < len);
}
@@ -524,9 +494,7 @@ void
isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
#ifdef ISC_PLATFORM_USETHREADS
struct tm tm;
#endif
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -534,11 +502,7 @@ isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) {
REQUIRE(len > 0);
now = (time_t)t->seconds;
#ifdef ISC_PLATFORM_USETHREADS
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%SZ", gmtime_r(&now, &tm));
#else
flen = strftime(buf, len, "%Y-%m-%dT%H:%M:%SZ", gmtime(&now));
#endif
INSIST(flen < len);
if (flen > 0U && len - flen >= 5) {
flen -= 1; /* rewind one character (Z) */
@@ -552,9 +516,7 @@ isc_time_formatshorttimestamp(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
unsigned int flen;
#ifdef ISC_PLATFORM_USETHREADS
struct tm tm;
#endif
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -562,11 +524,7 @@ isc_time_formatshorttimestamp(const isc_time_t *t, char *buf, unsigned int len)
REQUIRE(len > 0);
now = (time_t)t->seconds;
#ifdef ISC_PLATFORM_USETHREADS
flen = strftime(buf, len, "%Y%m%d%H%M%S", gmtime_r(&now, &tm));
#else
flen = strftime(buf, len, "%Y%m%d%H%M%S", gmtime(&now));
#endif
INSIST(flen < len);
if (flen > 0U && len - flen >= 5) {
snprintf(buf + flen, len - flen, "%03u",
+36 -87
View File
@@ -40,39 +40,8 @@
*/
static isc_thread_t blockedthread;
static bool is_running;
/*%
* The following are intended for internal use (indicated by "isc__"
* prefix) but are not declared as static, allowing direct access from
* unit tests etc.
*/
isc_result_t isc__app_start(void);
isc_result_t isc__app_ctxstart(isc_appctx_t *ctx);
isc_result_t isc__app_onrun(isc_mem_t *mctx, isc_task_t *task,
isc_taskaction_t action, void *arg);
isc_result_t isc__app_ctxrun(isc_appctx_t *ctx);
isc_result_t isc__app_run(void);
isc_result_t isc__app_ctxshutdown(isc_appctx_t *ctx);
isc_result_t isc__app_shutdown(void);
isc_result_t isc__app_reload(void);
isc_result_t isc__app_ctxsuspend(isc_appctx_t *ctx);
void isc__app_ctxfinish(isc_appctx_t *ctx);
void isc__app_finish(void);
void isc__app_block(void);
void isc__app_unblock(void);
isc_result_t isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp);
void isc__appctx_destroy(isc_appctx_t **ctxp);
void isc__appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr);
void isc__appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr);
void isc__appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr);
isc_result_t isc__app_ctxonrun(isc_appctx_t *ctx, isc_mem_t *mctx,
isc_task_t *task, isc_taskaction_t action,
void *arg);
/*
* The application context of this module. This implementation actually
* doesn't use it. (This may change in the future).
*/
#define APPCTX_MAGIC ISC_MAGIC('A', 'p', 'c', 'x')
#define VALID_APPCTX(c) ISC_MAGIC_VALID(c, APPCTX_MAGIC)
@@ -112,42 +81,13 @@ typedef struct isc__appctx {
static isc__appctx_t isc_g_appctx;
static struct {
isc_appmethods_t methods;
/*%
* The following are defined just for avoiding unused static functions.
*/
void *run, *shutdown, *start, *reload, *finish, *block, *unblock;
} appmethods = {
{
isc__appctx_destroy,
isc__app_ctxstart,
isc__app_ctxrun,
isc__app_ctxsuspend,
isc__app_ctxshutdown,
isc__app_ctxfinish,
isc__appctx_settaskmgr,
isc__appctx_setsocketmgr,
isc__appctx_settimermgr,
isc__app_ctxonrun
},
(void *)isc__app_run,
(void *)isc__app_shutdown,
(void *)isc__app_start,
(void *)isc__app_reload,
(void *)isc__app_finish,
(void *)isc__app_block,
(void *)isc__app_unblock
};
/*
* We need to remember which thread is the main thread...
*/
static isc_thread_t main_thread;
isc_result_t
isc__app_ctxstart(isc_appctx_t *ctx0) {
isc_app_ctxstart(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
isc_result_t result;
@@ -180,26 +120,26 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
}
isc_result_t
isc__app_start(void) {
isc_app_start(void) {
isc_g_appctx.common.impmagic = APPCTX_MAGIC;
isc_g_appctx.common.magic = ISCAPI_APPCTX_MAGIC;
isc_g_appctx.common.methods = &appmethods.methods;
isc_g_appctx.mctx = NULL;
/* The remaining members will be initialized in ctxstart() */
return (isc__app_ctxstart((isc_appctx_t *)&isc_g_appctx));
return (isc_app_ctxstart((isc_appctx_t *)&isc_g_appctx));
}
isc_result_t
isc__app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
void *arg)
{
return (isc__app_ctxonrun((isc_appctx_t *)&isc_g_appctx, mctx,
return (isc_app_ctxonrun((isc_appctx_t *)&isc_g_appctx, mctx,
task, action, arg));
}
isc_result_t
isc__app_ctxonrun(isc_appctx_t *ctx0, isc_mem_t *mctx, isc_task_t *task,
isc_app_ctxonrun(isc_appctx_t *ctx0, isc_mem_t *mctx, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
@@ -238,7 +178,7 @@ isc__app_ctxonrun(isc_appctx_t *ctx0, isc_mem_t *mctx, isc_task_t *task,
}
isc_result_t
isc__app_ctxrun(isc_appctx_t *ctx0) {
isc_app_ctxrun(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
isc_event_t *event, *next_event;
isc_task_t *task;
@@ -311,12 +251,21 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
}
isc_result_t
isc__app_run(void) {
return (isc__app_ctxrun((isc_appctx_t *)&isc_g_appctx));
isc_app_run(void) {
isc_result_t result;
is_running = ISC_TRUE;
result = isc_app_ctxrun((isc_appctx_t *)&isc_g_appctx);
is_running = ISC_FALSE;
return result;
}
bool
isc_app_isrunning() {
return (is_running);
}
isc_result_t
isc__app_ctxshutdown(isc_appctx_t *ctx0) {
isc_app_ctxshutdown(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
bool want_kill = true;
@@ -340,12 +289,12 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
}
isc_result_t
isc__app_shutdown(void) {
return (isc__app_ctxshutdown((isc_appctx_t *)&isc_g_appctx));
isc_app_shutdown(void) {
return (isc_app_ctxshutdown((isc_appctx_t *)&isc_g_appctx));
}
isc_result_t
isc__app_ctxsuspend(isc_appctx_t *ctx0) {
isc_app_ctxsuspend(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
bool want_kill = true;
@@ -370,12 +319,12 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
}
isc_result_t
isc__app_reload(void) {
return (isc__app_ctxsuspend((isc_appctx_t *)&isc_g_appctx));
isc_app_reload(void) {
return (isc_app_ctxsuspend((isc_appctx_t *)&isc_g_appctx));
}
void
isc__app_ctxfinish(isc_appctx_t *ctx0) {
isc_app_ctxfinish(isc_appctx_t *ctx0) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
@@ -384,12 +333,12 @@ isc__app_ctxfinish(isc_appctx_t *ctx0) {
}
void
isc__app_finish(void) {
isc__app_ctxfinish((isc_appctx_t *)&isc_g_appctx);
isc_app_finish(void) {
isc_app_ctxfinish((isc_appctx_t *)&isc_g_appctx);
}
void
isc__app_block(void) {
isc_app_block(void) {
REQUIRE(isc_g_appctx.running);
REQUIRE(!isc_g_appctx.blocked);
@@ -398,7 +347,7 @@ isc__app_block(void) {
}
void
isc__app_unblock(void) {
isc_app_unblock(void) {
REQUIRE(isc_g_appctx.running);
REQUIRE(isc_g_appctx.blocked);
@@ -407,7 +356,7 @@ isc__app_unblock(void) {
}
isc_result_t
isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc__appctx_t *ctx;
REQUIRE(mctx != NULL);
@@ -434,7 +383,7 @@ isc__appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
}
void
isc__appctx_destroy(isc_appctx_t **ctxp) {
isc_appctx_destroy(isc_appctx_t **ctxp) {
isc__appctx_t *ctx;
REQUIRE(ctxp != NULL);
@@ -447,7 +396,7 @@ isc__appctx_destroy(isc_appctx_t **ctxp) {
}
void
isc__appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
isc_appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
@@ -456,7 +405,7 @@ isc__appctx_settaskmgr(isc_appctx_t *ctx0, isc_taskmgr_t *taskmgr) {
}
void
isc__appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
isc_appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
@@ -465,7 +414,7 @@ isc__appctx_setsocketmgr(isc_appctx_t *ctx0, isc_socketmgr_t *socketmgr) {
}
void
isc__appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
isc_appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
isc__appctx_t *ctx = (isc__appctx_t *)ctx0;
REQUIRE(VALID_APPCTX(ctx));
@@ -474,7 +423,7 @@ isc__appctx_settimermgr(isc_appctx_t *ctx0, isc_timermgr_t *timermgr) {
}
isc_result_t
isc__app_register(void) {
isc_app_register(void) {
return (isc_app_register(isc__appctx_create));
}
-2
View File
@@ -16,8 +16,6 @@
***** Platform-dependent defines.
*****/
#define ISC_PLATFORM_USETHREADS 1
/*
* Some compatibility cludges
*/
+73 -73
View File
@@ -9,25 +9,25 @@ closelog
getpassphrase
@END PKCS11
isc___socketmgr_maxudp
isc__app_block
isc__app_ctxfinish
isc__app_ctxonrun
isc__app_ctxrun
isc__app_ctxshutdown
isc__app_ctxstart
isc__app_ctxsuspend
isc__app_finish
isc__app_onrun
isc__app_reload
isc__app_run
isc__app_shutdown
isc__app_start
isc__app_unblock
isc__appctx_create
isc__appctx_destroy
isc__appctx_setsocketmgr
isc__appctx_settaskmgr
isc__appctx_settimermgr
isc_app_block
isc_app_ctxfinish
isc_app_ctxonrun
isc_app_ctxrun
isc_app_ctxshutdown
isc_app_ctxstart
isc_app_ctxsuspend
isc_app_finish
isc_app_onrun
isc_app_reload
isc_app_run
isc_app_shutdown
isc_app_start
isc_app_unblock
isc_appctx_create
isc_appctx_destroy
isc_appctx_setsocketmgr
isc_appctx_settaskmgr
isc_appctx_settimermgr
isc__buffer_activeregion
isc__buffer_add
isc__buffer_availableregion
@@ -51,61 +51,61 @@ isc__buffer_remainingregion
isc__buffer_setactive
isc__buffer_subtract
isc__buffer_usedregion
isc__mem_allocate
isc__mem_free
isc__mem_get
isc__mem_printactive
isc__mem_put
isc__mem_putanddetach
isc__mem_reallocate
isc__mem_strdup
isc__mempool_get
isc__mempool_put
isc__socket_accept
isc__socket_attach
isc__socket_bind
isc__socket_cancel
isc__socket_cleanunix
isc__socket_close
isc__socket_connect
isc__socket_create
isc__socket_detach
isc__socket_dscp
isc__socket_dup
isc__socket_filter
isc__socket_getfd
isc__socket_getname
isc__socket_getpeername
isc__socket_getsockname
isc__socket_gettag
isc__socket_gettype
isc__socket_ipv6only
isc__socket_isbound
isc__socket_listen
isc__socket_open
isc__socket_permunix
isc__socket_recv
isc__socket_recv2
isc__socket_recvv
isc__socket_register
isc__socket_send
isc__socket_sendto
isc__socket_sendto2
isc__socket_sendtov
isc__socket_sendtov2
isc__socket_sendv
isc__socket_setname
isc__socketmgr_create
isc__socketmgr_create2
isc__socketmgr_destroy
isc__socketmgr_getmaxsockets
isc__socketmgr_setreserved
isc__socketmgr_setstats
isc_mem_allocate
isc_mem_free
isc_mem_get
isc_mem_printactive
isc_mem_put
isc_mem_putanddetach
isc_mem_reallocate
isc_mem_strdup
isc_mempool_get
isc_mempool_put
isc_socket_accept
isc_socket_attach
isc_socket_bind
isc_socket_cancel
isc_socket_cleanunix
isc_socket_close
isc_socket_connect
isc_socket_create
isc_socket_detach
isc_socket_dscp
isc_socket_dup
isc_socket_filter
isc_socket_getfd
isc_socket_getname
isc_socket_getpeername
isc_socket_getsockname
isc_socket_gettag
isc_socket_gettype
isc_socket_ipv6only
isc_socket_isbound
isc_socket_listen
isc_socket_open
isc_socket_permunix
isc_socket_recv
isc_socket_recv2
isc_socket_recvv
isc_socket_register
isc_socket_send
isc_socket_sendto
isc_socket_sendto2
isc_socket_sendtov
isc_socket_sendtov2
isc_socket_sendv
isc_socket_setname
isc_socketmgr_create
isc_socketmgr_create2
isc_socketmgr_destroy
isc_socketmgr_getmaxsockets
isc_socketmgr_setreserved
isc_socketmgr_setstats
isc__strerror
isc__task_getname
isc__task_gettag
isc__task_unsendrange
isc__taskmgr_mode
isc_task_getname
isc_task_gettag
isc_task_unsendrange
isc_taskmgr_mode
isc__taskmgr_pause
isc__taskmgr_resume
isc_aes128_crypt
+47 -92
View File
@@ -1811,19 +1811,19 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
if (dup_socket) {
#ifndef ISC_ALLOW_MAPPED
isc__socket_ipv6only(sock, true);
isc_socket_ipv6only(sock, true);
#endif
if (dup_socket->bound) {
isc_sockaddr_t local;
result = isc__socket_getsockname(dup_socket, &local);
result = isc_socket_getsockname(dup_socket, &local);
if (result != ISC_R_SUCCESS) {
isc_socket_close(sock);
return (result);
}
result = isc__socket_bind(sock, &local,
ISC_SOCKET_REUSEADDRESS);
result = isc_socket_bind(sock, &local,
ISC_SOCKET_REUSEADDRESS);
if (result != ISC_R_SUCCESS) {
isc_socket_close(sock);
return (result);
@@ -1849,14 +1849,14 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
}
isc_result_t
isc__socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
isc_socket_t **socketp)
{
return (socket_create(manager, pf, type, socketp, NULL));
}
isc_result_t
isc__socket_dup(isc_socket_t *sock, isc_socket_t **socketp) {
isc_socket_dup(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
@@ -1876,7 +1876,7 @@ isc_socket_open(isc_socket_t *sock) {
* Attach to a socket. Caller must explicitly detach when it is done.
*/
void
isc__socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
isc_socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
REQUIRE(VALID_SOCKET(sock));
REQUIRE(socketp != NULL && *socketp == NULL);
@@ -1893,7 +1893,7 @@ isc__socket_attach(isc_socket_t *sock, isc_socket_t **socketp) {
* up by destroying the socket.
*/
void
isc__socket_detach(isc_socket_t **socketp) {
isc_socket_detach(isc_socket_t **socketp) {
isc_socket_t *sock;
REQUIRE(socketp != NULL);
@@ -2651,12 +2651,12 @@ SocketIoThread(LPVOID ThreadContext) {
* Create a new socket manager.
*/
isc_result_t
isc__socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
return (isc_socketmgr_create2(mctx, managerp, 0));
}
isc_result_t
isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks)
{
isc_socketmgr_t *manager;
@@ -2724,7 +2724,7 @@ isc_socketmgr_setstats(isc_socketmgr_t *manager, isc_stats_t *stats) {
}
void
isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
isc_socketmgr_t *manager;
int i;
isc_mem_t *mctx;
@@ -2849,7 +2849,7 @@ socket_recv(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
}
isc_result_t
isc__socket_recvv(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc;_socket_recvv(isc_socket_t *sock, isc_bufferlist_t *buflist,
unsigned int minimum, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
@@ -2920,7 +2920,7 @@ isc__socket_recvv(isc_socket_t *sock, isc_bufferlist_t *buflist,
}
isc_result_t
isc__socket_recv(isc_socket_t *sock, isc_region_t *region,
isc_socket_recv(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_taskaction_t action, void *arg)
{
@@ -2959,7 +2959,7 @@ isc__socket_recv(isc_socket_t *sock, isc_region_t *region,
}
isc_result_t
isc__socket_recv2(isc_socket_t *sock, isc_region_t *region,
isc_socket_recv2(isc_socket_t *sock, isc_region_t *region,
unsigned int minimum, isc_task_t *task,
isc_socketevent_t *event, unsigned int flags)
{
@@ -3070,7 +3070,7 @@ socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task,
}
isc_result_t
isc__socket_send(isc_socket_t *sock, isc_region_t *region,
isc_socket_send(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
/*
@@ -3081,7 +3081,7 @@ isc__socket_send(isc_socket_t *sock, isc_region_t *region,
}
isc_result_t
isc__socket_sendto(isc_socket_t *sock, isc_region_t *region,
isc_socket_sendto(isc_socket_t *sock, isc_region_t *region,
isc_task_t *task, isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo)
{
@@ -3125,7 +3125,7 @@ isc__socket_sendto(isc_socket_t *sock, isc_region_t *region,
}
isc_result_t
isc__socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
return (isc_socket_sendtov2(sock, buflist, task, action, arg, NULL,
@@ -3133,8 +3133,8 @@ isc__socket_sendv(isc_socket_t *sock, isc_bufferlist_t *buflist,
}
isc_result_t
isc__socket_sendtov(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_socket_sendtov(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo)
{
return (isc_socket_sendtov2(sock, buflist, task, action, arg, address,
@@ -3142,10 +3142,10 @@ isc__socket_sendtov(isc_socket_t *sock, isc_bufferlist_t *buflist,
}
isc_result_t
isc__socket_sendtov2(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg,
isc_socket_sendtov2(isc_socket_t *sock, isc_bufferlist_t *buflist,
isc_task_t *task, isc_taskaction_t action, void *arg,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
unsigned int flags)
unsigned int flags)
{
isc_socketevent_t *dev;
isc_socketmgr_t *manager;
@@ -3199,9 +3199,9 @@ isc__socket_sendtov2(isc_socket_t *sock, isc_bufferlist_t *buflist,
}
isc_result_t
isc__socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
isc_socketevent_t *event, unsigned int flags)
isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
const isc_sockaddr_t *address, struct in6_pktinfo *pktinfo,
isc_socketevent_t *event, unsigned int flags)
{
isc_result_t ret;
@@ -3233,8 +3233,8 @@ isc__socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_task_t *task,
}
isc_result_t
isc__socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
isc_socket_options_t options)
isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
isc_socket_options_t options)
{
int bind_errno;
char strbuf[ISC_STRERRORSIZE];
@@ -3301,7 +3301,7 @@ isc__socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr,
}
isc_result_t
isc__socket_filter(isc_socket_t *sock, const char *filter) {
isc_socket_filter(isc_socket_t *sock, const char *filter) {
UNUSED(sock);
UNUSED(filter);
@@ -3320,7 +3320,7 @@ isc__socket_filter(isc_socket_t *sock, const char *filter) {
* as well keep things simple rather than having to track them.
*/
isc_result_t
isc__socket_listen(isc_socket_t *sock, unsigned int backlog) {
isc_socket_listen(isc_socket_t *sock, unsigned int backlog) {
char strbuf[ISC_STRERRORSIZE];
#if defined(ISC_PLATFORM_HAVETFO) && defined(TCP_FASTOPEN)
char on = 1;
@@ -3379,8 +3379,8 @@ isc__socket_listen(isc_socket_t *sock, unsigned int backlog) {
* This should try to do aggressive accept() XXXMLG
*/
isc_result_t
isc__socket_accept(isc_socket_t *sock,
isc_task_t *task, isc_taskaction_t action, void *arg)
isc_socket_accept(isc_socket_t *sock,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
isc_socket_newconnev_t *adev;
isc_socketmgr_t *manager;
@@ -3497,8 +3497,8 @@ isc__socket_accept(isc_socket_t *sock,
}
isc_result_t
isc__socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action, void *arg)
isc_socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
isc_task_t *task, isc_taskaction_t action, void *arg)
{
char strbuf[ISC_STRERRORSIZE];
isc_socket_connev_t *cdev;
@@ -3628,7 +3628,7 @@ isc__socket_connect(isc_socket_t *sock, const isc_sockaddr_t *addr,
}
isc_result_t
isc__socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
isc_socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
isc_result_t result;
REQUIRE(VALID_SOCKET(sock));
@@ -3658,7 +3658,7 @@ isc__socket_getpeername(isc_socket_t *sock, isc_sockaddr_t *addressp) {
}
isc_result_t
isc__socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
ISC_SOCKADDR_LEN_T len;
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
@@ -3705,7 +3705,7 @@ isc__socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) {
* queued for task "task" of type "how". "how" is a bitmask.
*/
void
isc__socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
REQUIRE(VALID_SOCKET(sock));
@@ -3831,7 +3831,7 @@ isc__socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) {
}
isc_sockettype_t
isc__socket_gettype(isc_socket_t *sock) {
isc_socket_gettype(isc_socket_t *sock) {
isc_sockettype_t type;
REQUIRE(VALID_SOCKET(sock));
@@ -3851,31 +3851,8 @@ isc__socket_gettype(isc_socket_t *sock) {
return (type);
}
bool
isc__socket_isbound(isc_socket_t *sock) {
bool val;
REQUIRE(VALID_SOCKET(sock));
LOCK(&sock->lock);
CONSISTENT(sock);
/*
* make sure that the socket's not closed
*/
if (sock->fd == INVALID_SOCKET) {
UNLOCK(&sock->lock);
return (false);
}
val = ((sock->bound) ? true : false);
UNLOCK(&sock->lock);
return (val);
}
void
isc__socket_ipv6only(isc_socket_t *sock, bool yes) {
isc_socket_ipv6only(isc_socket_t *sock, bool yes) {
#if defined(IPV6_V6ONLY)
int onoff = yes ? 1 : 0;
#else
@@ -3893,7 +3870,7 @@ isc__socket_ipv6only(isc_socket_t *sock, bool yes) {
}
void
isc__socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) {
isc_socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) {
#if !defined(IP_TOS) && !defined(IPV6_TCLASS)
UNUSED(dscp);
#else
@@ -3921,14 +3898,14 @@ isc__socket_dscp(isc_socket_t *sock, isc_dscp_t dscp) {
}
void
isc__socket_cleanunix(const isc_sockaddr_t *addr, bool active) {
isc_socket_cleanunix(const isc_sockaddr_t *addr, bool active) {
UNUSED(addr);
UNUSED(active);
}
isc_result_t
isc__socket_permunix(const isc_sockaddr_t *addr, uint32_t perm,
uint32_t owner, uint32_t group)
isc_socket_permunix(const isc_sockaddr_t *addr, uint32_t perm,
uint32_t owner, uint32_t group)
{
UNUSED(addr);
UNUSED(perm);
@@ -3938,7 +3915,7 @@ isc__socket_permunix(const isc_sockaddr_t *addr, uint32_t perm,
}
void
isc__socket_setname(isc_socket_t *socket, const char *name, void *tag) {
isc_socket_setname(isc_socket_t *socket, const char *name, void *tag) {
/*
* Name 'socket'.
@@ -3953,33 +3930,26 @@ isc__socket_setname(isc_socket_t *socket, const char *name, void *tag) {
}
const char *
isc__socket_getname(isc_socket_t *socket) {
isc_socket_getname(isc_socket_t *socket) {
return (socket->name);
}
void *
isc__socket_gettag(isc_socket_t *socket) {
isc_socket_gettag(isc_socket_t *socket) {
return (socket->tag);
}
int
isc__socket_getfd(isc_socket_t *socket) {
isc_socket_getfd(isc_socket_t *socket) {
return ((short) socket->fd);
}
void
isc__socketmgr_setreserved(isc_socketmgr_t *manager, uint32_t reserved) {
isc_socketmgr_setreserved(isc_socketmgr_t *manager, uint32_t reserved) {
UNUSED(manager);
UNUSED(reserved);
}
void
isc___socketmgr_maxudp(isc_socketmgr_t *manager, int maxudp) {
UNUSED(manager);
UNUSED(maxudp);
}
isc_socketevent_t *
isc_socket_socketevent(isc_mem_t *mctx, void *sender,
isc_eventtype_t eventtype, isc_taskaction_t action,
@@ -4016,12 +3986,6 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr, xmlTextWriterPtr writer)
LOCK(&mgr->lock);
#ifndef ISC_PLATFORM_USETHREADS
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "references"));
TRY0(xmlTextWriterWriteFormatString(writer, "%d", mgr->refs));
TRY0(xmlTextWriterEndElement(writer));
#endif
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "sockets"));
sock = ISC_LIST_HEAD(mgr->socklist);
while (sock != NULL) {
@@ -4253,15 +4217,6 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr, json_object *stats) {
}
#endif /* HAVE_JSON */
/*
* Replace ../socket_api.c
*/
isc_result_t
isc__socket_register(void) {
return (ISC_R_SUCCESS);
}
isc_result_t
isc_socketmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
isc_socketmgr_t **managerp)
-16
View File
@@ -28,9 +28,7 @@ isc_atomic_xadd(int32_t *p, int32_t val) {
int32_t prev = val;
__asm__ volatile(
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xadd %0, %1"
:"=q"(prev)
:"m"(*p), "0"(prev)
@@ -45,9 +43,7 @@ isc_atomic_xaddq(int64_t *p, int64_t val) {
int64_t prev = val;
__asm__ volatile(
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xaddq %0, %1"
:"=q"(prev)
:"m"(*p), "0"(prev)
@@ -63,13 +59,11 @@ isc_atomic_xaddq(int64_t *p, int64_t val) {
static __inline__ void
isc_atomic_store(int32_t *p, int32_t val) {
__asm__ volatile(
#ifdef ISC_PLATFORM_USETHREADS
/*
* xchg should automatically lock memory, but we add it
* explicitly just in case (it at least doesn't harm)
*/
"lock;"
#endif
"xchgl %1, %0"
:
@@ -84,13 +78,11 @@ isc_atomic_store(int32_t *p, int32_t val) {
static __inline__ void
isc_atomic_storeq(int64_t *p, int64_t val) {
__asm__ volatile(
#ifdef ISC_PLATFORM_USETHREADS
/*
* xchg should automatically lock memory, but we add it
* explicitly just in case (it at least doesn't harm)
*/
"lock;"
#endif
"xchgq %1, %0"
:
@@ -107,9 +99,7 @@ isc_atomic_storeq(int64_t *p, int64_t val) {
static __inline__ int32_t
isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) {
__asm__ volatile(
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"cmpxchgl %1, %2"
: "=a"(cmpval)
: "r"(val), "m"(*p), "a"(cmpval)
@@ -134,9 +124,7 @@ isc_atomic_xadd(int32_t *p, int32_t val) {
__asm (
"movl 8(%ebp), %ecx\n"
"movl 12(%ebp), %edx\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xadd %edx, (%ecx)\n"
/*
@@ -156,9 +144,7 @@ isc_atomic_store(int32_t *p, int32_t val) {
__asm (
"movl 8(%ebp), %ecx\n"
"movl 12(%ebp), %edx\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xchgl (%ecx), %edx\n"
);
}
@@ -173,9 +159,7 @@ isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) {
"movl 8(%ebp), %ecx\n"
"movl 12(%ebp), %eax\n" /* must be %eax for cmpxchgl */
"movl 16(%ebp), %edx\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
/*
* If (%ecx) == %eax then (%ecx) := %edx.
-10
View File
@@ -40,9 +40,7 @@ isc_atomic_xadd(int32_t *p, int32_t val) {
__asm (
"movq %rdi, %rdx\n"
"movl %esi, %eax\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xadd %eax, (%rdx)\n"
/*
* XXX: assume %eax will be used as the return value.
@@ -59,9 +57,7 @@ isc_atomic_xaddq(int64_t *p, int64_t val) {
__asm (
"movq %rdi, %rdx\n"
"movq %rsi, %rax\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xaddq %rax, (%rdx)\n"
/*
* XXX: assume %rax will be used as the return value.
@@ -78,9 +74,7 @@ isc_atomic_store(int32_t *p, int32_t val) {
__asm (
"movq %rdi, %rax\n"
"movl %esi, %edx\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xchgl (%rax), %edx\n"
);
}
@@ -94,9 +88,7 @@ isc_atomic_storeq(int64_t *p, int64_t val) {
__asm (
"movq %rdi, %rax\n"
"movq %rsi, %rdx\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
"xchgq (%rax), %rdx\n"
);
}
@@ -116,9 +108,7 @@ isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) {
"movl %esi, %eax\n"
"movq %rdi, %rdx\n"
#ifdef ISC_PLATFORM_USETHREADS
"lock;"
#endif
/*
* If [%rdi] == %eax then [%rdi] := %ecx (equal to %edx
* from above), and %eax is untouched (equal to %esi)
+4 -9
View File
@@ -34,7 +34,6 @@
*
* The state must be seeded so that it is not everywhere zero.
*/
#if defined(ISC_PLATFORM_USETHREADS)
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
static volatile HANDLE _mutex = NULL;
@@ -61,26 +60,22 @@ static volatile HANDLE _mutex = NULL;
#else /* defined(_WIN32) || defined(_WIN64) */
#include <pthread.h>
static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
//static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
#define _LOCK() pthread_mutex_lock(&_mutex)
#define _UNLOCK() pthread_mutex_unlock(&_mutex)
#endif /* defined(_WIN32) || defined(_WIN64) */
#else /* defined(ISC_PLATFORM_USETHREADS) */
#define _LOCK()
#define _UNLOCK()
#endif
static inline uint32_t rotl(const uint32_t x, int k) {
return (x << k) | (x >> (32 - k));
}
static uint32_t seed[4];
static thread_local uint32_t seed[4];
static inline uint32_t
next(void) {
uint32_t result_starstar, t;
_LOCK();
// _LOCK();
result_starstar = rotl(seed[0] * 5, 7) * 9;
t = seed[1] << 9;
@@ -94,7 +89,7 @@ next(void) {
seed[3] = rotl(seed[3], 11);
_UNLOCK();
// _UNLOCK();
return (result_starstar);
}
+49 -10
View File
@@ -102,7 +102,6 @@
#define SEND_BUFFER_SIZE 4096
#define RECV_BUFFER_SIZE 4096
#ifdef ISC_PLATFORM_USETHREADS
#define NMCTXS 100
/*%<
* Number of 'mctx pools' for clients. (Should this be configurable?)
@@ -112,13 +111,6 @@
* completely avoiding contentions among threads for an authoritative-only
* server.
*/
#else
#define NMCTXS 0
/*%<
* If named with built without thread, simply share manager's context. Using
* a separate context in this case would simply waste memory.
*/
#endif
#define COOKIE_SIZE 24U /* 8 + 4 + 4 + 8 */
#define ECS_SIZE 20U /* 2 + 1 + 1 + [0..16] */
@@ -1056,6 +1048,51 @@ ns_client_sendraw(ns_client_t *client, dns_message_t *message) {
ns_client_next(client, result);
}
#ifdef PSEUDOSEND
static void
client_pseudosend(ns_client_t *client, uint16_t id) {
isc_result_t result;
unsigned char *data;
isc_buffer_t buffer;
isc_buffer_t tcpbuffer;
isc_region_t r;
unsigned char sendbuf[SEND_BUFFER_SIZE];
result = client_allocsendbuf(client, &buffer, &tcpbuffer, 0,
sendbuf, &data);
if (result != ISC_R_SUCCESS) {
goto done;
}
isc_buffer_putuint16(&buffer, id);
isc_buffer_putuint8(&buffer, 0x81);
isc_buffer_putuint8(&buffer, 0x80);
isc_buffer_putuint16(&buffer, 0);
isc_buffer_putuint16(&buffer, 0);
isc_buffer_putuint16(&buffer, 0);
isc_buffer_putuint16(&buffer, 0);
if (client->sendcb != NULL) {
client->sendcb(&buffer);
} else if (TCP_CLIENT(client)) {
isc_buffer_usedregion(&buffer, &r);
isc_buffer_putuint16(&tcpbuffer, (uint16_t) r.length);
isc_buffer_add(&tcpbuffer, r.length);
result = client_sendpkg(client, &tcpbuffer);
} else {
result = client_sendpkg(client, &buffer);
}
if (result == ISC_R_SUCCESS) {
return;
}
done:
if (client->tcpbuf != NULL) {
isc_mem_put(client->mctx, client->tcpbuf, TCP_BUFFER_SIZE);
client->tcpbuf = NULL;
}
ns_client_next(client, result);
}
#endif
static void
client_send(ns_client_t *client) {
isc_result_t result;
@@ -2354,7 +2391,6 @@ ns__client_request(isc_task_t *task, isc_event_t *event) {
}
isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
#if NS_CLIENT_DROPPORT
if (ns_client_dropport(isc_sockaddr_getport(&client->peeraddr)) ==
DROPPORT_REQUEST) {
@@ -2411,7 +2447,10 @@ ns__client_request(isc_task_t *task, isc_event_t *event) {
ns_client_next(client, result);
return;
}
#ifdef PSEUDOSEND
client_pseudosend(client, id);
return;
#endif
/*
* The client object handles requests, not responses.
* If this is a UDP response, forward it to the dispatcher.
-14
View File
@@ -142,17 +142,12 @@ cleanup_managers(void) {
}
while (run_managers && !shutdown_done) {
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#else
/*
* There's no straightforward way to determine
* whether all the clients have shut down, so
* we'll just sleep for a bit and hope.
*/
ns_test_nap(500000);
#endif
}
if (sctx != NULL)
@@ -178,11 +173,7 @@ create_managers(void) {
isc_result_t result;
ns_listenlist_t *listenon = NULL;
isc_event_t *event = NULL;
#ifdef ISC_PLATFORM_USETHREADS
ncpus = isc_os_ncpus();
#else
ncpus = 1;
#endif
CHECK(isc_taskmgr_create(mctx, ncpus, 0, &taskmgr));
CHECK(isc_task_create(taskmgr, 0, &maintask));
@@ -212,17 +203,12 @@ create_managers(void) {
scan_interfaces, NULL,
sizeof (isc_event_t));
isc_task_send(maintask, &event);
#ifndef ISC_PLATFORM_USETHREADS
while (isc__taskmgr_ready(taskmgr))
isc__taskmgr_dispatch(taskmgr);
#else
/*
* There's no straightforward way to determine
* whether the interfaces have been scanned,
* we'll just sleep for a bit and hope.
*/
ns_test_nap(500000);
#endif
run_managers = true;
-2
View File
@@ -3407,7 +3407,6 @@
./lib/isc/alpha/include/isc/Makefile.in MAKE 2007,2012,2015,2016,2018
./lib/isc/alpha/include/isc/atomic.h C 2005,2007,2009,2016,2018
./lib/isc/api X 1999,2000,2001,2006,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
./lib/isc/app_api.c C 2009,2013,2014,2015,2016,2018
./lib/isc/assertions.c C 1997,1998,1999,2000,2001,2004,2005,2007,2008,2009,2015,2016,2018
./lib/isc/backtrace-emptytbl.c C 2009,2016,2018
./lib/isc/backtrace.c C 2009,2013,2014,2015,2016,2018
@@ -3603,7 +3602,6 @@
./lib/isc/sha1.c C 2000,2001,2003,2004,2005,2007,2009,2011,2012,2014,2016,2017,2018
./lib/isc/sha2.c C 2005,2006,2007,2009,2011,2012,2014,2016,2017,2018
./lib/isc/sockaddr.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2010,2011,2012,2014,2015,2016,2017,2018
./lib/isc/socket_api.c C 2009,2011,2012,2013,2014,2015,2016,2018
./lib/isc/sparc64/Makefile.in MAKE 2007,2012,2016,2018
./lib/isc/sparc64/include/Makefile.in MAKE 2007,2012,2016,2018
./lib/isc/sparc64/include/isc/Makefile.in MAKE 2007,2012,2015,2016,2018