ITS#8614 - slapd must be built threaded

This commit is contained in:
Quanah Gibson-Mount 2020-05-04 23:37:17 +00:00
parent 9282e6edea
commit c91bbe6eea
11 changed files with 32 additions and 106 deletions

View 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

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

View 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 },

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

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

View 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

View 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)"

View File

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

View File

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

View File

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

View File

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