+ slap_passwd_init();
+
+ rc = slap_sasl_init();
+
+ if( rc == 0 ) {
+ rc = backend_init( );
+ }
+
+ break;
+
+ default:
+ Debug( LDAP_DEBUG_ANY,
+ "%s init: undefined mode (%d).\n", name, mode, 0 );
+
+ rc = 1;
+ break;
+ }
+
+ return rc;
+}
+
+int slap_startup( Backend *be )
+{
+ int rc;
+
+ Debug( LDAP_DEBUG_TRACE,
+ "%s startup: initiated.\n",
+ slap_name, 0, 0 );
+
+
+ rc = backend_startup( be );
+
+#ifdef LDAP_SLAPI
+ if( rc == 0 ) {
+ Slapi_PBlock *pb = slapi_pblock_new();
+
+ if ( slapi_int_call_plugins( frontendDB, SLAPI_PLUGIN_START_FN, pb ) < 0 ) {
+ rc = -1;
+ }
+ slapi_pblock_destroy( pb );
+ }
+#endif /* LDAP_SLAPI */
+
+ return rc;
+}
+
+int slap_shutdown( Backend *be )
+{
+ int rc;
+#ifdef LDAP_SLAPI
+ Slapi_PBlock *pb;
+#endif
+
+ Debug( LDAP_DEBUG_TRACE,
+ "%s shutdown: initiated\n",
+ slap_name, 0, 0 );
+
+ /* let backends do whatever cleanup they need to do */
+ rc = backend_shutdown( be );
+
+#ifdef LDAP_SLAPI
+ pb = slapi_pblock_new();
+ (void) slapi_int_call_plugins( frontendDB, SLAPI_PLUGIN_CLOSE_FN, pb );
+ slapi_pblock_destroy( pb );
+#endif /* LDAP_SLAPI */
+
+ return rc;
+}
+
+int slap_destroy(void)
+{
+ int rc;
+ int i;
+
+ Debug( LDAP_DEBUG_TRACE,
+ "%s destroy: freeing system resources.\n",
+ slap_name, 0, 0 );
+
+ if ( default_referral ) {
+ ber_bvarray_free( default_referral );
+ }
+
+ rc = backend_destroy();
+
+ slap_sasl_destroy();
+
+ entry_destroy();
+
+ switch ( slapMode & SLAP_MODE ) {
+ case SLAP_SERVER_MODE:
+ case SLAP_TOOL_MODE:
+
+ ldap_pvt_thread_mutex_destroy( &slap_counters.sc_sent_mutex );
+ ldap_pvt_thread_mutex_destroy( &slap_counters.sc_ops_mutex );
+ ldap_pvt_mp_clear( slap_counters.sc_bytes );
+ ldap_pvt_mp_clear( slap_counters.sc_pdu );
+ ldap_pvt_mp_clear( slap_counters.sc_entries );
+ ldap_pvt_mp_clear( slap_counters.sc_refs );
+ ldap_pvt_mp_clear( slap_counters.sc_ops_initiated );
+ ldap_pvt_mp_clear( slap_counters.sc_ops_completed );
+
+#ifdef SLAPD_MONITOR
+ for ( i = 0; i < SLAP_OP_LAST; i++ ) {
+ ldap_pvt_mp_clear( slap_counters.sc_ops_initiated_[ i ] );
+ ldap_pvt_mp_clear( slap_counters.sc_ops_completed_[ i ] );
+ }
+#endif /* SLAPD_MONITOR */
+ break;
+
+ default:
+ Debug( LDAP_DEBUG_ANY,
+ "slap_destroy(): undefined mode (%d).\n", slapMode, 0, 0 );
+
+ rc = 1;
+ break;
+
+ }
+
+ ldap_pvt_thread_destroy();
+
+ /* should destory the above mutex */
+ return rc;