mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-17 14:00:30 +08:00
Use pthread_detach() to detach connection threads instead of
creating them detached. This hopefully will reduce problems on draft4 pthread implementations related to creating detached threads (which is _np under draft4) on some platforms without causing problems with other thread implementations.
This commit is contained in:
parent
82b94e2258
commit
318531a437
@ -578,7 +578,8 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
|
||||
fi
|
||||
|
||||
dnl Check functions for compatibility
|
||||
AC_CHECK_FUNCS(pthread_kill)
|
||||
AC_CHECK_FUNCS(pthread_kill pthread_detach)
|
||||
|
||||
AC_CHECK_FUNCS( \
|
||||
pthread_attr_create pthread_attr_init \
|
||||
pthread_attr_destroy pthread_attr_delete \
|
||||
|
@ -343,6 +343,9 @@
|
||||
/* Define if you have the pthread_attr_setdetachstate function. */
|
||||
#undef HAVE_PTHREAD_ATTR_SETDETACHSTATE
|
||||
|
||||
/* Define if you have the pthread_detach function. */
|
||||
#undef HAVE_PTHREAD_DETACH
|
||||
|
||||
/* Define if you have the pthread_kill function. */
|
||||
#undef HAVE_PTHREAD_KILL
|
||||
|
||||
|
@ -112,7 +112,9 @@ connection_activity(
|
||||
Connection *conn
|
||||
)
|
||||
{
|
||||
#ifndef HAVE_PTHREAD_DETACH
|
||||
pthread_attr_t attr;
|
||||
#endif
|
||||
struct co_arg *arg;
|
||||
unsigned long tag, len;
|
||||
long msgid;
|
||||
@ -195,6 +197,24 @@ connection_activity(
|
||||
free( tmpdn );
|
||||
}
|
||||
|
||||
#ifdef HAVE_PTHREAD_DETACH
|
||||
if ( pthread_create( &arg->co_op->o_tid, NULL,
|
||||
connection_operation, (void *) arg ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
|
||||
} else {
|
||||
pthread_mutex_lock( &active_threads_mutex );
|
||||
active_threads++;
|
||||
pthread_mutex_unlock( &active_threads_mutex );
|
||||
}
|
||||
|
||||
#if !defined(HAVE_PTHREADS_D4)
|
||||
pthread_detach( arg->co_op->o_tid );
|
||||
#else
|
||||
pthread_detach( &arg->co_op->o_tid );
|
||||
#endif
|
||||
|
||||
#else /* !pthread detach */
|
||||
|
||||
pthread_attr_init( &attr );
|
||||
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
|
||||
#if !defined(HAVE_PTHREADS_D4)
|
||||
@ -223,4 +243,5 @@ connection_activity(
|
||||
}
|
||||
#endif /* pthread draft4 */
|
||||
pthread_attr_destroy( &attr );
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user