]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#8614 - slapd must be built threaded
authorQuanah Gibson-Mount <quanah@openldap.org>
Mon, 4 May 2020 23:37:17 +0000 (23:37 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 14 May 2020 16:30:17 +0000 (16:30 +0000)
configure.in
servers/slapd/back-monitor/thread.c
servers/slapd/bconfig.c
servers/slapd/connection.c
servers/slapd/daemon.c
servers/slapd/sl_malloc.c
tests/run.in
tests/scripts/defines.sh
tests/scripts/test028-idassert
tests/scripts/test030-relay
tests/scripts/test048-syncrepl-multiproxy

index ac367b91e9c6fc6529d32b84319b17677706e153..d491e70670048cb080e0e996d172cd27960e4328 100644 (file)
@@ -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 <ldap_pvt_thread.h>
 dnl
-dnl HAVE_THREADS is defined by <ldap_pvt_thread.h> iff -UNO_THREADS
-dnl 
 dnl libldap/*.c should only include <ldap_pvt_thread.h> 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
index a0802f7e24dce295f893d13e55af790e0428aea4..561983e984c094719985c9e79822a09c8b3cf5cd 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <ldap_rq.h>
 
-#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 */
index 4c90715be58c88b414387b1bfd163cad6485915a..30d8ead205d116a28cacce0969036c4ddcb732ea 100644 (file)
@@ -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 },
index 6d9bb8e8538bd87353c3b63fff8c65bf5298f500..8d62d28fd95cf32b0f3ee17f43bbb1cc02eeb689 100644 (file)
@@ -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;
 }
index e8660387ef32830b16f2ee008f8776b579cb821b..050a62ce3ef29dc0feae4ad01e4ec19d8af4a05d 100644 (file)
@@ -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;
index a631341f1936884af74cef837c9a3b0b7a79fd74..c89a33fd6cfd51a817c84b3df2e99b42da454a49 100644 (file)
@@ -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
index 249504051de2d8e75e62ea4c7e895bc45c083068..66f18c42aae08a02c90f93065642d85075226cb4 100644 (file)
@@ -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)"
index a84fd0a655c9bfbfe8ec6d9b2a551b4c08a1dc03..a6a916bda7690a7c84cc59dbc278f46f6f7d49c3 100755 (executable)
@@ -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}
index 252650dfa536e3d6bdb33e49d1d57bae9cb2073e..ba5e32bba3472392f64860250d4d7f73b0cb0807 100755 (executable)
@@ -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
index 53ee8446186902e2be8c9318778914536812ecb4..db5043d560262de7f4604324be803833670175e8 100755 (executable)
@@ -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"
index 83b2efd8fd07b776e20a43f872cb4967b1757db0..317d3d2f85457a9d7c7979bc8268bb596891ebea 100755 (executable)
@@ -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
 
 #