From: Mark Valence Date: Sat, 10 Jun 2000 06:40:03 +0000 (+0000) Subject: Removed active_threads count and associated mutex/cond. Replaced with X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2673 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3cad129608cda1c80acc15c364537f017fa454c7;p=openldap Removed active_threads count and associated mutex/cond. Replaced with ldap_pvt_thread_pool_backload() as needed. All tests run OK on pthre ads (linux), cthreads, NT threads, and Pth. --- diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 147c7b3511..67d6cd0427 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -843,13 +843,6 @@ operations_error: } } - ldap_pvt_thread_mutex_lock( &active_threads_mutex ); - active_threads--; - if( active_threads < 1 ) { - ldap_pvt_thread_cond_signal(&active_threads_cond); - } - ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); - connection_resched( conn ); ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); @@ -1135,10 +1128,6 @@ static int connection_op_activate( Connection *conn, Operation *op ) free( tmpdn ); } - ldap_pvt_thread_mutex_lock( &active_threads_mutex ); - active_threads++; - ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); - status = ldap_pvt_thread_pool_submit( connection_pool, connection_operation, (void *) arg ); if ( status != 0 ) { diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 337edd72c9..93ec33d23c 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -751,9 +751,7 @@ slapd_daemon_task( ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); - ldap_pvt_thread_mutex_lock( &active_threads_mutex ); - at = active_threads; - ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); + at = ldap_pvt_thread_pool_backload(connection_pool); #if defined( HAVE_YIELDING_SELECT ) || defined( NO_THREADS ) tvp = NULL; @@ -1158,16 +1156,11 @@ slapd_daemon_task( } } - ldap_pvt_thread_pool_destroy(connection_pool, 1); - - ldap_pvt_thread_mutex_lock( &active_threads_mutex ); Debug( LDAP_DEBUG_ANY, "slapd shutdown: waiting for %d threads to terminate\n", - active_threads, 0, 0 ); - while ( active_threads > 0 ) { - ldap_pvt_thread_cond_wait(&active_threads_cond, &active_threads_mutex); - } - ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); + ldap_pvt_thread_pool_backload(connection_pool), 0, 0 ); + + ldap_pvt_thread_pool_destroy(connection_pool, 1); return NULL; } diff --git a/servers/slapd/init.c b/servers/slapd/init.c index 7de52da5a4..0039bdbfde 100644 --- a/servers/slapd/init.c +++ b/servers/slapd/init.c @@ -38,9 +38,6 @@ char **g_argv; /* * global variables that need mutex protection */ -int active_threads; -ldap_pvt_thread_mutex_t active_threads_mutex; -ldap_pvt_thread_cond_t active_threads_cond; ldap_pvt_thread_pool_t connection_pool; ldap_pvt_thread_mutex_t gmtime_mutex; @@ -99,9 +96,6 @@ slap_init( int mode, const char *name ) (void) ldap_pvt_thread_initialize(); ldap_pvt_thread_pool_initialize(&connection_pool, 0, 0); - ldap_pvt_thread_mutex_init( &active_threads_mutex ); - ldap_pvt_thread_cond_init( &active_threads_cond ); - ldap_pvt_thread_mutex_init( ¤ttime_mutex ); ldap_pvt_thread_mutex_init( &entry2str_mutex ); ldap_pvt_thread_mutex_init( &replog_mutex ); diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index dbe8dda1ff..63c791dd58 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -90,9 +90,7 @@ monitor_info( } attr_merge( e, "version", vals ); - ldap_pvt_thread_mutex_lock( &active_threads_mutex ); - sprintf( buf, "%d", active_threads ); - ldap_pvt_thread_mutex_unlock( &active_threads_mutex ); + sprintf( buf, "%d", ldap_pvt_thread_pool_backload(connection_pool) ); val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "threads", vals ); diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 9905e1787c..1f4e352171 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -726,7 +726,6 @@ LIBSLAPD_F (int) krbv4_ldap_auth(); LIBSLAPD_F (struct berval **) default_referral; LIBSLAPD_F (char *) replogfile; LIBSLAPD_F (const char) Versionstr[]; -LIBSLAPD_F (int) active_threads; LIBSLAPD_F (int) defsize; LIBSLAPD_F (int) deftime; LIBSLAPD_F (int) g_argc; @@ -757,8 +756,6 @@ LIBSLAPD_F (time_t) starttime; LIBSLAPD_F (time_t) slap_get_time LDAP_P((void)); -LIBSLAPD_F (ldap_pvt_thread_mutex_t) active_threads_mutex; -LIBSLAPD_F (ldap_pvt_thread_cond_t) active_threads_cond; LIBSLAPD_F (ldap_pvt_thread_pool_t) connection_pool; LIBSLAPD_F (ldap_pvt_thread_mutex_t) entry2str_mutex;