mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-09 02:52:04 +08:00
Rework libldap to not attempt to set LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
This commit is contained in:
parent
daf7d0c0eb
commit
73b4170a6c
78
configure.in
78
configure.in
@ -1313,47 +1313,6 @@ if test $ol_enable_lmpasswd != no; then
|
||||
AC_DEFINE(SLAPD_LMHASH, 1, [define to support LAN Manager passwords])
|
||||
fi
|
||||
|
||||
dnl ----------------------------------------------------------------
|
||||
dnl Tests for reentrant functions necessary to build a
|
||||
dnl thread_safe -lldap.
|
||||
AC_CHECK_FUNCS( \
|
||||
ctime_r \
|
||||
gethostbyname_r gethostbyaddr_r \
|
||||
)
|
||||
|
||||
if test "$ac_cv_func_ctime_r" = no ; then
|
||||
ol_cv_func_ctime_r_nargs=0
|
||||
else
|
||||
OL_FUNC_CTIME_R_NARGS
|
||||
dnl OL_FUNC_CTIME_R_TYPE
|
||||
fi
|
||||
|
||||
if test "$ac_cv_func_gethostbyname_r" = yes ; then
|
||||
OL_FUNC_GETHOSTBYNAME_R_NARGS
|
||||
else
|
||||
ol_cv_func_gethostbyname_r_nargs=0
|
||||
fi
|
||||
|
||||
if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
|
||||
OL_FUNC_GETHOSTBYADDR_R_NARGS
|
||||
else
|
||||
ol_cv_func_gethostbyaddr_r_nargs=0
|
||||
fi
|
||||
|
||||
if test "$ac_cv_func_ctime_r" = yes \
|
||||
-a "$ol_cv_func_ctime_r_nargs" -ge 2 \
|
||||
-a "$ol_cv_func_ctime_r_nargs" -le 3 \
|
||||
-a "$ac_cv_func_gethostbyname_r" = yes \
|
||||
-a "$ol_cv_func_gethostbyname_r_nargs" -ge 5 \
|
||||
-a "$ol_cv_func_gethostbyname_r_nargs" -le 6 \
|
||||
-a "$ac_cv_func_gethostbyaddr_r" = yes \
|
||||
-a "$ol_cv_func_gethostbyaddr_r_nargs" -ge 5 \
|
||||
-a "$ol_cv_func_gethostbyaddr_r_nargs" -le 6 \
|
||||
; then
|
||||
|
||||
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT,1)
|
||||
fi
|
||||
|
||||
dnl ----------------------------------------------------------------
|
||||
dnl Threads?
|
||||
ol_link_threads=no
|
||||
@ -1854,8 +1813,7 @@ if test $ol_link_threads != no -a $ol_link_threads != nt ; then
|
||||
fi
|
||||
|
||||
dnl When in thread environment, use
|
||||
dnl #if defined( HAVE_REENTRANT_FUNCTIONS ) \
|
||||
dnl || defined( HAVE_FUNC_R )
|
||||
dnl #if defined( HAVE_REENTRANT_FUNCTIONS ) || defined( HAVE_FUNC_R )
|
||||
dnl func_r(...);
|
||||
dnl #else
|
||||
dnl # if defined( HAVE_THREADS )
|
||||
@ -1872,14 +1830,14 @@ dnl _POSIX_REENTRANT_FUNCTIONS
|
||||
dnl _POSIX_THREAD_SAFE_FUNCTIONS
|
||||
dnl _POSIX_THREADSAFE_FUNCTIONS
|
||||
dnl
|
||||
dnl and is currently defined in lthread.h
|
||||
dnl and is currently defined in <ldap_pvt_thread.h>
|
||||
dnl
|
||||
dnl HAVE_THREADS is defined by lthread.h iff -UNO_THREADS
|
||||
dnl HAVE_THREADS is defined by <ldap_pvt_thread.h> iff -UNO_THREADS
|
||||
dnl
|
||||
dnl libldap/*.c should only include <lthread.h> iff
|
||||
dnl libldap/*.c should only include <ldap_pvt_thread.h> iff
|
||||
dnl LDAP_R_COMPILE is defined. ie:
|
||||
dnl #ifdef LDAP_R_COMPILE
|
||||
dnl # include LDAP_R_COMPILE
|
||||
dnl # include <ldap_pvt_thread.h>
|
||||
dnl #endif
|
||||
dnl
|
||||
dnl LDAP_R_COMPILE is defined by libldap_r/Makefile.in
|
||||
@ -1924,6 +1882,32 @@ if test $ol_link_threads != no ; then
|
||||
AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE,1)
|
||||
fi
|
||||
|
||||
dnl ----------------------------------------------------------------
|
||||
dnl Tests for reentrant functions necessary to build -lldap_r
|
||||
AC_CHECK_FUNCS( \
|
||||
ctime_r \
|
||||
gethostbyname_r gethostbyaddr_r \
|
||||
)
|
||||
|
||||
if test "$ac_cv_func_ctime_r" = no ; then
|
||||
ol_cv_func_ctime_r_nargs=0
|
||||
else
|
||||
OL_FUNC_CTIME_R_NARGS
|
||||
dnl OL_FUNC_CTIME_R_TYPE
|
||||
fi
|
||||
|
||||
if test "$ac_cv_func_gethostbyname_r" = yes ; then
|
||||
OL_FUNC_GETHOSTBYNAME_R_NARGS
|
||||
else
|
||||
ol_cv_func_gethostbyname_r_nargs=0
|
||||
fi
|
||||
|
||||
if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
|
||||
OL_FUNC_GETHOSTBYADDR_R_NARGS
|
||||
else
|
||||
ol_cv_func_gethostbyaddr_r_nargs=0
|
||||
fi
|
||||
|
||||
dnl ----------------------------------------------------------------
|
||||
ol_link_ldbm=no
|
||||
|
||||
|
@ -29,15 +29,11 @@
|
||||
** OpenLDAP reentrancy/thread-safeness should be dynamically
|
||||
** checked using ldap_get_option().
|
||||
**
|
||||
** The -lldap implementation may or may not be:
|
||||
** LDAP_API_FEATURE_THREAD_SAFE
|
||||
** The -lldap implementation is not thread-safe.
|
||||
**
|
||||
** The preprocessor flag LDAP_API_FEATURE_X_OPENLDAP_REENTRANT can
|
||||
** be used to determine if -lldap is LDAP_API_FEATURE_THREAD_SAFE at
|
||||
** compile time.
|
||||
**
|
||||
** The -lldap_r implementation is always THREAD_SAFE but
|
||||
** may also be:
|
||||
** The -lldap_r implementation is:
|
||||
** LDAP_API_FEATURE_THREAD_SAFE (basic thread safety)
|
||||
** but also be:
|
||||
** LDAP_API_FEATURE_SESSION_THREAD_SAFE
|
||||
** LDAP_API_FEATURE_OPERATION_THREAD_SAFE
|
||||
**
|
||||
@ -52,10 +48,7 @@
|
||||
**
|
||||
*/
|
||||
|
||||
/* is -lldap reentrant or not */
|
||||
#undef LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
|
||||
|
||||
/* is threadsafe version of -lldap (ie: -lldap_r) *available* or not */
|
||||
/* is -lldap_r available or not */
|
||||
#undef LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
|
||||
|
||||
/* LDAP v2 Kerberos Bind */
|
||||
|
@ -184,7 +184,6 @@ ldap_pvt_thread_pool_setkey LDAP_P((
|
||||
void *data,
|
||||
ldap_pvt_thread_pool_keyfree_t *kfree ));
|
||||
|
||||
|
||||
LDAP_END_DECL
|
||||
|
||||
#endif /* _LDAP_THREAD_H */
|
||||
|
@ -698,15 +698,6 @@
|
||||
/* define to support LAN Manager passwords */
|
||||
#undef SLAPD_LMHASH
|
||||
|
||||
/* set to the number of arguments ctime_r() expects */
|
||||
#undef CTIME_R_NARGS
|
||||
|
||||
/* set to the number of arguments gethostbyname_r() expects */
|
||||
#undef GETHOSTBYNAME_R_NARGS
|
||||
|
||||
/* set to the number of arguments gethostbyaddr_r() expects */
|
||||
#undef GETHOSTBYADDR_R_NARGS
|
||||
|
||||
/* if you have NT Threads */
|
||||
#undef HAVE_NT_THREADS
|
||||
|
||||
@ -749,6 +740,15 @@
|
||||
/* define if you have (or want) no threads */
|
||||
#undef NO_THREADS
|
||||
|
||||
/* set to the number of arguments ctime_r() expects */
|
||||
#undef CTIME_R_NARGS
|
||||
|
||||
/* set to the number of arguments gethostbyname_r() expects */
|
||||
#undef GETHOSTBYNAME_R_NARGS
|
||||
|
||||
/* set to the number of arguments gethostbyaddr_r() expects */
|
||||
#undef GETHOSTBYADDR_R_NARGS
|
||||
|
||||
/* define if Berkeley DB has DB_THREAD support */
|
||||
#undef HAVE_BERKELEY_DB_THREAD
|
||||
|
||||
|
@ -33,15 +33,20 @@
|
||||
|
||||
#include "ldap-int.h"
|
||||
|
||||
#if defined( LDAP_R_COMPILE )
|
||||
# include <ldap_pvt_thread.h>
|
||||
#else
|
||||
#if !defined( LDAP_R_COMPILE )
|
||||
# undef HAVE_REENTRANT_FUNCTIONS
|
||||
#endif
|
||||
# undef HAVE_CTIME_R
|
||||
# undef HAVE_GETHOSTBYNAME_R
|
||||
# undef HAVE_GETHOSTBYADDR_R
|
||||
|
||||
#else
|
||||
# include <ldap_pvt_thread.h>
|
||||
|
||||
#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \
|
||||
&& defined( CTIME_R_NARGS )
|
||||
# define USE_CTIME_R
|
||||
#else
|
||||
static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GETHOSTBYNAME_R) && \
|
||||
@ -55,13 +60,7 @@
|
||||
# undef HAVE_GETHOSTBYADDR_R
|
||||
#endif
|
||||
|
||||
#ifdef LDAP_R_COMPILE
|
||||
# ifndef USE_CTIME_R
|
||||
static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex;
|
||||
# endif
|
||||
# ifdef HAVE_RES_QUERY
|
||||
ldap_pvt_thread_mutex_t ldap_int_resolv_mutex;
|
||||
# endif
|
||||
#endif /* LDAP_R_COMPILE */
|
||||
|
||||
char *ldap_pvt_ctime( const time_t *tp, char *buf )
|
||||
@ -78,13 +77,17 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf )
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
# ifdef LDAP_R_COMPILE
|
||||
ldap_pvt_thread_mutex_lock( &ldap_int_ctime_mutex );
|
||||
# endif
|
||||
|
||||
AC_MEMCPY( buf, ctime(tp), 26 );
|
||||
|
||||
# ifdef LDAP_R_COMPILE
|
||||
ldap_pvt_thread_mutex_unlock( &ldap_int_ctime_mutex );
|
||||
# endif
|
||||
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
@ -95,7 +98,8 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf )
|
||||
static char *safe_realloc( char **buf, int len );
|
||||
|
||||
#if !defined(HAVE_GETHOSTBYNAME_R) && defined(LDAP_R_COMPILE)
|
||||
static int copy_hostent( struct hostent *res, char **buf, struct hostent * src );
|
||||
static int copy_hostent( struct hostent *res,
|
||||
char **buf, struct hostent * src );
|
||||
#endif
|
||||
|
||||
int ldap_pvt_gethostbyname_a(
|
||||
@ -243,7 +247,8 @@ int ldap_pvt_gethostbyaddr_a(
|
||||
|
||||
ldap_pvt_thread_mutex_unlock( &ldap_int_resolv_mutex );
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
|
||||
#else /* gethostbyaddr() */
|
||||
*buf = NULL;
|
||||
*result = gethostbyaddr( addr, len, type );
|
||||
@ -266,17 +271,13 @@ void ldap_int_utils_init( void )
|
||||
done=1;
|
||||
|
||||
#ifdef LDAP_R_COMPILE
|
||||
|
||||
#if !defined( USE_CTIME_R ) && !defined( HAVE_REENTRANT_FUNCTIONS )
|
||||
ldap_pvt_thread_mutex_init( &ldap_int_ctime_mutex );
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_RES_QUERY
|
||||
ldap_pvt_thread_mutex_init( &ldap_int_resolv_mutex );
|
||||
#endif
|
||||
|
||||
/* call other module init functions here... */
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined( NEED_COPY_HOSTENT )
|
||||
|
Loading…
Reference in New Issue
Block a user