mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-20 22:59:34 -05:00
Support for native GNU Pth Threads (--with-threads=pth)
Tests behave as expected excepting slapd sometimes does not shutdown properly.
This commit is contained in:
parent
5cf315c31f
commit
1b0aa8cf23
6 changed files with 567 additions and 279 deletions
22
configure.in
22
configure.in
|
|
@ -89,7 +89,7 @@ OL_ARG_WITH(kerberos,[ --with-kerberos with Kerberos support],
|
||||||
OL_ARG_WITH(readline,[ --with-readline with readline support],
|
OL_ARG_WITH(readline,[ --with-readline with readline support],
|
||||||
auto, [auto yes no] )
|
auto, [auto yes no] )
|
||||||
OL_ARG_WITH(threads,[ --with-threads use threads],
|
OL_ARG_WITH(threads,[ --with-threads use threads],
|
||||||
auto, [auto posix mach lwp yes no manual] )
|
auto, [auto posix mach pth lwp yes no manual] )
|
||||||
OL_ARG_WITH(tls,[ --with-tls with TLS/SSL support],
|
OL_ARG_WITH(tls,[ --with-tls with TLS/SSL support],
|
||||||
auto, [auto ssleay openssl yes no] )
|
auto, [auto ssleay openssl yes no] )
|
||||||
OL_ARG_WITH(yielding_select,[ --with-yielding-select with implicitly yielding select],
|
OL_ARG_WITH(yielding_select,[ --with-yielding-select with implicitly yielding select],
|
||||||
|
|
@ -1240,6 +1240,26 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test $ol_with_threads = auto -o $ol_with_threads = yes \
|
||||||
|
-o $ol_with_threads = pth ; then
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS(pth.h)
|
||||||
|
|
||||||
|
if test $ac_cv_header_pth_h = yes ; then
|
||||||
|
AC_CHECK_LIB(pth, pth_version, [have_pth=yes], [have_pth=no])
|
||||||
|
|
||||||
|
if test $have_pth = yes ; then
|
||||||
|
AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth])
|
||||||
|
LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
|
||||||
|
ol_link_threads=pth
|
||||||
|
|
||||||
|
if test $ol_with_yielding_select = auto ; then
|
||||||
|
ol_with_yielding_select=yes
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if test $ol_with_threads = auto -o $ol_with_threads = yes \
|
if test $ol_with_threads = auto -o $ol_with_threads = yes \
|
||||||
-o $ol_with_threads = lwp ; then
|
-o $ol_with_threads = lwp ; then
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,24 @@ typedef struct condition ldap_pvt_thread_cond_t;
|
||||||
|
|
||||||
LDAP_END_DECL
|
LDAP_END_DECL
|
||||||
|
|
||||||
|
#elif defined( HAVE_GNU_PTH )
|
||||||
|
/***********************************
|
||||||
|
* *
|
||||||
|
* thread definitions for GNU Pth *
|
||||||
|
* *
|
||||||
|
***********************************/
|
||||||
|
|
||||||
|
#include <pth.h>
|
||||||
|
|
||||||
|
LDAP_BEGIN_DECL
|
||||||
|
|
||||||
|
typedef pth_t ldap_pvt_thread_t;
|
||||||
|
typedef pth_mutex_t ldap_pvt_thread_mutex_t;
|
||||||
|
typedef pth_cond_t ldap_pvt_thread_cond_t;
|
||||||
|
|
||||||
|
LDAP_END_DECL
|
||||||
|
|
||||||
|
|
||||||
#elif defined( HAVE_THR )
|
#elif defined( HAVE_THR )
|
||||||
/********************************************
|
/********************************************
|
||||||
* *
|
* *
|
||||||
|
|
|
||||||
|
|
@ -429,6 +429,9 @@
|
||||||
/* Define if you have the <psap.h> header file. */
|
/* Define if you have the <psap.h> header file. */
|
||||||
#undef HAVE_PSAP_H
|
#undef HAVE_PSAP_H
|
||||||
|
|
||||||
|
/* Define if you have the <pth.h> header file. */
|
||||||
|
#undef HAVE_PTH_H
|
||||||
|
|
||||||
/* Define if you have the <pthread.h> header file. */
|
/* Define if you have the <pthread.h> header file. */
|
||||||
#undef HAVE_PTHREAD_H
|
#undef HAVE_PTHREAD_H
|
||||||
|
|
||||||
|
|
@ -654,6 +657,9 @@
|
||||||
/* define if you have Mach Cthreads */
|
/* define if you have Mach Cthreads */
|
||||||
#undef HAVE_MACH_CTHREADS
|
#undef HAVE_MACH_CTHREADS
|
||||||
|
|
||||||
|
/* if you have GNU Pth */
|
||||||
|
#undef HAVE_GNU_PTH
|
||||||
|
|
||||||
/* if you have Solaris LWP (thr) package */
|
/* if you have Solaris LWP (thr) package */
|
||||||
#undef HAVE_THR
|
#undef HAVE_THR
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ XXSRCS = apitest.c test.c tmpltest.c extended.c \
|
||||||
init.c options.c print.c string.c util-int.c schema.c \
|
init.c options.c print.c string.c util-int.c schema.c \
|
||||||
charray.c digest.c tls.c
|
charray.c digest.c tls.c
|
||||||
SRCS = thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \
|
SRCS = thr_posix.c thr_cthreads.c thr_thr.c thr_lwp.c thr_nt.c \
|
||||||
thr_sleep.c thr_stub.c rdwr.c
|
thr_pth.c thr_sleep.c thr_stub.c rdwr.c
|
||||||
OBJS = extended.lo \
|
OBJS = extended.lo \
|
||||||
bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \
|
bind.lo controls.lo open.lo result.lo error.lo compare.lo search.lo \
|
||||||
modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
|
modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
|
||||||
|
|
@ -27,7 +27,7 @@ OBJS = extended.lo \
|
||||||
request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
|
request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
|
||||||
init.lo options.lo print.lo string.lo util-int.lo schema.lo \
|
init.lo options.lo print.lo string.lo util-int.lo schema.lo \
|
||||||
thr_posix.lo thr_cthreads.lo thr_thr.lo thr_lwp.lo thr_nt.lo \
|
thr_posix.lo thr_cthreads.lo thr_thr.lo thr_lwp.lo thr_nt.lo \
|
||||||
thr_sleep.lo thr_stub.lo rdwr.lo \
|
thr_pth.lo thr_sleep.lo thr_stub.lo rdwr.lo \
|
||||||
charray.lo digest.lo tls.lo
|
charray.lo digest.lo tls.lo
|
||||||
|
|
||||||
LDAP_INCDIR= ../../include
|
LDAP_INCDIR= ../../include
|
||||||
|
|
|
||||||
142
libraries/libldap_r/thr_pth.c
Normal file
142
libraries/libldap_r/thr_pth.c
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*
|
||||||
|
* Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms are permitted only
|
||||||
|
* as authorized by the OpenLDAP Public License. A copy of this
|
||||||
|
* license is available at http://www.OpenLDAP.org/license.html or
|
||||||
|
* in file LICENSE in the top-level directory of the distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* thr_thr.c - wrappers around solaris threads */
|
||||||
|
|
||||||
|
#include "portable.h"
|
||||||
|
|
||||||
|
#if defined( HAVE_GNU_PTH )
|
||||||
|
|
||||||
|
#include "ldap_pvt_thread.h"
|
||||||
|
|
||||||
|
/*******************
|
||||||
|
* *
|
||||||
|
* GNU Pth Threads *
|
||||||
|
* *
|
||||||
|
*******************/
|
||||||
|
|
||||||
|
static pth_attr_t detach_attr;
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_initialize( void )
|
||||||
|
{
|
||||||
|
detach_attr = pth_attr_new();
|
||||||
|
pth_attr_set( detach_attr, PTH_ATTR_JOINABLE, FALSE );
|
||||||
|
return pth_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_destroy( void )
|
||||||
|
{
|
||||||
|
pth_attr_destroy(detach_attr);
|
||||||
|
pth_kill();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
|
||||||
|
int detach,
|
||||||
|
void *(*start_routine)( void *),
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
*thread = pth_spawn( detach ? detach_attr : PTH_ATTR_DEFAULT,
|
||||||
|
start_routine, arg );
|
||||||
|
|
||||||
|
return *thread == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ldap_pvt_thread_exit( void *retval )
|
||||||
|
{
|
||||||
|
pth_exit( retval );
|
||||||
|
}
|
||||||
|
|
||||||
|
int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
|
||||||
|
{
|
||||||
|
pth_join( thread, thread_return );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
|
||||||
|
{
|
||||||
|
pth_raise( thread, signo );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_yield( void )
|
||||||
|
{
|
||||||
|
pth_yield(NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
|
||||||
|
{
|
||||||
|
return( pth_cond_init( cond ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
|
||||||
|
{
|
||||||
|
return( pth_cond_notify( cond, 0 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
|
||||||
|
{
|
||||||
|
return( pth_cond_notify( cond, 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
|
||||||
|
ldap_pvt_thread_mutex_t *mutex )
|
||||||
|
{
|
||||||
|
return( pth_cond_await( cond, mutex, NULL ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
|
||||||
|
{
|
||||||
|
return( pth_mutex_init( mutex ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
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( pth_mutex_acquire( mutex, 0, NULL ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
|
||||||
|
{
|
||||||
|
return( pth_mutex_release( mutex ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
|
||||||
|
{
|
||||||
|
return( pth_mutex_acquire( mutex, 1, NULL ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_GNU_PTH */
|
||||||
Loading…
Reference in a new issue