X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fconnection.c;h=36fca0b705356a6b268055176c6eb5dee9ad076e;hb=bbdac6ebcac9deaa18302f95fa96e585c8eb97d7;hp=bbfdd4344e5cef97d2feee0230c33b908f7136df;hpb=b76c56ba3f45576b9c418ea9fe7f7b3440052904;p=openldap diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index bbfdd4344e..36fca0b705 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -1,27 +1,14 @@ #include "portable.h" #include + +#include +#include +#include #include #include -#include -#include -#include -#include -#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; - -#ifdef DECL_SYS_ERRLIST -extern int sys_nerr; -extern char *sys_errlist[]; -#endif +#include "slap.h" struct co_arg { Connection *co_conn; @@ -34,9 +21,10 @@ struct co_arg { * 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 ); @@ -52,7 +40,7 @@ connection_operation( struct co_arg *arg ) do_bind( arg->co_conn, arg->co_op ); break; -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 case LDAP_REQ_UNBIND_30: #endif case LDAP_REQ_UNBIND: @@ -63,7 +51,7 @@ connection_operation( struct co_arg *arg ) do_add( arg->co_conn, arg->co_op ); break; -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 case LDAP_REQ_DELETE_30: #endif case LDAP_REQ_DELETE: @@ -86,7 +74,7 @@ connection_operation( struct co_arg *arg ) do_search( arg->co_conn, arg->co_op ); break; -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 case LDAP_REQ_ABANDON_30: #endif case LDAP_REQ_ABANDON: @@ -94,7 +82,7 @@ connection_operation( struct co_arg *arg ) 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; } @@ -113,6 +101,7 @@ connection_operation( struct co_arg *arg ) pthread_mutex_lock( &active_threads_mutex ); active_threads--; pthread_mutex_unlock( &active_threads_mutex ); + return NULL; } void @@ -140,7 +129,7 @@ connection_activity( "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 ); @@ -159,7 +148,7 @@ connection_activity( 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 ); @@ -169,7 +158,7 @@ connection_activity( 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 ); @@ -177,7 +166,7 @@ connection_activity( return; } -#ifdef COMPAT30 +#ifdef LDAP_COMPAT30 if ( conn->c_version == 30 ) { (void) ber_skip_tag( ber, &len ); } @@ -205,30 +194,30 @@ connection_activity( pthread_attr_init( &attr ); pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED ); -#ifndef THREAD_MIT_PTHREADS +#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, - (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 ); } -#else /* !THREAD_MIT_PTHREAD */ +#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 /* !THREAD_MIT_PTHREAD */ +#endif /* pthread draft4 */ pthread_attr_destroy( &attr ); }