]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/monitor.c
implement support for selective iteration in slaptools (ITS#6442)
[openldap] / servers / slapd / back-bdb / monitor.c
index 2271940de1eb18680a3f2c7a558061a584459194..598ca6a19147fcdbca59d76ed43be3dc2940f16b 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2007 The OpenLDAP Foundation.
+ * Copyright 2000-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -158,17 +158,17 @@ bdb_monitor_update(
        a = attr_find( e->e_attrs, ad_olmBDBEntryCache );
        assert( a != NULL );
        bv.bv_val = buf;
-       bv.bv_len = snprintf( buf, sizeof( buf ), "%d", bdb->bi_cache.c_cursize );
+       bv.bv_len = snprintf( buf, sizeof( buf ), "%lu", bdb->bi_cache.c_cursize );
        ber_bvreplace( &a->a_vals[ 0 ], &bv );
 
        a = attr_find( e->e_attrs, ad_olmBDBDNCache );
        assert( a != NULL );
-       bv.bv_len = snprintf( buf, sizeof( buf ), "%d", bdb->bi_cache.c_eiused );
+       bv.bv_len = snprintf( buf, sizeof( buf ), "%lu", bdb->bi_cache.c_eiused );
        ber_bvreplace( &a->a_vals[ 0 ], &bv );
 
        a = attr_find( e->e_attrs, ad_olmBDBIDLCache );
        assert( a != NULL );
-       bv.bv_len = snprintf( buf, sizeof( buf ), "%d", bdb->bi_idl_cache_size );
+       bv.bv_len = snprintf( buf, sizeof( buf ), "%lu", bdb->bi_idl_cache_size );
        ber_bvreplace( &a->a_vals[ 0 ], &bv );
        
 #ifdef BDB_MONITOR_IDX
@@ -266,8 +266,8 @@ bdb_monitor_initialize( void )
                argv[ 2 ] = s_oid[ i ].oid;
 
                if ( parse_oidm( &c, 0, NULL ) != 0 ) {
-                       Debug( LDAP_DEBUG_ANY,
-                               "bdb_monitor_initialize: unable to add "
+                       Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_monitor_initialize)
+                               ": unable to add "
                                "objectIdentifier \"%s=%s\"\n",
                                s_oid[ i ].name, s_oid[ i ].oid, 0 );
                        return 1;
@@ -277,21 +277,23 @@ bdb_monitor_initialize( void )
        for ( i = 0; s_at[ i ].desc != NULL; i++ ) {
                code = register_at( s_at[ i ].desc, s_at[ i ].ad, 1 );
                if ( code != LDAP_SUCCESS ) {
-                       Debug( LDAP_DEBUG_ANY,
-                               "bdb_monitor_initialize: register_at failed\n",
+                       Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_monitor_initialize)
+                               ": register_at failed\n",
                                0, 0, 0 );
+               } else {
+                       (*s_at[ i ].ad)->ad_type->sat_flags |= SLAP_AT_HIDE;
                }
-               (*s_at[ i ].ad)->ad_type->sat_flags |= SLAP_AT_HIDE;
        }
 
        for ( i = 0; s_oc[ i ].desc != NULL; i++ ) {
                code = register_oc( s_oc[ i ].desc, s_oc[ i ].oc, 1 );
                if ( code != LDAP_SUCCESS ) {
-                       Debug( LDAP_DEBUG_ANY,
-                               "bdb_monitor_initialize: register_oc failed\n",
+                       Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_monitor_initialize)
+                               ": register_oc failed\n",
                                0, 0, 0 );
+               } else {
+                       (*s_oc[ i ].oc)->soc_flags |= SLAP_OC_HIDE;
                }
-               (*s_oc[ i ].oc)->soc_flags |= SLAP_OC_HIDE;
        }
 
        return 0;
@@ -305,10 +307,6 @@ bdb_monitor_db_init( BackendDB *be )
 {
        struct bdb_info         *bdb = (struct bdb_info *) be->be_private;
 
-       if ( SLAP_GLUE_SUBORDINATE( be ) ) {
-               return 0;
-       }
-
        if ( bdb_monitor_initialize() == LDAP_SUCCESS ) {
                /* monitoring in back-bdb is on by default */
                SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_MONITORING;
@@ -340,10 +338,6 @@ bdb_monitor_db_open( BackendDB *be )
                return 0;
        }
 
-       if ( SLAP_GLUE_SUBORDINATE( be ) ) {
-               return 0;
-       }
-
        mi = backend_info( "monitor" );
        if ( !mi || !mi->bi_extra ) {
                SLAP_DBFLAGS( be ) ^= SLAP_DBFLAG_MONITORING;
@@ -356,8 +350,8 @@ bdb_monitor_db_open( BackendDB *be )
                static int warning = 0;
 
                if ( warning++ == 0 ) {
-                       Debug( LDAP_DEBUG_ANY, "bdb_monitor_open: "
-                               "monitoring disabled; "
+                       Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(bdb_monitor_db_open)
+                               "monitoring disabled; "
                                "configure monitor database to enable\n",
                                0, 0, 0 );
                }
@@ -395,7 +389,7 @@ bdb_monitor_db_open( BackendDB *be )
        {
                struct berval   bv, nbv;
                ber_len_t       pathlen = 0, len = 0;
-               char            path[ PATH_MAX ] = { '\0' };
+               char            path[ MAXPATHLEN ] = { '\0' };
                char            *fname = bdb->bi_dbenv_home,
                                *ptr;
 
@@ -491,10 +485,6 @@ bdb_monitor_db_close( BackendDB *be )
 {
        struct bdb_info         *bdb = (struct bdb_info *) be->be_private;
 
-       if ( SLAP_GLUE_SUBORDINATE( be ) ) {
-               return 0;
-       }
-
        if ( !BER_BVISNULL( &bdb->bi_monitor.bdm_ndn ) ) {
                BackendInfo             *mi = backend_info( "monitor" );
                monitor_extra_t         *mbe;
@@ -518,18 +508,12 @@ bdb_monitor_db_close( BackendDB *be )
 int
 bdb_monitor_db_destroy( BackendDB *be )
 {
-       if ( SLAP_GLUE_SUBORDINATE( be ) ) {
-               return 0;
-       }
-
 #ifdef BDB_MONITOR_IDX
-       {
-               struct bdb_info         *bdb = (struct bdb_info *) be->be_private;
+       struct bdb_info         *bdb = (struct bdb_info *) be->be_private;
 
-               /* TODO: free tree */
-               ldap_pvt_thread_mutex_destroy( &bdb->bi_idx_mutex );
-               avl_free( bdb->bi_idx, ch_free );
-       }
+       /* TODO: free tree */
+       ldap_pvt_thread_mutex_destroy( &bdb->bi_idx_mutex );
+       avl_free( bdb->bi_idx, ch_free );
 #endif /* BDB_MONITOR_IDX */
 
        return 0;
@@ -551,9 +535,9 @@ bdb_monitor_bitmask2key( slap_mask_t bitmask )
 {
        int     key;
 
-       for ( key = 0; key < 8*sizeof(slap_mask_t) && !( bitmask & 0x1U ); key++ ) {
+       for ( key = 0; key < 8 * (int)sizeof(slap_mask_t) && !( bitmask & 0x1U );
+                       key++ )
                bitmask >>= 1;
-       }
 
        return key;
 }