1 /* init.c - initialize various things */
15 * read-only global variables or variables only written by the listener
16 * thread (after they are initialized) - no need to protect them with a mutex.
21 int ldap_syslog = LDAP_DEBUG_STATS;
26 int ldap_syslog_level = LOG_DEBUG;
27 char *default_referral;
29 ldap_pvt_thread_t listener_tid;
34 * global variables that need mutex protection
37 ldap_pvt_thread_mutex_t active_threads_mutex;
38 ldap_pvt_thread_cond_t active_threads_cond;
41 ldap_pvt_thread_mutex_t currenttime_mutex;
43 ldap_pvt_thread_mutex_t new_conn_mutex;
46 ldap_pvt_thread_mutex_t crypt_mutex;
52 ldap_pvt_thread_mutex_t ops_mutex;
54 long num_entries_sent;
56 ldap_pvt_thread_mutex_t num_sent_mutex;
58 * these mutexes must be used when calling the entry2str()
59 * routine since it returns a pointer to static data.
61 ldap_pvt_thread_mutex_t entry2str_mutex;
62 ldap_pvt_thread_mutex_t replog_mutex;
64 static char* slap_name;
65 int slapMode = SLAP_UNDEFINED_MODE;
68 slap_init( int mode, char *name )
72 if( slapMode != SLAP_UNDEFINED_MODE ) {
73 Debug( LDAP_DEBUG_ANY,
74 "%s init: init called twice (old=%d, new=%d)\n",
75 name, slapMode, mode );
83 case SLAP_SERVER_MODE:
86 case SLAP_TIMEDSERVER_MODE:
89 Debug( LDAP_DEBUG_TRACE,
90 "%s init: initiated %s.\n",
91 name, mode == SLAP_TOOL_MODE ? "tool" : "server", 0 );
95 (void) ldap_pvt_thread_initialize();
97 ldap_pvt_thread_mutex_init( &active_threads_mutex );
98 ldap_pvt_thread_cond_init( &active_threads_cond );
100 ldap_pvt_thread_mutex_init( &new_conn_mutex );
101 ldap_pvt_thread_mutex_init( ¤ttime_mutex );
102 ldap_pvt_thread_mutex_init( &entry2str_mutex );
103 ldap_pvt_thread_mutex_init( &replog_mutex );
104 ldap_pvt_thread_mutex_init( &ops_mutex );
105 ldap_pvt_thread_mutex_init( &num_sent_mutex );
107 ldap_pvt_thread_mutex_init( &crypt_mutex );
114 Debug( LDAP_DEBUG_ANY,
115 "%s init: undefined mode (%d).\n", name, mode, 0 );
123 int slap_startup(int dbnum)
127 Debug( LDAP_DEBUG_TRACE,
128 "%s startup: initiated.\n",
131 rc = backend_startup(dbnum);
136 int slap_shutdown(int dbnum)
140 Debug( LDAP_DEBUG_TRACE,
141 "%s shutdown: initiated\n",
144 /* let backends do whatever cleanup they need to do */
145 rc = backend_shutdown(dbnum);
150 int slap_destroy(void)
154 Debug( LDAP_DEBUG_TRACE,
155 "%s shutdown: freeing system resources.\n",
158 rc = backend_destroy();
160 /* should destory the above mutex */