-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-#include <signal.h>
#include "portable.h"
-#include "slap.h"
-extern Operation *op_add();
-extern int active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern long ops_initiated;
-extern long ops_completed;
-extern pthread_mutex_t ops_mutex;
-extern pthread_t listener_tid;
-#ifndef SYSERRLIST_IN_STDIO
-extern int sys_nerr;
-extern char *sys_errlist[];
-#endif
+#include <stdio.h>
+
+#include <ac/errno.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "slap.h"
struct co_arg {
Connection *co_conn;
* calls the appropriate stub to handle it.
*/
-static void
-connection_operation( struct co_arg *arg )
+static void *
+connection_operation( void *arg_v )
{
+ struct co_arg *arg = arg_v;
unsigned long len;
pthread_mutex_lock( &arg->co_conn->c_opsmutex );
do_bind( arg->co_conn, arg->co_op );
break;
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
case LDAP_REQ_UNBIND_30:
#endif
case LDAP_REQ_UNBIND:
do_add( arg->co_conn, arg->co_op );
break;
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
case LDAP_REQ_DELETE_30:
#endif
case LDAP_REQ_DELETE:
do_search( arg->co_conn, arg->co_op );
break;
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
case LDAP_REQ_ABANDON_30:
#endif
case LDAP_REQ_ABANDON:
break;
default:
- Debug( LDAP_DEBUG_ANY, "unknown request 0x%x\n",
+ Debug( LDAP_DEBUG_ANY, "unknown request 0x%lx\n",
arg->co_op->o_tag, 0, 0 );
break;
}
pthread_mutex_lock( &active_threads_mutex );
active_threads--;
pthread_mutex_unlock( &active_threads_mutex );
+ return NULL;
}
void
"ber_get_next on fd %d failed errno %d (%s)\n",
conn->c_sb.sb_sd, errno, errno > -1 && errno < sys_nerr ?
sys_errlist[errno] : "unknown" );
- Debug( LDAP_DEBUG_TRACE, "*** got %d of %d so far\n",
+ Debug( LDAP_DEBUG_TRACE, "*** got %d of %lu so far\n",
conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf,
conn->c_currentber->ber_len, 0 );
if ( (tag = ber_get_int( ber, &msgid )) != LDAP_TAG_MSGID ) {
/* log, close and send error */
- Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%x\n", tag, 0,
+ Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0,
0 );
ber_free( ber, 1 );
if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
/* log, close and send error */
- Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%x\n", tag, 0,
+ Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0,
0 );
ber_free( ber, 1 );
return;
}
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
if ( conn->c_version == 30 ) {
(void) ber_skip_tag( ber, &len );
}
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
+#if !defined(HAVE_PTHREADS_D4)
+ /* POSIX_THREADS or compatible
+ * This is a draft 10 or standard pthreads implementation
+ */
+ if ( pthread_create( &arg->co_op->o_tid, &attr,
+ 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 );
+ }
+#else /* pthread draft4 */
+ /*
+ * This is a draft 4 or earlier pthreads implementation
+ */
if ( pthread_create( &arg->co_op->o_tid, attr,
- (void *) connection_operation, (void *) arg ) != 0 ) {
+ 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 );
}
+#endif /* pthread draft4 */
pthread_attr_destroy( &attr );
}