1 /* init.c - initialize various things */
14 * read-only global variables or variables only written by the listener
15 * thread (after they are initialized) - no need to protect them with a mutex.
20 int ldap_syslog = LDAP_DEBUG_STATS;
25 int ldap_syslog_level = LOG_DEBUG;
26 char *default_referral;
31 * global variables that need mutex protection
34 ldap_pvt_thread_mutex_t active_threads_mutex;
35 ldap_pvt_thread_cond_t active_threads_cond;
37 ldap_pvt_thread_mutex_t gmtime_mutex;
39 ldap_pvt_thread_mutex_t crypt_mutex;
43 long num_ops_initiated;
44 long num_ops_completed;
45 ldap_pvt_thread_mutex_t num_ops_mutex;
47 long num_entries_sent;
49 ldap_pvt_thread_mutex_t num_sent_mutex;
51 * these mutexes must be used when calling the entry2str()
52 * routine since it returns a pointer to static data.
54 ldap_pvt_thread_mutex_t entry2str_mutex;
55 ldap_pvt_thread_mutex_t replog_mutex;
57 static char* slap_name;
58 int slapMode = SLAP_UNDEFINED_MODE;
60 static ldap_pvt_thread_mutex_t currenttime_mutex;
63 slap_init( int mode, char *name )
67 if( slapMode != SLAP_UNDEFINED_MODE ) {
68 Debug( LDAP_DEBUG_ANY,
69 "%s init: init called twice (old=%d, new=%d)\n",
70 name, slapMode, mode );
78 case SLAP_SERVER_MODE:
81 case SLAP_TIMEDSERVER_MODE:
82 case SLAP_TOOLID_MODE:
85 Debug( LDAP_DEBUG_TRACE,
86 "%s init: initiated %s.\n",
87 name, mode == SLAP_TOOL_MODE ? "tool" : "server", 0 );
91 (void) ldap_pvt_thread_initialize();
93 ldap_pvt_thread_mutex_init( &active_threads_mutex );
94 ldap_pvt_thread_cond_init( &active_threads_cond );
96 ldap_pvt_thread_mutex_init( ¤ttime_mutex );
97 ldap_pvt_thread_mutex_init( &entry2str_mutex );
98 ldap_pvt_thread_mutex_init( &replog_mutex );
99 ldap_pvt_thread_mutex_init( &num_ops_mutex );
100 ldap_pvt_thread_mutex_init( &num_sent_mutex );
102 ldap_pvt_thread_mutex_init( &gmtime_mutex );
104 ldap_pvt_thread_mutex_init( &crypt_mutex );
111 Debug( LDAP_DEBUG_ANY,
112 "%s init: undefined mode (%d).\n", name, mode, 0 );
120 int slap_startup(int dbnum)
124 Debug( LDAP_DEBUG_TRACE,
125 "%s startup: initiated.\n",
128 rc = backend_startup(dbnum);
133 int slap_shutdown(int dbnum)
137 Debug( LDAP_DEBUG_TRACE,
138 "%s shutdown: initiated\n",
141 /* let backends do whatever cleanup they need to do */
142 rc = backend_shutdown(dbnum);
147 int slap_destroy(void)
151 Debug( LDAP_DEBUG_TRACE,
152 "%s shutdown: freeing system resources.\n",
155 rc = backend_destroy();
157 /* should destory the above mutex */
161 /* should create a utils.c for these */
162 time_t slap_get_time(void)
165 ldap_pvt_thread_mutex_lock( ¤ttime_mutex );
167 ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );