Commit 318531a4 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

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.
parent 82b94e22
This diff is collapsed.
......@@ -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
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment