From 7b6facefae6a07618c0ad0573cb78413d39f9102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Kr=C4=99cicki?= Date: Tue, 18 Feb 2020 13:52:07 +0100 Subject: [PATCH] use pthread rwlock by default --- configure | 31 ++++++++++++++++++++++--------- configure.ac | 6 +++--- lib/dns/badcache.c | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/configure b/configure index 97756f150d..f25abad1ba 100755 --- a/configure +++ b/configure @@ -852,6 +852,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -1025,6 +1026,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1277,6 +1279,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1414,7 +1425,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1567,6 +1578,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1625,8 +1637,9 @@ Optional Features: --enable-devpoll use /dev/poll when available [default=yes] --disable-geoip support GeoIP2 geolocation ACLs if available [default=yes] - --enable-pthread-rwlock use pthread rwlock instead of internal rwlock - implementation (EXPERIMENTAL) + --disable-pthread-rwlock + use internal rwlock implementation instead of + pthread --enable-fips-mode enable FIPS mode in OpenSSL library [default=no] --enable-native-pkcs11 use native PKCS11 for public-key crypto [default=no] --enable-backtrace log stack backtrace on abort [default=yes] @@ -4011,7 +4024,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4057,7 +4070,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4081,7 +4094,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4126,7 +4139,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4150,7 +4163,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -16046,7 +16059,7 @@ esac if test "${enable_pthread_rwlock+set}" = set; then : enableval=$enable_pthread_rwlock; else - enable_pthread_rwlock=no + enable_pthread_rwlock=yes fi diff --git a/configure.ac b/configure.ac index 4ed0ac2d3e..1982834801 100644 --- a/configure.ac +++ b/configure.ac @@ -719,9 +719,9 @@ AC_SUBST(INSTALL_LIBRARY) # Do we want to use pthread rwlock? (useful for ThreadSanitizer) # AC_ARG_ENABLE([pthread_rwlock], - [AS_HELP_STRING([--enable-pthread-rwlock], - [use pthread rwlock instead of internal rwlock implementation (EXPERIMENTAL)])], - [], [enable_pthread_rwlock=no]) + [AS_HELP_STRING([--disable-pthread-rwlock], + [use internal rwlock implementation instead of pthread])], + [], [enable_pthread_rwlock=yes]) AS_IF([test "$enable_pthread_rwlock" = "yes"], [AC_CHECK_FUNCS([pthread_rwlock_rdlock], [], diff --git a/lib/dns/badcache.c b/lib/dns/badcache.c index 4079ad8097..3e1e3a5735 100644 --- a/lib/dns/badcache.c +++ b/lib/dns/badcache.c @@ -328,8 +328,8 @@ skip: * Slow sweep to clean out stale records. */ i = atomic_fetch_add(&bc->sweep, 1) % bc->size; - bad = bc->table[i]; if (isc_mutex_trylock(&bc->tlocks[i]) == ISC_R_SUCCESS) { + bad = bc->table[i]; if (bad != NULL && isc_time_compare(&bad->expire, now) < 0) { bc->table[i] = bad->next; isc_mem_put(bc->mctx, bad,