Merge branch '478-remove-support-for-unthreaded-bind' into 'master'

Remove support for unthreaded BIND

Closes #478

See merge request isc-projects/bind9!655
This commit is contained in:
Witold Krecicki 2018-08-16 15:09:43 -04:00
commit 28cf1a7a9c
65 changed files with 1446 additions and 3099 deletions

View file

@ -1,3 +1,5 @@
5011. [func] Remove support for unthreaded named. [GL #478]
5010. [func] New "validate-except" option specifies a list of
domains beneath which DNSSEC validation should not
be performed. [GL #237]

1
aclocal.m4 vendored
View file

@ -289,6 +289,7 @@ AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR
m4_include([m4/ax_check_openssl.m4])
m4_include([m4/ax_pthread.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
m4_include([m4/ltsugar.m4])

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);

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,7 +772,6 @@ 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;
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
@ -785,9 +780,6 @@ create_managers(void) {
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
@ -800,12 +792,10 @@ create_managers(void) {
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);
@ -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);

View file

@ -11252,7 +11252,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));
@ -11262,10 +11261,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);

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

View file

@ -326,36 +326,21 @@ int sigwait(const unsigned int *set, int *sig);
/* Define to 1 if you have the <krb5/krb5.h> header file. */
#undef HAVE_KRB5_KRB5_H
/* Define to 1 if you have the `c' library (-lc). */
#undef HAVE_LIBC
/* if system have backtrace function */
#undef HAVE_LIBCTRACE
/* Define to 1 if you have the `c_r' library (-lc_r). */
#undef HAVE_LIBC_R
/* Define if libidn2 was found */
#undef HAVE_LIBIDN2
/* Define to 1 if you have the `nsl' library (-lnsl). */
#undef HAVE_LIBNSL
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the `rt' library (-lrt). */
#undef HAVE_LIBRT
/* Define to 1 if you have the `scf' library (-lscf). */
#undef HAVE_LIBSCF
/* Define to 1 if you have the `socket' library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define to 1 if you have the `thr' library (-lthr). */
#undef HAVE_LIBTHR
/* Define if libxml2 was found */
#undef HAVE_LIBXML2
@ -389,12 +374,24 @@ int sigwait(const unsigned int *set, int *sig);
/* define if OpenSSL supports Ed25519 */
#undef HAVE_OPENSSL_ED25519
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
/* Define to 1 if you have the `pthread_attr_getstacksize' function. */
#undef HAVE_PTHREAD_ATTR_GETSTACKSIZE
/* Define to 1 if you have the `pthread_attr_setstacksize' function. */
#undef HAVE_PTHREAD_ATTR_SETSTACKSIZE
/* Support for PTHREAD_MUTEX_ADAPTIVE_NP */
#undef HAVE_PTHREAD_MUTEX_ADAPTIVE_NP
/* Define to 1 if you have the <pthread_np.h> header file. */
#undef HAVE_PTHREAD_NP_H
/* Have PTHREAD_PRIO_INHERIT. */
#undef HAVE_PTHREAD_PRIO_INHERIT
/* Define to 1 if you have the `pthread_setname_np' function. */
#undef HAVE_PTHREAD_SETNAME_NP
@ -443,6 +440,9 @@ int sigwait(const unsigned int *set, int *sig);
/* Define to 1 if you have the `setresuid' function. */
#undef HAVE_SETRESUID
/* Define to 1 if you have the `sigwait' function. */
#undef HAVE_SIGWAIT
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@ -589,6 +589,10 @@ int sigwait(const unsigned int *set, int *sig);
(O_NDELAY/O_NONBLOCK). */
#undef PORT_NONBLOCK
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* The size of `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P

1695
configure vendored

File diff suppressed because it is too large Load diff

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
@ -842,195 +837,113 @@ AC_SUBST(CHECK_DSA)
#
AC_CHECK_FUNCS(arc4random arc4random_buf arc4random_uniform getrandom)
sinclude(config.threads.in)dnl
AX_PTHREAD
if $use_threads
then
if test "X$GCC" = "Xyes"; then
case "$host" in
*-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
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
#
# We'd like to use sigwait() too
#
AC_CHECK_FUNCS([sigwait pthread_attr_getstacksize pthread_attr_setstacksize])
AC_ARG_WITH([locktype],
AS_HELP_STRING([--with-locktype=ARG],
[Specify mutex lock type
(adaptive or standard)]),
[], [with_locktype="adaptive"])
AS_CASE([$with_locktype],
[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.])]
)
AC_CHECK_HEADERS([sched.h])
AC_SEARCH_LIBS([sched_yield],[rt])
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
*-dec-osf*)
CC="$CC -pthread"
CCOPT="$CCOPT -pthread"
CCNOOPT="$CCNOOPT -pthread"
*-freebsd5.[[012]]|*-freebsd5.[[012]].*);;
*-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*)
AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
;;
*-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"
*-freebsd6.*)
AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
;;
esac
fi
ALWAYS_DEFINES="-D_REENTRANT"
ISC_PLATFORM_USETHREADS="#define ISC_PLATFORM_USETHREADS 1"
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.
# 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.
#
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>])
*-bsdi3.*|*-bsdi4.0*)
AC_DEFINE(NEED_PTHREAD_INIT)
;;
#
# Look for sysconf to allow detection of the number of processors.
# LinuxThreads requires some changes to the way we
# deal with signals.
#
AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
*-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
else
ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
thread_dir=nothreads
THREADOPTOBJS=""
THREADOPTSRCS=""
ALWAYS_DEFINES=""
fi
# 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
AC_SUBST(ISC_THREAD_DIR)
AC_MSG_CHECKING(for libtool)
AC_ARG_WITH(libtool, AS_HELP_STRING([--with-libtool], [use GNU libtool]),
@ -1807,20 +1720,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 +3203,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 +3380,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 +3751,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)
;;
@ -4412,9 +4302,9 @@ AC_CONFIG_FILES([
lib/isc/$arch/Makefile
lib/isc/$arch/include/Makefile
lib/isc/$arch/include/isc/Makefile
lib/isc/$thread_dir/Makefile
lib/isc/$thread_dir/include/Makefile
lib/isc/$thread_dir/include/isc/Makefile
lib/isc/pthreads/Makefile
lib/isc/pthreads/include/Makefile
lib/isc/pthreads/include/isc/Makefile
lib/isc/Makefile
lib/isc/include/Makefile
lib/isc/include/isc/Makefile
@ -4480,11 +4370,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 +4436,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)"

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"

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"

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);

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;

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. */

View file

@ -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"

View file

@ -156,6 +156,14 @@
<section xml:id="relnotes_removed"><info><title>Removed Features</title></info>
<itemizedlist>
<listitem>
<para>
Previously, it was possible to build BIND without thread support
for old architectures and systems without threads support.
BIND now requires threading support (either POSIX or Windows) from
the operating system, and it cannot be built without threads.
</para>
</listitem>
<listitem>
<para>
<command>named</command> can no longer use the EDNS CLIENT-SUBNET

View file

@ -230,23 +230,13 @@ $ <userinput>patch -p1 -d openssl-0.9.8zc \
<screen>
$ <userinput>cp pkcs11.GCC4.0.2.so.4.05 /opt/pkcs11/usr/lib/libpkcs11.so</userinput>
</screen>
<para>
The Keyper library requires threads, so we
must specify -pthread.
</para>
<screen>
$ <userinput>cd openssl-0.9.8zc</userinput>
$ <userinput>./Configure linux-x86_64 -pthread \
$ <userinput>./Configure linux-x86_64 \
--pk11-libname=/opt/pkcs11/usr/lib/libpkcs11.so \
--pk11-flavor=sign-only \
--prefix=/opt/pkcs11/usr</userinput>
</screen>
<para>
After configuring, run "<command>make</command>"
and "<command>make test</command>". If "<command>make
test</command>" fails with "pthread_atfork() not found", you forgot to
add the -pthread above.
</para>
</section>
<section><info><title>Building OpenSSL for the SCA 6000 on Solaris</title></info>
<!-- Example 2 -->
@ -316,7 +306,7 @@ $ <userinput> /opt/pkcs11/usr/bin/softhsm --init-token 0 --slot 0 --label sofths
</para>
<screen>
$ <userinput>cd openssl-0.9.8zc</userinput>
$ <userinput>./Configure linux-x86_64 -pthread \
$ <userinput>./Configure linux-x86_64 \
--pk11-libname=/opt/pkcs11/usr/lib/libsofthsm.so \
--pk11-flavor=sign-only \
--prefix=/opt/pkcs11/usr</userinput>
@ -355,13 +345,9 @@ $ <userinput>./Configure linux-x86_64 -pthread \
<section><info><title>Configuring BIND 9 for Linux with the AEP Keyper</title></info>
<!-- Example 4 -->
<para>
To link with the PKCS#11 provider, threads must be
enabled in the BIND 9 build.
</para>
<screen>
$ <userinput>cd ../bind9</userinput>
$ <userinput>./configure --enable-threads \
$ <userinput>./configure \
--with-openssl=/opt/pkcs11/usr \
--with-pkcs11=/opt/pkcs11/usr/lib/libpkcs11.so</userinput>
</screen>
@ -369,13 +355,9 @@ $ <userinput>./configure --enable-threads \
<section><info><title>Configuring BIND 9 for Solaris with the SCA 6000</title></info>
<!-- Example 5 -->
<para>
To link with the PKCS#11 provider, threads must be
enabled in the BIND 9 build.
</para>
<screen>
$ <userinput>cd ../bind9</userinput>
$ <userinput>./configure CC="cc -xarch=amd64" --enable-threads \
$ <userinput>./configure CC="cc -xarch=amd64" \
--with-openssl=/opt/pkcs11/usr \
--with-pkcs11=/usr/lib/64/libpkcs11.so</userinput>
</screen>
@ -393,7 +375,7 @@ $ <userinput>./configure CC="cc -xarch=amd64" --enable-threads \
<screen>
$ <userinput>cd ../bind9</userinput>
$ <userinput>./configure --enable-threads \
$ <userinput>./configure \
--with-openssl=/opt/pkcs11/usr \
--with-pkcs11=/opt/pkcs11/usr/lib/libsofthsm.so</userinput>
</screen>

View file

@ -80,7 +80,7 @@ comments; they must be clearly written and consistent with existing style.
* Read the diff
* Read accompanying notes in the ticket
* Apply the diff to the appropriate branch
* Run `configure` (using at least `--enable-developer --enable-threads --with-atf`)
* Run `configure` (using at least `--enable-developer --with-atf`)
* Build
* Read the documentation, if any
* Read the tests

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);

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

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
}
/*

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;

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));

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());
}

View file

@ -1276,7 +1276,6 @@ ATF_TC_BODY(rbt_nodechain, tc) {
dns_test_end();
}
#ifdef ISC_PLATFORM_USETHREADS
#ifdef DNS_BENCHMARK_TESTS
/*
@ -1404,7 +1403,6 @@ ATF_TC_BODY(benchmark, tc) {
}
#endif /* DNS_BENCHMARK_TESTS */
#endif /* ISC_PLATFORM_USETHREADS */
/*
* Main
@ -1422,11 +1420,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());
}

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

View file

@ -10166,9 +10166,7 @@ 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;
}
@ -10434,9 +10432,7 @@ 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;
}
}
@ -14967,9 +14963,7 @@ 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;
}
}
@ -15203,9 +15197,7 @@ 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;
}
}
@ -15468,9 +15460,7 @@ 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;
}
}
@ -18513,9 +18503,7 @@ 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;
}
}

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 *

View file

@ -18,7 +18,7 @@ VERSION=@BIND9_VERSION@
@BIND9_MAKE_INCLUDES@
CINCLUDES = -I${srcdir}/unix/include \
-I${srcdir}/@ISC_THREAD_DIR@/include \
-I${srcdir}/pthreads/include \
-I${srcdir}/@ISC_ARCH_DIR@/include \
-I./include \
-I${srcdir}/include ${DNS_INCLUDES} @OPENSSL_INCLUDES@
@ -36,9 +36,7 @@ UNIXOBJS = @ISC_ISCIPV6_O@ unix/pk11_api.@O@ \
NLSOBJS = nls/msgcat.@O@
THREADOPTOBJS = @ISC_THREAD_DIR@/condition.@O@ @ISC_THREAD_DIR@/mutex.@O@
THREADOBJS = @THREADOPTOBJS@ @ISC_THREAD_DIR@/thread.@O@
THREADOBJS = pthreads/condition.@O@ pthreads/mutex.@O@ pthreads/thread.@O@
WIN32OBJS = win32/condition.@O@ win32/dir.@O@ win32/errno.@O@ \
win32/file.@O@ win32/fsaccess.@O@ \
@ -85,7 +83,7 @@ LIBS = @OPENSSL_LIBS@ @LIBS@
# Attempt to disable parallel processing.
.NOTPARALLEL:
.NO_PARALLEL:
SUBDIRS = include unix nls @ISC_THREAD_DIR@ @ISC_ARCH_DIR@
SUBDIRS = include unix nls pthreads @ISC_ARCH_DIR@
TARGETS = timestamp
TESTDIRS = @UNITTESTS@

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.
*/

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);

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,

View file

@ -826,19 +826,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

View file

@ -1,32 +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.
top_srcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
CINCLUDES = -I${srcdir}/include \
-I${srcdir}/../unix/include \
-I../include \
-I${srcdir}/../include \
-I${srcdir}/..
CDEFINES =
CWARNINGS =
THREADOPTOBJS = condition.@O@ mutex.@O@
OBJS = @THREADOPTOBJS@ thread.@O@
THREADOPTSRCS = condition.c mutex.c
SRCS = @THREADOPTSRCS@ thread.c
SUBDIRS = include
TARGETS = ${OBJS}
@BIND9_MAKE_RULES@

View file

@ -1,17 +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 <isc/util.h>
EMPTY_TRANSLATION_UNIT

View file

@ -1,17 +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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
SUBDIRS = isc
TARGETS =
@BIND9_MAKE_RULES@

View file

@ -1,34 +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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
VERSION=@BIND9_VERSION@
HEADERS = condition.h mutex.h once.h thread.h
SUBDIRS =
TARGETS =
@BIND9_MAKE_RULES@
installdirs:
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc
install:: installdirs
for i in ${HEADERS}; do \
${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \
done
uninstall::
for i in ${HEADERS}; do \
rm -f ${DESTDIR}${includedir}/isc/$$i ; \
done

View file

@ -1,52 +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.
*/
/*
* This provides a limited subset of the isc_condition_t
* functionality for use by single-threaded programs that
* need to block waiting for events. Only a single
* call to isc_condition_wait() may be blocked at any given
* time, and the _waituntil and _broadcast functions are not
* supported. This is intended primarily for use by the omapi
* library, and may go away once omapi goes away. Use for
* other purposes is strongly discouraged.
*/
#ifndef ISC_CONDITION_H
#define ISC_CONDITION_H 1
#include <isc/mutex.h>
typedef int isc_condition_t;
isc_result_t isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp);
isc_result_t isc__nothread_signal_hack(isc_condition_t *cp);
#define isc_condition_init(cp) \
(*(cp) = 0, ISC_R_SUCCESS)
#define isc_condition_wait(cp, mp) \
isc__nothread_wait_hack(cp, mp)
#define isc_condition_waituntil(cp, mp, tp) \
((void)(cp), (void)(mp), (void)(tp), ISC_R_NOTIMPLEMENTED)
#define isc_condition_signal(cp) \
isc__nothread_signal_hack(cp)
#define isc_condition_broadcast(cp) \
((void)(cp), ISC_R_NOTIMPLEMENTED)
#define isc_condition_destroy(cp) \
(*(cp) == 0 ? (*(cp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED)
#endif /* ISC_CONDITION_H */

View file

@ -1,31 +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.
*/
#ifndef ISC_MUTEX_H
#define ISC_MUTEX_H 1
#include <isc/result.h> /* for ISC_R_ codes */
typedef int isc_mutex_t;
#define isc_mutex_init(mp) \
(*(mp) = 0, ISC_R_SUCCESS)
#define isc_mutex_lock(mp) \
((*(mp))++ == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
#define isc_mutex_unlock(mp) \
(--(*(mp)) == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
#define isc_mutex_trylock(mp) \
(*(mp) == 0 ? ((*(mp))++, ISC_R_SUCCESS) : ISC_R_LOCKBUSY)
#define isc_mutex_destroy(mp) \
(*(mp) == 0 ? (*(mp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED)
#define isc_mutex_stats(fp)
#endif /* ISC_MUTEX_H */

View file

@ -1,27 +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.
*/
#ifndef ISC_ONCE_H
#define ISC_ONCE_H 1
#include <stdbool.h>
#include <isc/result.h>
typedef bool isc_once_t;
#define ISC_ONCE_INIT false
#define isc_once_do(op, f) \
(!*(op) ? (f(), *(op) = true, ISC_R_SUCCESS) : ISC_R_SUCCESS)
#endif /* ISC_ONCE_H */

View file

@ -1,40 +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.
*/
#ifndef ISC_THREAD_H
#define ISC_THREAD_H 1
#include <isc/lang.h>
#include <isc/result.h>
ISC_LANG_BEGINDECLS
/* Placeholder types (they are not accessed) */
typedef void * isc_thread_t;
typedef void * isc_threadresult_t;
typedef void * isc_threadarg_t;
typedef void * isc_threadfunc_t;
typedef void * isc_thread_key_t;
void
isc_thread_setconcurrency(unsigned int level);
void
isc_thread_setname(isc_thread_t thread, const char *name);
#define isc_thread_self() ((unsigned long)0)
#define isc_thread_yield() ((void)0)
ISC_LANG_ENDDECLS
#endif /* ISC_THREAD_H */

View file

@ -1,18 +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 <isc/util.h>
EMPTY_TRANSLATION_UNIT

View file

@ -1,26 +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 <isc/thread.h>
#include <isc/util.h>
void
isc_thread_setconcurrency(unsigned int level) {
UNUSED(level);
}
void isc_thread_setname(isc_thread_t thread, const char *name) {
UNUSED(thread);
UNUSED(name);
}

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);

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 */

View file

@ -53,12 +53,6 @@
* is expected to have a separate manager; no "worker threads" are shared by
* the application threads.
*/
#ifdef ISC_PLATFORM_USETHREADS
#define USE_WORKER_THREADS
#else
#define USE_SHARED_MANAGER
#endif /* ISC_PLATFORM_USETHREADS */
#ifdef ISC_TASK_TRACE
#define XTRACE(m) fprintf(stderr, "task %p thread %lu: %s\n", \
task, isc_thread_self(), (m))
@ -132,21 +126,17 @@ struct isc__taskmgr {
isc_taskmgr_t common;
isc_mem_t * mctx;
isc_mutex_t lock;
#ifdef ISC_PLATFORM_USETHREADS
unsigned int workers;
isc_thread_t * threads;
#endif /* ISC_PLATFORM_USETHREADS */
/* Locked by task manager lock. */
unsigned int default_quantum;
LIST(isc__task_t) tasks;
isc__tasklist_t ready_tasks;
isc__tasklist_t ready_priority_tasks;
isc_taskmgrmode_t mode;
#ifdef ISC_PLATFORM_USETHREADS
isc_condition_t work_available;
isc_condition_t exclusive_granted;
isc_condition_t paused;
#endif /* ISC_PLATFORM_USETHREADS */
unsigned int tasks_running;
unsigned int tasks_ready;
bool pause_requested;
@ -160,19 +150,12 @@ struct isc__taskmgr {
*/
isc_mutex_t excl_lock;
isc__task_t *excl;
#ifdef USE_SHARED_MANAGER
unsigned int refs;
#endif /* ISC_PLATFORM_USETHREADS */
};
#define DEFAULT_TASKMGR_QUANTUM 10
#define DEFAULT_DEFAULT_QUANTUM 5
#define FINISHED(m) ((m)->exiting && EMPTY((m)->tasks))
#ifdef USE_SHARED_MANAGER
static isc__taskmgr_t *taskmgr = NULL;
#endif /* USE_SHARED_MANAGER */
/*%
* The following are intended for internal use (indicated by "isc__"
* prefix) but are not declared as static, allowing direct access from
@ -314,7 +297,6 @@ task_finished(isc__task_t *task) {
LOCK(&manager->lock);
UNLINK(manager->tasks, task, link);
#ifdef USE_WORKER_THREADS
if (FINISHED(manager)) {
/*
* All tasks have completed and the
@ -324,7 +306,6 @@ task_finished(isc__task_t *task) {
*/
BROADCAST(&manager->work_available);
}
#endif /* USE_WORKER_THREADS */
UNLOCK(&manager->lock);
DESTROYLOCK(&task->lock);
@ -461,9 +442,7 @@ task_shutdown(isc__task_t *task) {
static inline void
task_ready(isc__task_t *task) {
isc__taskmgr_t *manager = task->manager;
#ifdef USE_WORKER_THREADS
bool has_privilege = isc__task_privilege((isc_task_t *) task);
#endif /* USE_WORKER_THREADS */
REQUIRE(VALID_MANAGER(manager));
REQUIRE(task->state == task_state_ready);
@ -472,10 +451,8 @@ task_ready(isc__task_t *task) {
LOCK(&manager->lock);
push_readyq(manager, task);
#ifdef USE_WORKER_THREADS
if (manager->mode == isc_taskmgrmode_normal || has_privilege)
SIGNAL(&manager->work_available);
#endif /* USE_WORKER_THREADS */
UNLOCK(&manager->lock);
}
@ -1001,12 +978,6 @@ push_readyq(isc__taskmgr_t *manager, isc__task_t *task) {
static void
dispatch(isc__taskmgr_t *manager) {
isc__task_t *task;
#ifndef USE_WORKER_THREADS
unsigned int total_dispatch_count = 0;
isc__tasklist_t new_ready_tasks;
isc__tasklist_t new_priority_tasks;
unsigned int tasks_ready = 0;
#endif /* USE_WORKER_THREADS */
REQUIRE(VALID_MANAGER(manager));
@ -1060,14 +1031,9 @@ dispatch(isc__taskmgr_t *manager) {
* unlocks. The while expression is always protected by the lock.
*/
#ifndef USE_WORKER_THREADS
ISC_LIST_INIT(new_ready_tasks);
ISC_LIST_INIT(new_priority_tasks);
#endif
LOCK(&manager->lock);
while (!FINISHED(manager)) {
#ifdef USE_WORKER_THREADS
/*
* For reasons similar to those given in the comment in
* isc_task_send() above, it is safe for us to dequeue
@ -1089,11 +1055,6 @@ dispatch(isc__taskmgr_t *manager) {
ISC_MSGSET_TASK,
ISC_MSG_AWAKE, "awake"));
}
#else /* USE_WORKER_THREADS */
if (total_dispatch_count >= DEFAULT_TASKMGR_QUANTUM ||
empty_readyq(manager))
break;
#endif /* USE_WORKER_THREADS */
XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK,
ISC_MSG_WORKING, "working"));
@ -1144,9 +1105,6 @@ dispatch(isc__taskmgr_t *manager) {
LOCK(&task->lock);
}
dispatch_count++;
#ifndef USE_WORKER_THREADS
total_dispatch_count++;
#endif /* USE_WORKER_THREADS */
}
if (task->references == 0 &&
@ -1231,7 +1189,6 @@ dispatch(isc__taskmgr_t *manager) {
LOCK(&manager->lock);
manager->tasks_running--;
#ifdef USE_WORKER_THREADS
if (manager->exclusive_requested &&
manager->tasks_running == 1) {
SIGNAL(&manager->exclusive_granted);
@ -1239,7 +1196,6 @@ dispatch(isc__taskmgr_t *manager) {
manager->tasks_running == 0) {
SIGNAL(&manager->paused);
}
#endif /* USE_WORKER_THREADS */
if (requeue) {
/*
* We know we're awake, so we don't have
@ -1260,19 +1216,10 @@ dispatch(isc__taskmgr_t *manager) {
* were usually nonempty, the 'optimization'
* might even hurt rather than help.
*/
#ifdef USE_WORKER_THREADS
push_readyq(manager, task);
#else
ENQUEUE(new_ready_tasks, task, ready_link);
if ((task->flags & TASK_F_PRIVILEGED) != 0)
ENQUEUE(new_priority_tasks, task,
ready_priority_link);
tasks_ready++;
#endif
}
}
#ifdef USE_WORKER_THREADS
/*
* If we are in privileged execution mode and there are no
* tasks remaining on the current ready queue, then
@ -1284,22 +1231,11 @@ dispatch(isc__taskmgr_t *manager) {
if (!empty_readyq(manager))
BROADCAST(&manager->work_available);
}
#endif
}
#ifndef USE_WORKER_THREADS
ISC_LIST_APPENDLIST(manager->ready_tasks, new_ready_tasks, ready_link);
ISC_LIST_APPENDLIST(manager->ready_priority_tasks, new_priority_tasks,
ready_priority_link);
manager->tasks_ready += tasks_ready;
if (empty_readyq(manager))
manager->mode = isc_taskmgrmode_normal;
#endif
UNLOCK(&manager->lock);
}
#ifdef USE_WORKER_THREADS
static isc_threadresult_t
#ifdef _WIN32
WINAPI
@ -1321,18 +1257,15 @@ run(void *uap) {
return ((isc_threadresult_t)0);
}
#endif /* USE_WORKER_THREADS */
static void
manager_free(isc__taskmgr_t *manager) {
isc_mem_t *mctx;
#ifdef USE_WORKER_THREADS
(void)isc_condition_destroy(&manager->exclusive_granted);
(void)isc_condition_destroy(&manager->work_available);
(void)isc_condition_destroy(&manager->paused);
isc_mem_free(manager->mctx, manager->threads);
#endif /* USE_WORKER_THREADS */
DESTROYLOCK(&manager->lock);
DESTROYLOCK(&manager->excl_lock);
manager->common.impmagic = 0;
@ -1340,10 +1273,6 @@ manager_free(isc__taskmgr_t *manager) {
mctx = manager->mctx;
isc_mem_put(mctx, manager, sizeof(*manager));
isc_mem_detach(&mctx);
#ifdef USE_SHARED_MANAGER
taskmgr = NULL;
#endif /* USE_SHARED_MANAGER */
}
isc_result_t
@ -1361,21 +1290,6 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
REQUIRE(workers > 0);
REQUIRE(managerp != NULL && *managerp == NULL);
#ifndef USE_WORKER_THREADS
UNUSED(i);
UNUSED(started);
#endif
#ifdef USE_SHARED_MANAGER
if (taskmgr != NULL) {
if (taskmgr->refs == 0)
return (ISC_R_SHUTTINGDOWN);
taskmgr->refs++;
*managerp = (isc_taskmgr_t *)taskmgr;
return (ISC_R_SUCCESS);
}
#endif /* USE_SHARED_MANAGER */
manager = isc_mem_get(mctx, sizeof(*manager));
if (manager == NULL)
return (ISC_R_NOMEMORY);
@ -1393,7 +1307,6 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
goto cleanup_mgr;
}
#ifdef USE_WORKER_THREADS
manager->workers = 0;
manager->threads = isc_mem_allocate(mctx,
workers * sizeof(isc_thread_t));
@ -1425,7 +1338,6 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
result = ISC_R_UNEXPECTED;
goto cleanup_exclusivegranted;
}
#endif /* USE_WORKER_THREADS */
if (default_quantum == 0)
default_quantum = DEFAULT_DEFAULT_QUANTUM;
manager->default_quantum = default_quantum;
@ -1441,7 +1353,6 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
isc_mem_attach(mctx, &manager->mctx);
#ifdef USE_WORKER_THREADS
LOCK(&manager->lock);
/*
* Start workers.
@ -1465,17 +1376,11 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
return (ISC_R_NOTHREADS);
}
isc_thread_setconcurrency(workers);
#endif /* USE_WORKER_THREADS */
#ifdef USE_SHARED_MANAGER
manager->refs = 1;
taskmgr = manager;
#endif /* USE_SHARED_MANAGER */
*managerp = (isc_taskmgr_t *)manager;
return (ISC_R_SUCCESS);
#ifdef USE_WORKER_THREADS
cleanup_exclusivegranted:
(void)isc_condition_destroy(&manager->exclusive_granted);
cleanup_workavailable:
@ -1484,7 +1389,6 @@ isc__taskmgr_create(isc_mem_t *mctx, unsigned int workers,
isc_mem_free(mctx, manager->threads);
cleanup_lock:
DESTROYLOCK(&manager->lock);
#endif
cleanup_mgr:
isc_mem_put(mctx, manager, sizeof(*manager));
return (result);
@ -1504,18 +1408,6 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
manager = (isc__taskmgr_t *)*managerp;
REQUIRE(VALID_MANAGER(manager));
#ifndef USE_WORKER_THREADS
UNUSED(i);
#endif /* USE_WORKER_THREADS */
#ifdef USE_SHARED_MANAGER
manager->refs--;
if (manager->refs > 0) {
*managerp = NULL;
return;
}
#endif
XTHREADTRACE("isc_taskmgr_destroy");
/*
* Only one non-worker thread may ever call this routine.
@ -1567,7 +1459,6 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
push_readyq(manager, task);
UNLOCK(&task->lock);
}
#ifdef USE_WORKER_THREADS
/*
* Wake up any sleeping workers. This ensures we get work done if
* there's work left to do, and if there are already no tasks left
@ -1581,28 +1472,6 @@ isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
*/
for (i = 0; i < manager->workers; i++)
(void)isc_thread_join(manager->threads[i], NULL);
#else /* USE_WORKER_THREADS */
/*
* Dispatch the shutdown events.
*/
UNLOCK(&manager->lock);
while (isc__taskmgr_ready((isc_taskmgr_t *)manager))
(void)isc__taskmgr_dispatch((isc_taskmgr_t *)manager);
if (!ISC_LIST_EMPTY(manager->tasks)) {
isc__task_t *t;
isc_mem_printallactive(stderr);
for (t = ISC_LIST_HEAD(manager->tasks);
t != NULL;
t = ISC_LIST_NEXT(t, link))
{
fprintf(stderr, "task: %p (%s)\n", t, t->name);
}
}
INSIST(ISC_LIST_EMPTY(manager->tasks));
#ifdef USE_SHARED_MANAGER
taskmgr = NULL;
#endif
#endif /* USE_WORKER_THREADS */
manager_free(manager);
@ -1628,43 +1497,6 @@ isc__taskmgr_mode(isc_taskmgr_t *manager0) {
return (mode);
}
#ifndef USE_WORKER_THREADS
bool
isc__taskmgr_ready(isc_taskmgr_t *manager0) {
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
bool is_ready;
#ifdef USE_SHARED_MANAGER
if (manager == NULL)
manager = taskmgr;
#endif
if (manager == NULL)
return (false);
LOCK(&manager->lock);
is_ready = !empty_readyq(manager);
UNLOCK(&manager->lock);
return (is_ready);
}
isc_result_t
isc__taskmgr_dispatch(isc_taskmgr_t *manager0) {
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
#ifdef USE_SHARED_MANAGER
if (manager == NULL)
manager = taskmgr;
#endif
if (manager == NULL)
return (ISC_R_NOTFOUND);
dispatch(manager);
return (ISC_R_SUCCESS);
}
#else
void
isc__taskmgr_pause(isc_taskmgr_t *manager0) {
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
@ -1687,7 +1519,6 @@ isc__taskmgr_resume(isc_taskmgr_t *manager0) {
}
UNLOCK(&manager->lock);
}
#endif /* USE_WORKER_THREADS */
void
isc_taskmgr_setexcltask(isc_taskmgr_t *mgr0, isc_task_t *task0) {
@ -1723,7 +1554,6 @@ isc_taskmgr_excltask(isc_taskmgr_t *mgr0, isc_task_t **taskp) {
isc_result_t
isc__task_beginexclusive(isc_task_t *task0) {
#ifdef USE_WORKER_THREADS
isc__task_t *task = (isc__task_t *)task0;
isc__taskmgr_t *manager = task->manager;
@ -1743,15 +1573,11 @@ isc__task_beginexclusive(isc_task_t *task0) {
WAIT(&manager->exclusive_granted, &manager->lock);
}
UNLOCK(&manager->lock);
#else
UNUSED(task0);
#endif
return (ISC_R_SUCCESS);
}
void
isc__task_endexclusive(isc_task_t *task0) {
#ifdef USE_WORKER_THREADS
isc__task_t *task = (isc__task_t *)task0;
isc__taskmgr_t *manager = task->manager;
@ -1761,9 +1587,6 @@ isc__task_endexclusive(isc_task_t *task0) {
manager->exclusive_requested = false;
BROADCAST(&manager->work_available);
UNLOCK(&manager->lock);
#else
UNUSED(task0);
#endif
}
void
@ -1833,7 +1656,6 @@ isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, xmlTextWriterPtr writer) {
* on which type is enabled.
*/
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "thread-model"));
#ifdef ISC_PLATFORM_USETHREADS
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "type"));
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "threaded"));
TRY0(xmlTextWriterEndElement(writer)); /* type */
@ -1841,15 +1663,6 @@ isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, xmlTextWriterPtr writer) {
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "worker-threads"));
TRY0(xmlTextWriterWriteFormatString(writer, "%d", mgr->workers));
TRY0(xmlTextWriterEndElement(writer)); /* worker-threads */
#else /* ISC_PLATFORM_USETHREADS */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "type"));
TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR "non-threaded"));
TRY0(xmlTextWriterEndElement(writer)); /* type */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "references"));
TRY0(xmlTextWriterWriteFormatString(writer, "%d", mgr->refs));
TRY0(xmlTextWriterEndElement(writer)); /* references */
#endif /* ISC_PLATFORM_USETHREADS */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "default-quantum"));
TRY0(xmlTextWriterWriteFormatString(writer, "%d",
@ -1942,7 +1755,6 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, json_object *tasks) {
* Write out the thread-model, and some details about each depending
* on which type is enabled.
*/
#ifdef ISC_PLATFORM_USETHREADS
obj = json_object_new_string("threaded");
CHECKMEM(obj);
json_object_object_add(tasks, "thread-model", obj);
@ -1950,15 +1762,6 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, json_object *tasks) {
obj = json_object_new_int(mgr->workers);
CHECKMEM(obj);
json_object_object_add(tasks, "worker-threads", obj);
#else /* ISC_PLATFORM_USETHREADS */
obj = json_object_new_string("non-threaded");
CHECKMEM(obj);
json_object_object_add(tasks, "thread-model", obj);
obj = json_object_new_int(mgr->refs);
CHECKMEM(obj);
json_object_object_add(tasks, "references", obj);
#endif /* ISC_PLATFORM_USETHREADS */
obj = json_object_new_int(mgr->default_quantum);
CHECKMEM(obj);

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));

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);
}

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());
}

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());
}

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,13 +92,8 @@ 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;
};
@ -171,22 +155,13 @@ static struct isc__timermgrmethods {
(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) {
isc_result_t result;
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 +169,14 @@ 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 +239,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 +271,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 +286,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 */
}
}
@ -777,7 +734,6 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) {
}
}
#ifdef USE_TIMER_THREAD
static isc_threadresult_t
#ifdef _WIN32 /* XXXDCL */
WINAPI
@ -822,7 +778,6 @@ run(void *uap) {
return ((isc_threadresult_t)0);
}
#endif /* USE_TIMER_THREAD */
static bool
sooner(void *v1, void *v2) {
@ -859,14 +814,6 @@ 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);
@ -893,7 +840,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 +865,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,15 +873,11 @@ 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
@ -958,32 +895,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 +912,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,42 +927,8 @@ 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));

View file

@ -12,7 +12,7 @@ VPATH = @srcdir@
top_srcdir = @top_srcdir@
CINCLUDES = -I${srcdir}/include \
-I${srcdir}/../@ISC_THREAD_DIR@/include \
-I${srcdir}/../pthreads/include \
-I../include \
-I${srcdir}/../include \
-I${srcdir}/.. @OPENSSL_INCLUDES@

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,14 +49,7 @@
* 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__"
@ -117,10 +108,8 @@ 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;
@ -231,7 +220,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 +232,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 +289,6 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
goto cleanup;
#endif
#ifdef ISC_PLATFORM_USETHREADS
/*
* Block SIGHUP, SIGINT, SIGTERM.
*
@ -335,44 +317,14 @@ 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);
}
@ -434,159 +386,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__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 +426,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,7 +545,6 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
}
return (ISC_R_SUCCESS);
#endif /* ISC_PLATFORM_USETHREADS */
}
isc_result_t
@ -758,9 +556,7 @@ isc_result_t
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 +576,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 +612,6 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
UNLOCK(&ctx->readylock);
SIGNAL(&ctx->ready);
}
#endif /* ISC_PLATFORM_USETHREADS */
}
}
@ -835,9 +627,7 @@ isc_result_t
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 +648,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 +685,6 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
UNLOCK(&ctx->readylock);
SIGNAL(&ctx->ready);
}
#endif /* ISC_PLATFORM_USETHREADS */
}
}
@ -925,41 +712,33 @@ isc__app_finish(void) {
void
isc__app_block(void) {
#ifdef ISC_PLATFORM_USETHREADS
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
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

View file

@ -84,17 +84,6 @@
#include "errno2result.h"
/* See task.c about the following definition: */
#ifdef ISC_PLATFORM_USETHREADS
#define USE_WATCHER_THREAD
#else
#define USE_SHARED_MANAGER
#endif /* ISC_PLATFORM_USETHREADS */
#ifndef USE_WATCHER_THREAD
#include "socket_p.h"
#endif /* USE_WATCHER_THREAD */
#if defined(SO_BSDCOMPAT) && defined(__linux__)
#include <sys/utsname.h>
#endif
@ -120,21 +109,6 @@ typedef struct {
#define USE_SELECT
#endif /* ISC_PLATFORM_HAVEKQUEUE */
#ifndef USE_WATCHER_THREAD
#if defined(USE_KQUEUE) || defined(USE_EPOLL) || defined(USE_DEVPOLL)
struct isc_socketwait {
int nevents;
};
#elif defined (USE_SELECT)
struct isc_socketwait {
fd_set *readset;
fd_set *writeset;
int nfds;
int maxfd;
};
#endif /* USE_KQUEUE */
#endif /* !USE_WATCHER_THREAD */
/*
* Set by the -T dscp option on the command line. If set to a value
* other than -1, we check to make sure DSCP values match it, and
@ -215,13 +189,8 @@ typedef enum { poll_idle, poll_active, poll_checking } pollstate_t;
/*%
* Size of per-FD lock buckets.
*/
#ifdef ISC_PLATFORM_USETHREADS
#define FDLOCK_COUNT 1024
#define FDLOCK_ID(fd) ((fd) % FDLOCK_COUNT)
#else
#define FDLOCK_COUNT 1
#define FDLOCK_ID(fd) 0
#endif /* ISC_PLATFORM_USETHREADS */
/*%
* Maximum number of events communicated with the kernel. There should normally
@ -443,9 +412,7 @@ struct isc__socketmgr {
int fd_bufsize;
#endif /* USE_SELECT */
unsigned int maxsocks;
#ifdef ISC_PLATFORM_USETHREADS
int pipe_fds[2];
#endif
/* Locked by fdlock. */
isc__socket_t **fds;
@ -467,19 +434,11 @@ struct isc__socketmgr {
int maxfd;
#endif /* USE_SELECT */
int reserved; /* unlocked */
#ifdef USE_WATCHER_THREAD
isc_thread_t watcher;
isc_condition_t shutdown_ok;
#else /* USE_WATCHER_THREAD */
unsigned int refs;
#endif /* USE_WATCHER_THREAD */
int maxudp;
};
#ifdef USE_SHARED_MANAGER
static isc__socketmgr_t *socketmgr = NULL;
#endif /* USE_SHARED_MANAGER */
#define CLOSED 0 /* this one must be zero */
#define MANAGED 1
#define CLOSE_PENDING 2
@ -516,9 +475,7 @@ static void build_msghdr_send(isc__socket_t *, char *, isc_socketevent_t *,
struct msghdr *, struct iovec *, size_t *);
static void build_msghdr_recv(isc__socket_t *, char *, isc_socketevent_t *,
struct msghdr *, struct iovec *, size_t *);
#ifdef USE_WATCHER_THREAD
static bool process_ctlfd(isc__socketmgr_t *manager);
#endif
static void setdscp(isc__socket_t *sock, isc_dscp_t dscp);
/*%
@ -809,8 +766,6 @@ static const isc_statscounter_t rawstatsindex[] = {
isc_sockstatscounter_rawactive
};
#if defined(USE_KQUEUE) || defined(USE_EPOLL) || defined(USE_DEVPOLL) || \
defined(USE_WATCHER_THREAD)
static void
manager_log(isc__socketmgr_t *sockmgr,
isc_logcategory_t *category, isc_logmodule_t *module, int level,
@ -833,7 +788,6 @@ manager_log(isc__socketmgr_t *sockmgr,
isc_log_write(isc_lctx, category, module, level,
"sockmgr %p: %s", sockmgr, msgbuf);
}
#endif
static void
socket_log(isc__socket_t *sock, const isc_sockaddr_t *address,
@ -1159,7 +1113,6 @@ wakeup_socket(isc__socketmgr_t *manager, int fd, int msg) {
}
}
#ifdef USE_WATCHER_THREAD
/*
* Poke the select loop when there is something for us to do.
* The write is required (by POSIX) to complete. That is, we
@ -1230,19 +1183,6 @@ select_readmsg(isc__socketmgr_t *mgr, int *fd, int *msg) {
*fd = buf[0];
*msg = buf[1];
}
#else /* USE_WATCHER_THREAD */
/*
* Update the state of the socketmgr when something changes.
*/
static void
select_poke(isc__socketmgr_t *manager, int fd, int msg) {
if (msg == SELECT_POKE_SHUTDOWN)
return;
else if (fd >= 0)
wakeup_socket(manager, fd, msg);
return;
}
#endif /* USE_WATCHER_THREAD */
/*
* Make a fd non-blocking.
@ -2263,10 +2203,8 @@ socketclose(isc__socketmgr_t *manager, isc__socket_t *sock, int fd) {
}
UNLOCK(&manager->fdlock[lockid]);
}
#ifdef ISC_PLATFORM_USETHREADS
if (manager->maxfd < manager->pipe_fds[0])
manager->maxfd = manager->pipe_fds[0];
#endif
}
UNLOCK(&manager->lock);
@ -2298,10 +2236,8 @@ destroy(isc__socket_t **sockp) {
ISC_LIST_UNLINK(manager->socklist, sock, link);
#ifdef USE_WATCHER_THREAD
if (ISC_LIST_EMPTY(manager->socklist))
SIGNAL(&manager->shutdown_ok);
#endif /* USE_WATCHER_THREAD */
/* can't unlock manager as its memory context is still used */
free_socket(sockp);
@ -4028,9 +3964,7 @@ process_fds(isc__socketmgr_t *manager, struct kevent *events, int nevents) {
int i;
bool readable, writable;
bool done = false;
#ifdef USE_WATCHER_THREAD
bool have_ctlevent = false;
#endif
if (nevents == manager->nevents) {
/*
@ -4046,21 +3980,17 @@ process_fds(isc__socketmgr_t *manager, struct kevent *events, int nevents) {
for (i = 0; i < nevents; i++) {
REQUIRE(events[i].ident < manager->maxsocks);
#ifdef USE_WATCHER_THREAD
if (events[i].ident == (uintptr_t)manager->pipe_fds[0]) {
have_ctlevent = true;
continue;
}
#endif
readable = (events[i].filter == EVFILT_READ);
writable = (events[i].filter == EVFILT_WRITE);
process_fd(manager, events[i].ident, readable, writable);
}
#ifdef USE_WATCHER_THREAD
if (have_ctlevent)
done = process_ctlfd(manager);
#endif
return (done);
}
@ -4070,9 +4000,7 @@ process_fds(isc__socketmgr_t *manager, struct epoll_event *events, int nevents)
{
int i;
bool done = false;
#ifdef USE_WATCHER_THREAD
bool have_ctlevent = false;
#endif
if (nevents == manager->nevents) {
manager_log(manager, ISC_LOGCATEGORY_GENERAL,
@ -4083,12 +4011,10 @@ process_fds(isc__socketmgr_t *manager, struct epoll_event *events, int nevents)
for (i = 0; i < nevents; i++) {
REQUIRE(events[i].data.fd < (int)manager->maxsocks);
#ifdef USE_WATCHER_THREAD
if (events[i].data.fd == manager->pipe_fds[0]) {
have_ctlevent = true;
continue;
}
#endif
if ((events[i].events & EPOLLERR) != 0 ||
(events[i].events & EPOLLHUP) != 0) {
/*
@ -4106,10 +4032,8 @@ process_fds(isc__socketmgr_t *manager, struct epoll_event *events, int nevents)
(events[i].events & EPOLLOUT) != 0);
}
#ifdef USE_WATCHER_THREAD
if (have_ctlevent)
done = process_ctlfd(manager);
#endif
return (done);
}
@ -4118,9 +4042,7 @@ static bool
process_fds(isc__socketmgr_t *manager, struct pollfd *events, int nevents) {
int i;
bool done = false;
#ifdef USE_WATCHER_THREAD
bool have_ctlevent = false;
#endif
if (nevents == manager->nevents) {
manager_log(manager, ISC_LOGCATEGORY_GENERAL,
@ -4131,21 +4053,17 @@ process_fds(isc__socketmgr_t *manager, struct pollfd *events, int nevents) {
for (i = 0; i < nevents; i++) {
REQUIRE(events[i].fd < (int)manager->maxsocks);
#ifdef USE_WATCHER_THREAD
if (events[i].fd == manager->pipe_fds[0]) {
have_ctlevent = true;
continue;
}
#endif
process_fd(manager, events[i].fd,
(events[i].events & POLLIN) != 0,
(events[i].events & POLLOUT) != 0);
}
#ifdef USE_WATCHER_THREAD
if (have_ctlevent)
done = process_ctlfd(manager);
#endif
return (done);
}
@ -4159,17 +4077,14 @@ process_fds(isc__socketmgr_t *manager, int maxfd, fd_set *readfds,
REQUIRE(maxfd <= (int)manager->maxsocks);
for (i = 0; i < maxfd; i++) {
#ifdef USE_WATCHER_THREAD
if (i == manager->pipe_fds[0] || i == manager->pipe_fds[1])
continue;
#endif /* USE_WATCHER_THREAD */
process_fd(manager, i, FD_ISSET(i, readfds),
FD_ISSET(i, writefds));
}
}
#endif
#ifdef USE_WATCHER_THREAD
static bool
process_ctlfd(isc__socketmgr_t *manager) {
int msg, fd;
@ -4366,7 +4281,6 @@ watcher(void *uap) {
return ((isc_threadresult_t)0);
}
#endif /* USE_WATCHER_THREAD */
void
isc__socketmgr_setreserved(isc_socketmgr_t *manager0, uint32_t reserved) {
@ -4417,7 +4331,6 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
return (result);
}
#ifdef USE_WATCHER_THREAD
result = watch_fd(manager, manager->pipe_fds[0], SELECT_POKE_READ);
if (result != ISC_R_SUCCESS) {
close(manager->kqueue_fd);
@ -4425,7 +4338,6 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
sizeof(struct kevent) * manager->nevents);
return (result);
}
#endif /* USE_WATCHER_THREAD */
#elif defined(USE_EPOLL)
manager->nevents = ISC_SOCKET_MAXEVENTS;
manager->events = isc_mem_get(mctx, sizeof(struct epoll_event) *
@ -4445,7 +4357,6 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
sizeof(struct epoll_event) * manager->nevents);
return (result);
}
#ifdef USE_WATCHER_THREAD
result = watch_fd(manager, manager->pipe_fds[0], SELECT_POKE_READ);
if (result != ISC_R_SUCCESS) {
close(manager->epoll_fd);
@ -4453,7 +4364,6 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
sizeof(struct epoll_event) * manager->nevents);
return (result);
}
#endif /* USE_WATCHER_THREAD */
#elif defined(USE_DEVPOLL)
manager->nevents = ISC_SOCKET_MAXEVENTS;
result = isc_resource_getcurlimit(isc_resource_openfiles,
@ -4492,7 +4402,6 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
sizeof(pollinfo_t) * manager->maxsocks);
return (result);
}
#ifdef USE_WATCHER_THREAD
result = watch_fd(manager, manager->pipe_fds[0], SELECT_POKE_READ);
if (result != ISC_R_SUCCESS) {
close(manager->devpoll_fd);
@ -4502,7 +4411,6 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
sizeof(pollinfo_t) * manager->maxsocks);
return (result);
}
#endif /* USE_WATCHER_THREAD */
#elif defined(USE_SELECT)
UNUSED(result);
@ -4550,12 +4458,8 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
memset(manager->read_fds, 0, manager->fd_bufsize);
memset(manager->write_fds, 0, manager->fd_bufsize);
#ifdef USE_WATCHER_THREAD
(void)watch_fd(manager, manager->pipe_fds[0], SELECT_POKE_READ);
manager->maxfd = manager->pipe_fds[0];
#else /* USE_WATCHER_THREAD */
manager->maxfd = 0;
#endif /* USE_WATCHER_THREAD */
#endif /* USE_KQUEUE */
return (ISC_R_SUCCESS);
@ -4563,7 +4467,6 @@ setup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
static void
cleanup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
#ifdef USE_WATCHER_THREAD
isc_result_t result;
result = unwatch_fd(manager, manager->pipe_fds[0], SELECT_POKE_READ);
@ -4573,7 +4476,6 @@ cleanup_watcher(isc_mem_t *mctx, isc__socketmgr_t *manager) {
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_FAILED, "failed"));
}
#endif /* USE_WATCHER_THREAD */
#ifdef USE_KQUEUE
close(manager->kqueue_fd);
@ -4612,25 +4514,11 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
{
int i;
isc__socketmgr_t *manager;
#ifdef USE_WATCHER_THREAD
char strbuf[ISC_STRERRORSIZE];
#endif
isc_result_t result;
REQUIRE(managerp != NULL && *managerp == NULL);
#ifdef USE_SHARED_MANAGER
if (socketmgr != NULL) {
/* Don't allow maxsocks to be updated */
if (maxsocks > 0 && socketmgr->maxsocks != maxsocks)
return (ISC_R_EXISTS);
socketmgr->refs++;
*managerp = (isc_socketmgr_t *)socketmgr;
return (ISC_R_SUCCESS);
}
#endif /* USE_SHARED_MANAGER */
if (maxsocks == 0)
maxsocks = ISC_SOCKET_MAXSOCKETS;
@ -4691,7 +4579,6 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
}
}
#ifdef USE_WATCHER_THREAD
if (isc_condition_init(&manager->shutdown_ok) != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_condition_init() %s",
@ -4717,14 +4604,6 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
}
RUNTIME_CHECK(make_nonblock(manager->pipe_fds[0]) == ISC_R_SUCCESS);
#if 0
RUNTIME_CHECK(make_nonblock(manager->pipe_fds[1]) == ISC_R_SUCCESS);
#endif
#endif /* USE_WATCHER_THREAD */
#ifdef USE_SHARED_MANAGER
manager->refs = 1;
#endif /* USE_SHARED_MANAGER */
/*
* Set up initial state for the select loop
@ -4735,7 +4614,6 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
memset(manager->fdstate, 0, manager->maxsocks * sizeof(int));
#ifdef USE_WATCHER_THREAD
/*
* Start up the select/poll thread.
*/
@ -4750,26 +4628,18 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
goto cleanup;
}
isc_thread_setname(manager->watcher, "isc-socket");
#endif /* USE_WATCHER_THREAD */
isc_mem_attach(mctx, &manager->mctx);
#ifdef USE_SHARED_MANAGER
socketmgr = manager;
#endif /* USE_SHARED_MANAGER */
*managerp = (isc_socketmgr_t *)manager;
return (ISC_R_SUCCESS);
cleanup:
#ifdef USE_WATCHER_THREAD
(void)close(manager->pipe_fds[0]);
(void)close(manager->pipe_fds[1]);
#endif /* USE_WATCHER_THREAD */
#ifdef USE_WATCHER_THREAD
cleanup_condition:
(void)isc_condition_destroy(&manager->shutdown_ok);
#endif /* USE_WATCHER_THREAD */
cleanup_lock:
@ -4840,32 +4710,17 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
manager = (isc__socketmgr_t *)*managerp;
REQUIRE(VALID_MANAGER(manager));
#ifdef USE_SHARED_MANAGER
manager->refs--;
if (manager->refs > 0) {
*managerp = NULL;
return;
}
socketmgr = NULL;
#endif /* USE_SHARED_MANAGER */
LOCK(&manager->lock);
/*
* Wait for all sockets to be destroyed.
*/
while (!ISC_LIST_EMPTY(manager->socklist)) {
#ifdef USE_WATCHER_THREAD
manager_log(manager, CREATION, "%s",
isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET,
ISC_MSG_SOCKETSREMAIN,
"sockets exist"));
WAIT(&manager->shutdown_ok, &manager->lock);
#else /* USE_WATCHER_THREAD */
UNLOCK(&manager->lock);
isc__taskmgr_dispatch(NULL);
LOCK(&manager->lock);
#endif /* USE_WATCHER_THREAD */
}
UNLOCK(&manager->lock);
@ -4877,7 +4732,6 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
*/
select_poke(manager, 0, SELECT_POKE_SHUTDOWN);
#ifdef USE_WATCHER_THREAD
/*
* Wait for thread to exit.
*/
@ -4886,18 +4740,15 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
"isc_thread_join() %s",
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_FAILED, "failed"));
#endif /* USE_WATCHER_THREAD */
/*
* Clean up.
*/
cleanup_watcher(manager->mctx, manager);
#ifdef USE_WATCHER_THREAD
(void)close(manager->pipe_fds[0]);
(void)close(manager->pipe_fds[1]);
(void)isc_condition_destroy(&manager->shutdown_ok);
#endif /* USE_WATCHER_THREAD */
for (i = 0; i < (int)manager->maxsocks; i++)
if (manager->fdstate[i] == CLOSE_PENDING) /* no need to lock */
@ -4931,9 +4782,6 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
*managerp = NULL;
#ifdef USE_SHARED_MANAGER
socketmgr = NULL;
#endif
}
static isc_result_t
@ -6402,137 +6250,6 @@ isc_socket_socketevent(isc_mem_t *mctx, void *sender,
return (allocate_socketevent(mctx, sender, eventtype, action, arg));
}
#ifndef USE_WATCHER_THREAD
/*
* In our assumed scenario, we can simply use a single static object.
* XXX: this is not true if the application uses multiple threads with
* 'multi-context' mode. Fixing this is a future TODO item.
*/
static isc_socketwait_t swait_private;
int
isc__socketmgr_waitevents(isc_socketmgr_t *manager0, struct timeval *tvp,
isc_socketwait_t **swaitp)
{
isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
int n;
#ifdef USE_KQUEUE
struct timespec ts, *tsp;
#endif
#ifdef USE_EPOLL
int timeout;
#endif
#ifdef USE_DEVPOLL
isc_result_t result;
int pass;
struct dvpoll dvp;
#endif
REQUIRE(swaitp != NULL && *swaitp == NULL);
#ifdef USE_SHARED_MANAGER
if (manager == NULL)
manager = socketmgr;
#endif
if (manager == NULL)
return (0);
#ifdef USE_KQUEUE
if (tvp != NULL) {
ts.tv_sec = tvp->tv_sec;
ts.tv_nsec = tvp->tv_usec * 1000;
tsp = &ts;
} else
tsp = NULL;
swait_private.nevents = kevent(manager->kqueue_fd, NULL, 0,
manager->events, manager->nevents,
tsp);
n = swait_private.nevents;
#elif defined(USE_EPOLL)
if (tvp != NULL)
timeout = tvp->tv_sec * 1000 + (tvp->tv_usec + 999) / 1000;
else
timeout = -1;
swait_private.nevents = epoll_wait(manager->epoll_fd,
manager->events,
manager->nevents, timeout);
n = swait_private.nevents;
#elif defined(USE_DEVPOLL)
/*
* Re-probe every thousand calls.
*/
if (manager->calls++ > 1000U) {
result = isc_resource_getcurlimit(isc_resource_openfiles,
&manager->open_max);
if (result != ISC_R_SUCCESS)
manager->open_max = 64;
manager->calls = 0;
}
for (pass = 0; pass < 2; pass++) {
dvp.dp_fds = manager->events;
dvp.dp_nfds = manager->nevents;
if (dvp.dp_nfds >= manager->open_max)
dvp.dp_nfds = manager->open_max - 1;
if (tvp != NULL) {
dvp.dp_timeout = tvp->tv_sec * 1000 +
(tvp->tv_usec + 999) / 1000;
} else
dvp.dp_timeout = -1;
n = ioctl(manager->devpoll_fd, DP_POLL, &dvp);
if (n == -1 && errno == EINVAL) {
/*
* {OPEN_MAX} may have dropped. Look
* up the current value and try again.
*/
result = isc_resource_getcurlimit(
isc_resource_openfiles,
&manager->open_max);
if (result != ISC_R_SUCCESS)
manager->open_max = 64;
} else
break;
}
swait_private.nevents = n;
#elif defined(USE_SELECT)
memmove(manager->read_fds_copy, manager->read_fds, manager->fd_bufsize);
memmove(manager->write_fds_copy, manager->write_fds,
manager->fd_bufsize);
swait_private.readset = manager->read_fds_copy;
swait_private.writeset = manager->write_fds_copy;
swait_private.maxfd = manager->maxfd + 1;
n = select(swait_private.maxfd, swait_private.readset,
swait_private.writeset, NULL, tvp);
#endif
*swaitp = &swait_private;
return (n);
}
isc_result_t
isc__socketmgr_dispatch(isc_socketmgr_t *manager0, isc_socketwait_t *swait) {
isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0;
REQUIRE(swait == &swait_private);
#ifdef USE_SHARED_MANAGER
if (manager == NULL)
manager = socketmgr;
#endif
if (manager == NULL)
return (ISC_R_NOTFOUND);
#if defined(USE_KQUEUE) || defined(USE_EPOLL) || defined(USE_DEVPOLL)
(void)process_fds(manager, manager->events, swait->nevents);
return (ISC_R_SUCCESS);
#elif defined(USE_SELECT)
process_fds(manager, swait->maxfd, swait->readset, swait->writeset);
return (ISC_R_SUCCESS);
#endif
}
#endif /* USE_WATCHER_THREAD */
void
isc__socket_setname(isc_socket_t *socket0, const char *name, void *tag) {
isc__socket_t *sock = (isc__socket_t *)socket0;
@ -6605,12 +6322,6 @@ isc_socketmgr_renderxml(isc_socketmgr_t *mgr0, xmlTextWriterPtr writer) {
LOCK(&mgr->lock);
#ifdef USE_SHARED_MANAGER
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "references"));
TRY0(xmlTextWriterWriteFormatString(writer, "%d", mgr->refs));
TRY0(xmlTextWriterEndElement(writer));
#endif /* USE_SHARED_MANAGER */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "sockets"));
sock = ISC_LIST_HEAD(mgr->socklist);
while (sock != NULL) {
@ -6725,12 +6436,6 @@ isc_socketmgr_renderjson(isc_socketmgr_t *mgr0, json_object *stats) {
LOCK(&mgr->lock);
#ifdef USE_SHARED_MANAGER
obj = json_object_new_int(mgr->refs);
CHECKMEM(obj);
json_object_object_add(stats, "references", obj);
#endif /* USE_SHARED_MANAGER */
sock = ISC_LIST_HEAD(mgr->socklist);
while (sock != NULL) {
json_object *states, *entry = json_object_new_object();

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",

View file

@ -16,8 +16,6 @@
***** Platform-dependent defines.
*****/
#define ISC_PLATFORM_USETHREADS 1
/*
* Some compatibility cludges
*/

View file

@ -4016,12 +4016,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) {

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.

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)

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;
@ -65,10 +64,6 @@ 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));

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] */

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;

485
m4/ax_pthread.m4 Normal file
View file

@ -0,0 +1,485 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_pthread.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
#
# DESCRIPTION
#
# This macro figures out how to build C programs using POSIX threads. It
# sets the PTHREAD_LIBS output variable to the threads library and linker
# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
# flags that are needed. (The user can also force certain compiler
# flags/libs to be tested by setting these environment variables.)
#
# Also sets PTHREAD_CC to any special C compiler that is needed for
# multi-threaded programs (defaults to the value of CC otherwise). (This
# is necessary on AIX to use the special cc_r compiler alias.)
#
# NOTE: You are assumed to not only compile your program with these flags,
# but also to link with them as well. For example, you might link with
# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
#
# If you are only building threaded programs, you may wish to use these
# variables in your default LIBS, CFLAGS, and CC:
#
# LIBS="$PTHREAD_LIBS $LIBS"
# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# CC="$PTHREAD_CC"
#
# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to
# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
#
# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
# PTHREAD_CFLAGS.
#
# ACTION-IF-FOUND is a list of shell commands to run if a threads library
# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
# is not found. If ACTION-IF-FOUND is not specified, the default action
# will define HAVE_PTHREAD.
#
# Please let the authors know if this macro fails on any platform, or if
# you have any other suggestions or comments. This macro was based on work
# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
# Alejandro Forero Cuervo to the autoconf macro repository. We are also
# grateful for the helpful feedback of numerous users.
#
# Updated for Autoconf 2.68 by Daniel Richard G.
#
# LICENSE
#
# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 24
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_SED])
AC_LANG_PUSH([C])
ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on Tru64 or Sequent).
# It gets checked for in the link test anyway.
# First of all, check if the user has set any of the PTHREAD_LIBS,
# etcetera environment variables, and if threads linking works using
# them:
if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then
ax_pthread_save_CC="$CC"
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"])
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS])
AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes])
AC_MSG_RESULT([$ax_pthread_ok])
if test "x$ax_pthread_ok" = "xno"; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
CC="$ax_pthread_save_CC"
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
fi
# We must check for the threads library under a number of different
# names; the ordering is very important because some systems
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
# libraries is broken (non-POSIX).
# Create a list of thread flags to try. Items starting with a "-" are
# C compiler flags, and other items are library names, except for "none"
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# pthreads: AIX (must check this before -lpthread)
# none: in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64
# (Note: HP C rejects this with "bad form for `-t' option")
# -pthreads: Solaris/gcc (Note: HP C also rejects)
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads and
# -D_REENTRANT too), HP C (must be checked before -lpthread, which
# is present but should not be used directly; and before -mthreads,
# because the compiler interprets this as "-mt" + "-hreads")
# -mthreads: Mingw32/gcc, Lynx/gcc
# pthread: Linux, etcetera
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
case $host_os in
freebsd*)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
ax_pthread_flags="-kthread lthread $ax_pthread_flags"
;;
hpux*)
# From the cc(1) man page: "[-mt] Sets various -D flags to enable
# multi-threading and also sets -lpthread."
ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags"
;;
openedition*)
# IBM z/OS requires a feature-test macro to be defined in order to
# enable POSIX threads at all, so give the user a hint if this is
# not set. (We don't define these ourselves, as they can affect
# other portions of the system API in unpredictable ways.)
AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING],
[
# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)
AX_PTHREAD_ZOS_MISSING
# endif
],
[AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])])
;;
solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (N.B.: The stubs are missing
# pthread_cleanup_push, or rather a function called by this macro,
# so we could check for that, but who knows whether they'll stub
# that too in a future libc.) So we'll check first for the
# standard Solaris way of linking pthreads (-mt -lpthread).
ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags"
;;
esac
# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)
AS_IF([test "x$GCC" = "xyes"],
[ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"])
# The presence of a feature test macro requesting re-entrant function
# definitions is, on some systems, a strong hint that pthreads support is
# correctly enabled
case $host_os in
darwin* | hpux* | linux* | osf* | solaris*)
ax_pthread_check_macro="_REENTRANT"
;;
aix*)
ax_pthread_check_macro="_THREAD_SAFE"
;;
*)
ax_pthread_check_macro="--"
;;
esac
AS_IF([test "x$ax_pthread_check_macro" = "x--"],
[ax_pthread_check_cond=0],
[ax_pthread_check_cond="!defined($ax_pthread_check_macro)"])
# Are we compiling with Clang?
AC_CACHE_CHECK([whether $CC is Clang],
[ax_cv_PTHREAD_CLANG],
[ax_cv_PTHREAD_CLANG=no
# Note that Autoconf sets GCC=yes for Clang as well as GCC
if test "x$GCC" = "xyes"; then
AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG],
[/* Note: Clang 2.7 lacks __clang_[a-z]+__ */
# if defined(__clang__) && defined(__llvm__)
AX_PTHREAD_CC_IS_CLANG
# endif
],
[ax_cv_PTHREAD_CLANG=yes])
fi
])
ax_pthread_clang="$ax_cv_PTHREAD_CLANG"
ax_pthread_clang_warning=no
# Clang needs special handling, because older versions handle the -pthread
# option in a rather... idiosyncratic way
if test "x$ax_pthread_clang" = "xyes"; then
# Clang takes -pthread; it has never supported any other flag
# (Note 1: This will need to be revisited if a system that Clang
# supports has POSIX threads in a separate library. This tends not
# to be the way of modern systems, but it's conceivable.)
# (Note 2: On some systems, notably Darwin, -pthread is not needed
# to get POSIX threads support; the API is always present and
# active. We could reasonably leave PTHREAD_CFLAGS empty. But
# -pthread does define _REENTRANT, and while the Darwin headers
# ignore this macro, third-party headers might not.)
PTHREAD_CFLAGS="-pthread"
PTHREAD_LIBS=
ax_pthread_ok=yes
# However, older versions of Clang make a point of warning the user
# that, in an invocation where only linking and no compilation is
# taking place, the -pthread option has no effect ("argument unused
# during compilation"). They expect -pthread to be passed in only
# when source code is being compiled.
#
# Problem is, this is at odds with the way Automake and most other
# C build frameworks function, which is that the same flags used in
# compilation (CFLAGS) are also used in linking. Many systems
# supported by AX_PTHREAD require exactly this for POSIX threads
# support, and in fact it is often not straightforward to specify a
# flag that is used only in the compilation phase and not in
# linking. Such a scenario is extremely rare in practice.
#
# Even though use of the -pthread flag in linking would only print
# a warning, this can be a nuisance for well-run software projects
# that build with -Werror. So if the active version of Clang has
# this misfeature, we search for an option to squash it.
AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG],
[ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown
# Create an alternate version of $ac_link that compiles and
# links in two steps (.c -> .o, .o -> exe) instead of one
# (.c -> exe), because the warning occurs only in the second
# step
ax_pthread_save_ac_link="$ac_link"
ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g'
ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"`
ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)"
ax_pthread_save_CFLAGS="$CFLAGS"
for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do
AS_IF([test "x$ax_pthread_try" = "xunknown"], [break])
CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"
ac_link="$ax_pthread_save_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[ac_link="$ax_pthread_2step_ac_link"
AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])],
[break])
])
done
ac_link="$ax_pthread_save_ac_link"
CFLAGS="$ax_pthread_save_CFLAGS"
AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no])
ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"
])
case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in
no | unknown) ;;
*) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;;
esac
fi # $ax_pthread_clang = yes
if test "x$ax_pthread_ok" = "xno"; then
for ax_pthread_try_flag in $ax_pthread_flags; do
case $ax_pthread_try_flag in
none)
AC_MSG_CHECKING([whether pthreads work without any flags])
;;
-mt,pthread)
AC_MSG_CHECKING([whether pthreads work with -mt -lpthread])
PTHREAD_CFLAGS="-mt"
PTHREAD_LIBS="-lpthread"
;;
-*)
AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag])
PTHREAD_CFLAGS="$ax_pthread_try_flag"
;;
pthread-config)
AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
AS_IF([test "x$ax_pthread_config" = "xno"], [continue])
PTHREAD_CFLAGS="`pthread-config --cflags`"
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
*)
AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag])
PTHREAD_LIBS="-l$ax_pthread_try_flag"
;;
esac
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Check for various functions. We must include pthread.h,
# since some functions may be macros. (On the Sequent, we
# need a special flag -Kthread to make this header compile.)
# We check for pthread_join because it is in -lpthread on IRIX
# while pthread_create is in libc. We check for pthread_attr_init
# due to DEC craziness with -lpthreads. We check for
# pthread_cleanup_push because it is one of the few pthread
# functions on Solaris that doesn't have a non-functional libc stub.
# We try pthread_create on general principles.
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
# if $ax_pthread_check_cond
# error "$ax_pthread_check_macro must be defined"
# endif
static void routine(void *a) { a = 0; }
static void *start_routine(void *a) { return a; }],
[pthread_t th; pthread_attr_t attr;
pthread_create(&th, 0, start_routine, 0);
pthread_join(th, 0);
pthread_attr_init(&attr);
pthread_cleanup_push(routine, 0);
pthread_cleanup_pop(0) /* ; */])],
[ax_pthread_ok=yes],
[])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
AC_MSG_RESULT([$ax_pthread_ok])
AS_IF([test "x$ax_pthread_ok" = "xyes"], [break])
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
done
fi
# Various other checks:
if test "x$ax_pthread_ok" = "xyes"; then
ax_pthread_save_CFLAGS="$CFLAGS"
ax_pthread_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
LIBS="$PTHREAD_LIBS $LIBS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
AC_CACHE_CHECK([for joinable pthread attribute],
[ax_cv_PTHREAD_JOINABLE_ATTR],
[ax_cv_PTHREAD_JOINABLE_ATTR=unknown
for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
[int attr = $ax_pthread_attr; return attr /* ; */])],
[ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break],
[])
done
])
AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \
test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \
test "x$ax_pthread_joinable_attr_defined" != "xyes"],
[AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE],
[$ax_cv_PTHREAD_JOINABLE_ATTR],
[Define to necessary symbol if this constant
uses a non-standard name on your system.])
ax_pthread_joinable_attr_defined=yes
])
AC_CACHE_CHECK([whether more special flags are required for pthreads],
[ax_cv_PTHREAD_SPECIAL_FLAGS],
[ax_cv_PTHREAD_SPECIAL_FLAGS=no
case $host_os in
solaris*)
ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"
;;
esac
])
AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \
test "x$ax_pthread_special_flags_added" != "xyes"],
[PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"
ax_pthread_special_flags_added=yes])
AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
[ax_cv_PTHREAD_PRIO_INHERIT],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
[[int i = PTHREAD_PRIO_INHERIT;]])],
[ax_cv_PTHREAD_PRIO_INHERIT=yes],
[ax_cv_PTHREAD_PRIO_INHERIT=no])
])
AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \
test "x$ax_pthread_prio_inherit_defined" != "xyes"],
[AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])
ax_pthread_prio_inherit_defined=yes
])
CFLAGS="$ax_pthread_save_CFLAGS"
LIBS="$ax_pthread_save_LIBS"
# More AIX lossage: compile with *_r variant
if test "x$GCC" != "xyes"; then
case $host_os in
aix*)
AS_CASE(["x/$CC"],
[x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
[#handle absolute path differently from PATH based program lookup
AS_CASE(["x$CC"],
[x/*],
[AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
[AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
;;
esac
fi
fi
test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
AC_SUBST([PTHREAD_LIBS])
AC_SUBST([PTHREAD_CFLAGS])
AC_SUBST([PTHREAD_CC])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test "x$ax_pthread_ok" = "xyes"; then
ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
:
else
ax_pthread_ok=no
$2
fi
AC_LANG_POP
])dnl AX_PTHREAD

View file

@ -17,7 +17,7 @@ ISC_INCLUDES = @BIND9_ISC_BUILDINCLUDE@ \
-I${top_srcdir}/lib/isc \
-I${top_srcdir}/lib/isc/include \
-I${top_srcdir}/lib/isc/unix/include \
-I${top_srcdir}/lib/isc/@ISC_THREAD_DIR@/include \
-I${top_srcdir}/lib/isc/pthreads/include \
-I${top_srcdir}/lib/isc/@ISC_ARCH_DIR@/include
ISCCC_INCLUDES = @BIND9_ISCCC_BUILDINCLUDE@ \

View file

@ -3558,16 +3558,6 @@
./lib/isc/noatomic/include/isc/Makefile.in MAKE 2007,2012,2015,2016,2018
./lib/isc/noatomic/include/isc/atomic.h C 2005,2007,2016,2018
./lib/isc/nonce.c C 2018
./lib/isc/nothreads/Makefile.in MAKE 2000,2001,2004,2007,2009,2010,2012,2013,2016,2018
./lib/isc/nothreads/condition.c C 2000,2001,2004,2006,2007,2016,2018
./lib/isc/nothreads/include/Makefile.in MAKE 2000,2001,2004,2007,2012,2016,2018
./lib/isc/nothreads/include/isc/Makefile.in MAKE 2000,2001,2004,2007,2012,2015,2016,2018
./lib/isc/nothreads/include/isc/condition.h C 2000,2001,2004,2007,2016,2018
./lib/isc/nothreads/include/isc/mutex.h C 2000,2001,2004,2007,2015,2016,2018
./lib/isc/nothreads/include/isc/once.h C 2000,2001,2004,2007,2016,2018
./lib/isc/nothreads/include/isc/thread.h C 2000,2001,2004,2007,2013,2016,2017,2018
./lib/isc/nothreads/mutex.c C 2000,2001,2004,2006,2007,2016,2018
./lib/isc/nothreads/thread.c C 2000,2001,2004,2007,2016,2017,2018
./lib/isc/openssl_shim.c C 2018
./lib/isc/openssl_shim.h C 2018
./lib/isc/parseint.c C 2001,2002,2003,2004,2005,2007,2012,2016,2018
@ -3914,6 +3904,7 @@
./lib/win32/bindevt/bindevt.vcxproj.user X 2013,2018
./ltmain.sh X 1999,2000,2001,2003,2004,2006,2009,2012,2018
./m4/ax_check_openssl.m4 X 2018
./m4/ax_pthread.m4 X 2018
./m4/libtool.m4 X 2012,2018
./m4/ltoptions.m4 X 2012,2018
./m4/ltsugar.m4 X 2012,2018