From c91bbe6eeabdd6856a4e7a827e8baf47bd87add6 Mon Sep 17 00:00:00 2001 From: Quanah Gibson-Mount Date: Mon, 4 May 2020 23:37:17 +0000 Subject: [PATCH] ITS#8614 - slapd must be built threaded --- configure.in | 16 +++--- servers/slapd/back-monitor/thread.c | 6 --- servers/slapd/bconfig.c | 12 ----- servers/slapd/connection.c | 7 --- servers/slapd/daemon.c | 12 +---- servers/slapd/sl_malloc.c | 9 +--- tests/run.in | 3 +- tests/scripts/defines.sh | 1 - tests/scripts/test028-idassert | 5 -- tests/scripts/test030-relay | 62 ++++++++--------------- tests/scripts/test048-syncrepl-multiproxy | 5 -- 11 files changed, 32 insertions(+), 106 deletions(-) diff --git a/configure.in b/configure.in index ac367b91e9..d491e70670 100644 --- a/configure.in +++ b/configure.in @@ -1680,13 +1680,9 @@ dnl When in thread environment, use dnl #if defined( HAVE_REENTRANT_FUNCTIONS ) || defined( HAVE_FUNC_R ) dnl func_r(...); dnl #else -dnl # if defined( HAVE_THREADS ) -dnl /* lock */ -dnl # endif -dnl func(...); -dnl # if defined( HAVE_THREADS ) -dnl /* unlock */ -dnl # endif +dnl /* lock */ +dnl func(...); +dnl /* unlock */ dnl #endif dnl dnl HAVE_REENTRANT_FUNCTIONS is derived from: @@ -1696,8 +1692,6 @@ dnl _POSIX_THREADSAFE_FUNCTIONS dnl dnl and is currently defined in dnl -dnl HAVE_THREADS is defined by iff -UNO_THREADS -dnl dnl libldap/*.c should only include iff dnl LDAP_R_COMPILE is defined. ie: dnl #ifdef LDAP_R_COMPILE @@ -1728,6 +1722,10 @@ dnl LIBS="$save_LIBS" fi if test $ol_link_threads = no ; then + if test $ol_enable_slapd != no; then + AC_MSG_ERROR([slapd requires thread support]) + fi + if test $ol_with_threads = yes ; then AC_MSG_ERROR([no suitable thread support]) fi diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index a0802f7e24..561983e984 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -29,7 +29,6 @@ #include -#ifndef NO_THREADS typedef enum { MT_UNKNOWN, MT_RUNQUEUE, @@ -96,7 +95,6 @@ monitor_subsys_thread_update( Operation *op, SlapReply *rs, Entry *e ); -#endif /* ! NO_THREADS */ /* * initializes log subentry @@ -106,7 +104,6 @@ monitor_subsys_thread_init( BackendDB *be, monitor_subsys_t *ms ) { -#ifndef NO_THREADS monitor_info_t *mi; monitor_entry_t *mp; Entry *e, **ep, *e_thread; @@ -210,11 +207,9 @@ monitor_subsys_thread_init( monitor_cache_release( mi, e_thread ); -#endif /* ! NO_THREADS */ return( 0 ); } -#ifndef NO_THREADS static int monitor_subsys_thread_update( Operation *op, @@ -354,4 +349,3 @@ monitor_subsys_thread_update( return SLAP_CB_CONTINUE; } -#endif /* ! NO_THREADS */ diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 4c90715be5..30d8ead205 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -453,11 +453,7 @@ static ConfigTable config_back_cf_table[] = { "EQUALITY caseIgnoreMatch " "SYNTAX OMsDirectoryString X-ORDERED 'VALUES' )", NULL, NULL }, { "listener-threads", "count", 2, 0, 0, -#ifdef NO_THREADS - ARG_IGNORED, NULL, -#else ARG_UINT|ARG_MAGIC|CFG_LTHREADS, &config_generic, -#endif "( OLcfgGlAt:93 NAME 'olcListenerThreads' " "EQUALITY integerMatch " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, @@ -727,20 +723,12 @@ static ConfigTable config_back_cf_table[] = { "DESC 'Custom TCP buffer size' " "SYNTAX OMsDirectoryString )", NULL, NULL }, { "threads", "count", 2, 2, 0, -#ifdef NO_THREADS - ARG_IGNORED, NULL, -#else ARG_INT|ARG_MAGIC|CFG_THREADS, &config_generic, -#endif "( OLcfgGlAt:66 NAME 'olcThreads' " "EQUALITY integerMatch " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, { "threadqueues", "count", 2, 2, 0, -#ifdef NO_THREADS - ARG_IGNORED, NULL, -#else ARG_INT|ARG_MAGIC|CFG_THREADQS, &config_generic, -#endif "( OLcfgGlAt:95 NAME 'olcThreadQueues' " "EQUALITY integerMatch " "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL }, diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 6d9bb8e853..8d62d28fd9 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -1772,13 +1772,6 @@ connection_input( Connection *conn , conn_readinfo *cri ) } } -#ifdef NO_THREADS - if ( conn->c_struct_state != SLAP_C_USED ) { - /* connection must have got closed underneath us */ - return 1; - } -#endif - assert( conn->c_struct_state == SLAP_C_USED ); return rc; } diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index e8660387ef..050a62ce3e 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -107,19 +107,11 @@ static ldap_pvt_thread_mutex_t emfile_mutex; static int emfile; static volatile int waking; -#ifdef NO_THREADS -#define WAKE_LISTENER(l,w) do { \ - if ((w) && ++waking < 5) { \ - tcp_write( SLAP_FD2SOCK(wake_sds[l][1]), "0", 1 ); \ - } \ -} while (0) -#else /* ! NO_THREADS */ #define WAKE_LISTENER(l,w) do { \ if (w) { \ tcp_write( SLAP_FD2SOCK(wake_sds[l][1]), "0", 1 ); \ } \ } while (0) -#endif /* ! NO_THREADS */ volatile sig_atomic_t slapd_shutdown = 0; volatile sig_atomic_t slapd_gentle_shutdown = 0; @@ -2738,9 +2730,9 @@ loop: ldap_pvt_thread_mutex_unlock( &slap_daemon[tid].sd_mutex ); if ( at -#if defined(HAVE_YIELDING_SELECT) || defined(NO_THREADS) +#if defined(HAVE_YIELDING_SELECT) && ( tv.tv_sec || tv.tv_usec ) -#endif /* HAVE_YIELDING_SELECT || NO_THREADS */ +#endif /* HAVE_YIELDING_SELECT */ ) { tvp = &tv; diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index a631341f19..c89a33fd6c 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -110,12 +110,7 @@ static struct slab_object * slap_replenish_sopool(struct slab_heap* sh); static void print_slheap(int level, void *ctx); #endif -/* Keep memory context in a thread-local var, or in a global when no threads */ -#ifdef NO_THREADS -static struct slab_heap *slheap; -# define SET_MEMCTX(thrctx, memctx, sfree) ((void) (slheap = (memctx))) -# define GET_MEMCTX(thrctx, memctxp) (*(memctxp) = slheap) -#else +/* Keep memory context in a thread-local var */ # define memctx_key ((void *) slap_sl_mem_init) # define SET_MEMCTX(thrctx, memctx, kfree) \ ldap_pvt_thread_pool_setkey(thrctx,memctx_key, memctx,kfree, NULL,NULL) @@ -123,8 +118,6 @@ static struct slab_heap *slheap; ((void) (*(memctxp) = NULL), \ (void) ldap_pvt_thread_pool_getkey(thrctx,memctx_key, memctxp,NULL), \ *(memctxp)) -#endif /* NO_THREADS */ - /* Destroy the context, or if key==NULL clean it up for reuse. */ void diff --git a/tests/run.in b/tests/run.in index 249504051d..66f18c42aa 100644 --- a/tests/run.in +++ b/tests/run.in @@ -60,7 +60,6 @@ AC_WITH_TLS=@WITH_TLS@ AC_TLS_TYPE=@WITH_TLS_TYPE@ AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@ AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@ -AC_THREADS=threads@BUILD_THREAD@ AC_LIBS_DYNAMIC=lib@BUILD_LIBS_DYNAMIC@ # sanitize @@ -78,7 +77,7 @@ export AC_ldap AC_mdb AC_meta AC_asyncmeta AC_monitor AC_null AC_perl AC_relay A AC_refint AC_retcode AC_rwm AC_unique AC_syncprov AC_translucent \ AC_valsort \ AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \ - AC_THREADS AC_LIBS_DYNAMIC AC_WITH_TLS AC_TLS_TYPE + AC_LIBS_DYNAMIC AC_WITH_TLS AC_TLS_TYPE if test ! -x ../servers/slapd/slapd ; then echo "Could not locate slapd(8)" diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh index a84fd0a655..a6a916bda7 100755 --- a/tests/scripts/defines.sh +++ b/tests/scripts/defines.sh @@ -52,7 +52,6 @@ WITH_TLS=${AC_WITH_TLS-no} WITH_TLS_TYPE=${AC_TLS_TYPE-no} ACI=${AC_ACI_ENABLED-acino} -THREADS=${AC_THREADS-threadsno} SLEEP0=${SLEEP0-1} SLEEP1=${SLEEP1-7} SLEEP2=${SLEEP2-15} diff --git a/tests/scripts/test028-idassert b/tests/scripts/test028-idassert index 252650dfa5..ba5e32bba3 100755 --- a/tests/scripts/test028-idassert +++ b/tests/scripts/test028-idassert @@ -32,11 +32,6 @@ if test $RWM = "rwmno" ; then exit 0 fi -if test $THREADS = "threadsno" ; then - echo "Need threads support, test skipped" - exit 0 -fi - if test $WITH_SASL = "yes" ; then if test $USE_SASL != "no" ; then if test $USE_SASL = "yes" ; then diff --git a/tests/scripts/test030-relay b/tests/scripts/test030-relay index 53ee844618..db5043d560 100755 --- a/tests/scripts/test030-relay +++ b/tests/scripts/test030-relay @@ -39,28 +39,20 @@ if test "x$RELAYS" = "x" ; then if test $BACKLDAP = ldapno ; then echo "ldap backend not available, test skipped" else - if test $THREADS = "threadsno" ; then - echo "Need threads support, test skipped" - else - if test "x$RELAYS" != "x" ; then - RELAYS="${RELAYS} " - fi - RELAYS="${RELAYS}ldap" - fi + if test "x$RELAYS" != "x" ; then + RELAYS="${RELAYS} " + fi + RELAYS="${RELAYS}ldap" fi # back-meta if test $BACKMETA = metano ; then echo "meta backend not available, test skipped" else - if test $THREADS = "threadsno" ; then - echo "Need threads support, test skipped" - else - if test "x$RELAYS" != "x" ; then - RELAYS="${RELAYS} " - fi - RELAYS="${RELAYS}meta" + if test "x$RELAYS" != "x" ; then + RELAYS="${RELAYS} " fi + RELAYS="${RELAYS}meta" fi fi @@ -79,36 +71,24 @@ if test -f $tmpfile ; then fi first=1 for RELAY in $RELAYS ; do - RUNIT=yes - if test $THREADS = "threadsno" ; then - case $RELAY in - ldap|meta) - echo "Need threads support, test skipped" - RUNIT=no - ;; - esac + if test $first = 1 ; then + first=0 + else + echo ">>>>> waiting for things to exit" + test $KILLSERVERS != no && wait + echo "" + + mv -f $LOG1 $tmpfile + rm -rf $TESTDIR fi - - if test $RUNIT = yes ; then - if test $first = 1 ; then - first=0 - else - echo ">>>>> waiting for things to exit" - test $KILLSERVERS != no && wait - echo "" - mv -f $LOG1 $tmpfile - rm -rf $TESTDIR - fi + mkdir -p $TESTDIR $DBDIR1 - mkdir -p $TESTDIR $DBDIR1 - - if test -f $tmpfile ; then - mv $tmpfile $LOG1 - fi - - . $SRCDIR/scripts/relay + if test -f $tmpfile ; then + mv $tmpfile $LOG1 fi + + . $SRCDIR/scripts/relay done echo ">>>>> Test succeeded" diff --git a/tests/scripts/test048-syncrepl-multiproxy b/tests/scripts/test048-syncrepl-multiproxy index 83b2efd8fd..317d3d2f85 100755 --- a/tests/scripts/test048-syncrepl-multiproxy +++ b/tests/scripts/test048-syncrepl-multiproxy @@ -31,11 +31,6 @@ if test $MONITORDB = no; then exit 0 fi -if test $THREADS = threadsno ; then - echo "Need threads support, test skipped" - exit 0 -fi - mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $DBDIR3 #