--- servers/slapd/init.c 2002/01/04 20:38:28 1.18.2.10 +++ servers/slapd/init.c 1999/08/03 21:23:05 1.19 @@ -1,9 +1,4 @@ /* init.c - initialize various things */ -/* $OpenLDAP: pkg/ldap/servers/slapd/init.c,v 1.18.2.9 2000/10/11 02:41:31 kurt Exp $ */ -/* - * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file - */ #include "portable.h" @@ -27,10 +22,7 @@ int ldap_syslog = LDAP_DEBUG_STATS; int ldap_syslog; #endif -#ifdef LOG_DEBUG int ldap_syslog_level = LOG_DEBUG; -#endif - struct berval **default_referral = NULL; int g_argc; char **g_argv; @@ -38,10 +30,13 @@ char **g_argv; /* * global variables that need mutex protection */ -ldap_pvt_thread_pool_t connection_pool; +int active_threads; +ldap_pvt_thread_mutex_t active_threads_mutex; +ldap_pvt_thread_cond_t active_threads_cond; + ldap_pvt_thread_mutex_t gmtime_mutex; -#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) -ldap_pvt_thread_mutex_t passwd_mutex; +#ifdef SLAPD_CRYPT +ldap_pvt_thread_mutex_t crypt_mutex; #endif int num_conns; @@ -61,18 +56,16 @@ ldap_pvt_thread_mutex_t num_sent_mutex; ldap_pvt_thread_mutex_t entry2str_mutex; ldap_pvt_thread_mutex_t replog_mutex; -static const char* slap_name = NULL; +static char* slap_name; int slapMode = SLAP_UNDEFINED_MODE; static ldap_pvt_thread_mutex_t currenttime_mutex; int -slap_init( int mode, const char *name ) +slap_init( int mode, char *name ) { int rc; - assert( mode ); - if( slapMode != SLAP_UNDEFINED_MODE ) { Debug( LDAP_DEBUG_ANY, "%s init: init called twice (old=%d, new=%d)\n", @@ -82,19 +75,25 @@ slap_init( int mode, const char *name ) slapMode = mode; - switch ( slapMode & SLAP_MODE ) { + switch ( slapMode ) { + case SLAP_SERVER_MODE: case SLAP_TOOL_MODE: +#ifdef SLAPD_BDB2 + case SLAP_TIMEDSERVER_MODE: + case SLAP_TOOLID_MODE: +#endif + Debug( LDAP_DEBUG_TRACE, - "%s init: initiated %s.\n", name, - (mode & SLAP_MODE) == SLAP_TOOL_MODE ? "tool" : "server", - 0 ); + "%s init: initiated %s.\n", + name, mode == SLAP_TOOL_MODE ? "tool" : "server", 0 ); slap_name = name; (void) ldap_pvt_thread_initialize(); - ldap_pvt_thread_pool_init(&connection_pool, SLAP_MAX_WORKER_THREADS, 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 ); @@ -103,15 +102,11 @@ slap_init( int mode, const char *name ) ldap_pvt_thread_mutex_init( &num_sent_mutex ); ldap_pvt_thread_mutex_init( &gmtime_mutex ); -#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD ) - ldap_pvt_thread_mutex_init( &passwd_mutex ); +#ifdef SLAPD_CRYPT + ldap_pvt_thread_mutex_init( &crypt_mutex ); #endif - rc = slap_sasl_init(); - - if( rc == 0 ) { - rc = backend_init( ); - } + rc = backend_init(); break; default: @@ -124,7 +119,7 @@ slap_init( int mode, const char *name ) return rc; } -int slap_startup( Backend *be ) +int slap_startup(int dbnum) { int rc; @@ -132,12 +127,16 @@ int slap_startup( Backend *be ) "%s startup: initiated.\n", slap_name, 0, 0 ); - rc = backend_startup( be ); + rc = backend_startup(dbnum); + + if( rc == 0 ) { + rc = sasl_init(); + } return rc; } -int slap_shutdown( Backend *be ) +int slap_shutdown(int dbnum) { int rc; @@ -145,10 +144,10 @@ int slap_shutdown( Backend *be ) "%s shutdown: initiated\n", slap_name, 0, 0 ); - slap_sasl_destroy(); + sasl_destroy(); /* let backends do whatever cleanup they need to do */ - rc = backend_shutdown( be ); + rc = backend_shutdown(dbnum); return rc; } @@ -163,8 +162,6 @@ int slap_destroy(void) rc = backend_destroy(); - entry_destroy(); - ldap_pvt_thread_destroy(); /* should destory the above mutex */