]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/init.c
more (in)sanity stuff
[openldap] / servers / slapd / back-monitor / init.c
index f9a3482229aca00a14aea4a1f0c487ca7a4924ec..ce8967c3045ee82604b92cb022eea1001a43c0a0 100644 (file)
@@ -62,6 +62,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_backend_init,
+               NULL,   /* destroy */
                NULL,   /* update */
                NULL,   /* create */
                NULL    /* modify */
@@ -72,8 +73,9 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_VOLATILE_CH,
                monitor_subsys_conn_init,
-               monitor_subsys_conn_update,
-               monitor_subsys_conn_create,
+               NULL,   /* destroy */
+               NULL,   /* update */
+               NULL,   /* create */
                NULL    /* modify */
                }, { 
                SLAPD_MONITOR_DATABASE_NAME,    
@@ -82,9 +84,10 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_database_init,
+               NULL,   /* destroy */
                NULL,   /* update */
                NULL,   /* create */
-               monitor_subsys_database_modify
+               NULL    /* modify */
                }, { 
                SLAPD_MONITOR_LISTENER_NAME,    
                BER_BVNULL, BER_BVNULL, BER_BVNULL,
@@ -92,6 +95,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_listener_init,
+               NULL,   /* destroy */
                NULL,   /* update */
                NULL,   /* create */
                NULL    /* modify */
@@ -103,9 +107,10 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_NONE,
                monitor_subsys_log_init,
+               NULL,   /* destroy */
                NULL,   /* update */
                NULL,   /* create */
-               monitor_subsys_log_modify
+               NULL,   /* modify */
                }, { 
                SLAPD_MONITOR_OPS_NAME,
                BER_BVNULL, BER_BVNULL, BER_BVNULL,
@@ -113,7 +118,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_ops_init,
-               monitor_subsys_ops_update,
+               NULL,   /* destroy */
+               NULL,   /* update */
                NULL,   /* create */
                NULL,   /* modify */
                }, { 
@@ -123,6 +129,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_overlay_init,
+               NULL,   /* destroy */
                NULL,   /* update */
                NULL,   /* create */
                NULL,   /* modify */
@@ -133,6 +140,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_NONE,
                NULL,   /* init */
+               NULL,   /* destroy */
                NULL,   /* update */
                NULL,   /* create */
                NULL    /* modify */
@@ -143,7 +151,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_sent_init,
-               monitor_subsys_sent_update,
+               NULL,   /* destroy */
+               NULL,   /* update */
                NULL,   /* create */
                NULL,   /* modify */
                }, { 
@@ -153,7 +162,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_thread_init,
-               monitor_subsys_thread_update,
+               NULL,   /* destroy */
+               NULL,   /* update */
                NULL,   /* create */
                NULL    /* modify */
                }, { 
@@ -163,7 +173,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_time_init,
-               monitor_subsys_time_update,
+               NULL,   /* destroy */
+               NULL,   /* update */
                NULL,   /* create */
                NULL,   /* modify */
                }, { 
@@ -173,6 +184,7 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_NONE,
                NULL,   /* init */
+               NULL,   /* destroy */
                NULL,   /* update */
                NULL,   /* create */
                NULL    /* modify */
@@ -183,7 +195,8 @@ static struct monitor_subsys_t known_monitor_subsys[] = {
                        BER_BVNULL },
                MONITOR_F_PERSISTENT_CH,
                monitor_subsys_rww_init,
-               monitor_subsys_rww_update,
+               NULL,   /* destroy */
+               NULL,   /* update */
                NULL,   /* create */
                NULL    /* modify */
                }, { NULL }
@@ -1366,7 +1379,6 @@ int
 monitor_back_db_init(
        BackendDB       *be )
 {
-       monitor_info_t  *mi;
        int             rc;
        struct berval   dn, ndn;
        struct berval   bv;
@@ -1390,8 +1402,8 @@ monitor_back_db_init(
        rc = dnNormalize( 0, NULL, NULL, &dn, &ndn, NULL );
        if( rc != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_ANY,
-                       "unable to normalize monitor DN \"%s\"\n",
-                       SLAPD_MONITOR_DN, 0, 0 );
+                       "unable to normalize monitor DN \"%s\" (%d)\n",
+                       dn.bv_val, rc, 0 );
                return -1;
        }
 
@@ -1401,11 +1413,9 @@ monitor_back_db_init(
 
        /* NOTE: only one monitor database is allowed,
         * so we use static storage */
-       mi = &monitor_info;
+       ldap_pvt_thread_mutex_init( &monitor_info.mi_cache_mutex );
 
-       ldap_pvt_thread_mutex_init( &mi->mi_cache_mutex );
-
-       be->be_private = mi;
+       be->be_private = &monitor_info;
 
        return 0;
 }
@@ -1758,6 +1768,10 @@ monitor_back_db_destroy(
 {
        monitor_info_t  *mi = ( monitor_info_t * )be->be_private;
 
+       if ( mi == NULL ) {
+               return -1;
+       }
+
        /*
         * FIXME: destroys all the data
         */
@@ -1766,9 +1780,25 @@ monitor_back_db_destroy(
        (void)monitor_cache_destroy( mi );
 
        if ( monitor_subsys ) {
+               int     i;
+
+               for ( i = 0; monitor_subsys[ i ] != NULL; i++ ) {
+                       if ( monitor_subsys[ i ]->mss_destroy ) {
+                               monitor_subsys[ i ]->mss_destroy( be, monitor_subsys[ i ] );
+                       }
+
+                       if ( !BER_BVISNULL( &monitor_subsys[ i ]->mss_rdn ) ) {
+                               ch_free( monitor_subsys[ i ]->mss_rdn.bv_val );
+                       }
+               }
+
                ch_free( monitor_subsys );
        }
        
+       ldap_pvt_thread_mutex_destroy( &monitor_info.mi_cache_mutex );
+
+       be->be_private = NULL;
+
        return 0;
 }