From a5c0b593987c92ab2b5f8b90abc8cf887539f16d Mon Sep 17 00:00:00 2001 From: Ryan Tandy Date: Sat, 16 May 2020 09:35:12 -0700 Subject: [PATCH] ITS#9235 Define LDAP_R_COMPILE iff building with threads --- configure.in | 4 +- libraries/libldap/Makefile.in | 6 +- libraries/libldap/ldap-int.h | 3 +- libraries/libldap/ldap_thr_debug.h | 2 +- libraries/libldap/thr_stub.c | 323 ----------------------------- 5 files changed, 8 insertions(+), 330 deletions(-) delete mode 100644 libraries/libldap/thr_stub.c diff --git a/configure.in b/configure.in index fbbeaa67ee..7c2469aaf0 100644 --- a/configure.in +++ b/configure.in @@ -1699,9 +1699,9 @@ dnl #ifdef LDAP_R_COMPILE dnl # include dnl #endif dnl -dnl LDAP_R_COMPILE is defined by libldap_r/Makefile.in +dnl LDAP_R_COMPILE is defined by libldap/ldap-int.h dnl specifically for compiling the threadsafe version of -dnl the ldap library (-lldap_r). +dnl the ldap library. dnl dnl dnl check for reentrant/threadsafe functions dnl dnl diff --git a/libraries/libldap/Makefile.in b/libraries/libldap/Makefile.in index 716869c58b..c7a6a97e74 100644 --- a/libraries/libldap/Makefile.in +++ b/libraries/libldap/Makefile.in @@ -30,7 +30,7 @@ SRCS = bind.c open.c result.c error.c compare.c search.c \ turn.c ppolicy.c dds.c txn.c ldap_sync.c stctrl.c \ assertion.c deref.c ldifutil.c ldif.c fetch.c lbase64.c \ msctrl.c psearchctrl.c threads.c rdwr.c tpool.c rq.c \ - thr_posix.c thr_thr.c thr_nt.c thr_pth.c thr_stub.c thr_debug.c + thr_posix.c thr_thr.c thr_nt.c thr_pth.c thr_debug.c OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ controls.lo messages.lo references.lo extended.lo cyrus.lo \ @@ -45,12 +45,12 @@ OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \ turn.lo ppolicy.lo dds.lo txn.lo ldap_sync.lo stctrl.lo \ assertion.lo deref.lo ldifutil.lo ldif.lo fetch.lo lbase64.lo \ msctrl.lo psearchctrl.lo threads.lo rdwr.lo tpool.lo rq.lo \ - thr_posix.lo thr_thr.lo thr_nt.lo thr_pth.lo thr_stub.lo thr_debug.lo + thr_posix.lo thr_thr.lo thr_nt.lo thr_pth.lo thr_debug.lo LDAP_INCDIR= ../../include LDAP_LIBDIR= ../../libraries -LIB_DEFS = -DLDAP_LIBRARY -DLDAP_R_COMPILE +LIB_DEFS = -DLDAP_LIBRARY XLIBS = $(LIBRARY) $(LDAP_LIBLBER_LA) $(LDAP_LIBLUTIL_A) XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS) diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index 3364481159..b0f412877f 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -20,7 +20,8 @@ #ifndef _LDAP_INT_H #define _LDAP_INT_H 1 -#ifdef LDAP_R_COMPILE +#ifndef NO_THREADS +#define LDAP_R_COMPILE 1 #define LDAP_THREAD_SAFE 1 #endif diff --git a/libraries/libldap/ldap_thr_debug.h b/libraries/libldap/ldap_thr_debug.h index 9b72f71ce0..dd47986030 100644 --- a/libraries/libldap/ldap_thr_debug.h +++ b/libraries/libldap/ldap_thr_debug.h @@ -107,7 +107,7 @@ #define ldap_pvt_thread_rdwr_active ldap_int_thread_rdwr_active #endif /* LDAP_THREAD_RDWR_IMPLEMENTATION */ -#ifdef LDAP_THREAD_POOL_IMPLEMENTATION /* tpool.c, thr_stub.c, thr_debug.c */ +#ifdef LDAP_THREAD_POOL_IMPLEMENTATION /* tpool.c, thr_debug.c */ #ifdef LDAP_THREAD_DEBUG_WRAP /* see ldap_pvt_thread.h */ #define ldap_pvt_thread_pool_t ldap_int_thread_pool_t #endif diff --git a/libraries/libldap/thr_stub.c b/libraries/libldap/thr_stub.c deleted file mode 100644 index 7eb9407c20..0000000000 --- a/libraries/libldap/thr_stub.c +++ /dev/null @@ -1,323 +0,0 @@ -/* thr_stub.c - stubs for the threads */ -/* $OpenLDAP$ */ -/* This work is part of OpenLDAP Software . - * - * Copyright 1998-2020 The OpenLDAP Foundation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted only as authorized by the OpenLDAP - * Public License. - * - * A copy of this license is available in file LICENSE in the - * top-level directory of the distribution or, alternatively, at - * . - */ - -#include "portable.h" - -#if defined( NO_THREADS ) - -#include "ldap_pvt_thread.h" /* Get the thread interface */ -#define LDAP_THREAD_IMPLEMENTATION -#define LDAP_THREAD_POOL_IMPLEMENTATION -#include "ldap_thr_debug.h" /* May rename the symbols defined below */ - -/*********************************************************************** - * * - * no threads package defined for this system - fake ok returns from * - * all threads routines (making it single-threaded). * - * * - ***********************************************************************/ - -int -ldap_int_thread_initialize( void ) -{ - return 0; -} - -int -ldap_int_thread_destroy( void ) -{ - return 0; -} - -static void* ldap_int_status = NULL; - -int -ldap_pvt_thread_create( ldap_pvt_thread_t * thread, - int detach, - void *(*start_routine)(void *), - void *arg) -{ - if( ! detach ) ldap_int_status = NULL; - start_routine( arg ); - return 0; -} - -void -ldap_pvt_thread_exit( void *retval ) -{ - if( retval != NULL ) { - ldap_int_status = retval; - } - return; -} - -int -ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status ) -{ - if(status != NULL) *status = ldap_int_status; - return 0; -} - -int -ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo ) -{ - return 0; -} - -int -ldap_pvt_thread_yield( void ) -{ - return 0; -} - -int -ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond ) -{ - return 0; -} - -int -ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond ) -{ - return 0; -} - -int -ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond ) -{ - return 0; -} - -int -ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond ) -{ - return 0; -} - -int -ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, - ldap_pvt_thread_mutex_t *mutex ) -{ - return 0; -} - -int -ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex ) -{ - return 0; -} - -int -ldap_pvt_thread_mutex_recursive_init( ldap_pvt_thread_mutex_t *mutex ) -{ - return 0; -} - -int -ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex ) -{ - return 0; -} - -int -ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex ) -{ - return 0; -} - -int -ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex ) -{ - return 0; -} - -int -ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex ) -{ - return 0; -} - -/* - * NO_THREADS requires a separate tpool implementation since - * generic ldap_pvt_thread_pool_wrapper loops forever. - */ -int -ldap_pvt_thread_pool_init ( - ldap_pvt_thread_pool_t *pool_out, - int max_concurrency, int max_pending ) -{ - *pool_out = (ldap_pvt_thread_pool_t) 0; - return(0); -} - -int -ldap_pvt_thread_pool_submit ( - ldap_pvt_thread_pool_t *pool, - ldap_pvt_thread_start_t *start_routine, void *arg ) -{ - (start_routine)(NULL, arg); - return(0); -} - -int -ldap_pvt_thread_pool_retract ( - void *cookie ) -{ - return(0); -} - -int -ldap_pvt_thread_pool_maxthreads ( ldap_pvt_thread_pool_t *tpool, int max_threads ) -{ - return(0); -} - -int -ldap_pvt_thread_pool_query( ldap_pvt_thread_pool_t *tpool, - ldap_pvt_thread_pool_param_t param, void *value ) -{ - *(int *)value = -1; - return(-1); -} - -int -ldap_pvt_thread_pool_backload ( - ldap_pvt_thread_pool_t *pool ) -{ - return(0); -} - -int -ldap_pvt_thread_pool_destroy ( - ldap_pvt_thread_pool_t *pool, int run_pending ) -{ - return(0); -} - -int -ldap_pvt_thread_pool_close ( - ldap_pvt_thread_pool_t *pool, int run_pending ) -{ - return(0); -} - -int -ldap_pvt_thread_pool_free ( ldap_pvt_thread_pool_t *pool ) -{ - return(0); -} - -void -ldap_pvt_thread_pool_idle ( ldap_pvt_thread_pool_t *pool ) -{ - return; -} - -void -ldap_pvt_thread_pool_unidle ( ldap_pvt_thread_pool_t *pool ) -{ - return; -} - -int ldap_pvt_thread_pool_getkey ( - void *ctx, void *key, void **data, ldap_pvt_thread_pool_keyfree_t **kfree ) -{ - return(0); -} - -int ldap_pvt_thread_pool_setkey ( - void *ctx, void *key, - void *data, ldap_pvt_thread_pool_keyfree_t *kfree, - void **olddatap, ldap_pvt_thread_pool_keyfree_t **oldkfreep ) -{ - if ( olddatap ) *olddatap = NULL; - if ( oldkfreep ) *oldkfreep = 0; - return(0); -} - -void ldap_pvt_thread_pool_purgekey( void *key ) -{ -} - -int ldap_pvt_thread_pool_pause ( - ldap_pvt_thread_pool_t *tpool ) -{ - return(0); -} - -int ldap_pvt_thread_pool_resume ( - ldap_pvt_thread_pool_t *tpool ) -{ - return(0); -} - -int ldap_pvt_thread_pool_pausing( ldap_pvt_thread_pool_t *tpool ) -{ - return(0); -} - -ldap_pvt_thread_pool_pausecheck( ldap_pvt_thread_pool_t *tpool ) -{ - return(0); -} - -void *ldap_pvt_thread_pool_context( ) -{ - return(NULL); -} - -void ldap_pvt_thread_pool_context_reset( void *vctx ) -{ -} - -ldap_pvt_thread_t -ldap_pvt_thread_self( void ) -{ - return(0); -} - -int -ldap_pvt_thread_key_create( ldap_pvt_thread_key_t *key ) -{ - return(0); -} - -int -ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key ) -{ - return(0); -} - -int -ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key, void *data ) -{ - return(0); -} - -int -ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key, void **data ) -{ - return(0); -} - -ldap_pvt_thread_t -ldap_pvt_thread_pool_tid( void *vctx ) -{ - - return(0); -} - -#endif /* NO_THREADS */