Skip to content
Snippets Groups Projects
Commit 8eab4870 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

further improve monitoring setup and cleanup

parent 2dac2e27
No related branches found
No related tags found
No related merge requests found
......@@ -45,6 +45,7 @@ static int
bdb_db_init( BackendDB *be )
{
struct bdb_info *bdb;
int rc;
Debug( LDAP_DEBUG_TRACE,
LDAP_XSTRING(bdb_db_init) ": Initializing " BDB_UCTYPE " database\n",
......@@ -80,7 +81,9 @@ bdb_db_init( BackendDB *be )
be->be_private = bdb;
be->be_cf_ocs = be->bd_info->bi_cf_ocs;
return 0;
rc = bdb_monitor_init( be );
return rc;
}
static int
......@@ -447,7 +450,7 @@ bdb_db_close( BackendDB *be )
struct bdb_db_info *db;
bdb_idl_cache_entry_t *entry, *next_entry;
/* monitor setup */
/* monitor handling */
(void)bdb_monitor_close( be );
bdb->bi_flags &= ~BDB_IS_OPEN;
......
......@@ -330,6 +330,8 @@ done_oc:;
int
bdb_monitor_init( BackendDB *be )
{
SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_MONITORING;
return 0;
}
......@@ -364,11 +366,7 @@ bdb_monitor_open( BackendDB *be )
return 0;
}
/* monitor_back_register_entry_attrs() with a NULL ndn,
* base="cn=Databases,cn=Monitor", scope=LDAP_SCOPE_ONE
* and filter="(namingContexts:distinguishedNameMatch:=<suffix>)" */
bdb->bi_monitor.bdm_scope = LDAP_SCOPE_ONELEVEL;
bdb->bi_monitor.bdm_scope = LDAP_SCOPE_SUBORDINATE;
base = &bdb->bi_monitor.bdm_nbase;
BER_BVSTR( base, "cn=databases,cn=monitor" );
filter = &bdb->bi_monitor.bdm_filter;
......@@ -382,12 +380,16 @@ bdb_monitor_open( BackendDB *be )
ldap_bv2escaped_filter_value( &be->be_nsuffix[ 0 ], &suffix );
}
filter->bv_len = STRLENOF( "(namingContexts:distinguishedNameMatch:=)" ) + suffix.bv_len;
filter->bv_len = STRLENOF( "(&(monitoredInfo=" )
+ strlen( be->bd_info->bi_type )
+ STRLENOF( ")(namingContexts:distinguishedNameMatch:=" )
+ suffix.bv_len + STRLENOF( "))" );
ptr = filter->bv_val = ch_malloc( filter->bv_len + 1 );
ptr = lutil_strcopy( ptr, "(namingContexts:distinguishedNameMatch:=" );
ptr = lutil_strcopy( ptr, "(&(monitoredInfo=" );
ptr = lutil_strcopy( ptr, be->bd_info->bi_type );
ptr = lutil_strcopy( ptr, ")(namingContexts:distinguishedNameMatch:=" );
ptr = lutil_strncopy( ptr, suffix.bv_val, suffix.bv_len );
ptr[ 0 ] = ')';
ptr++;
ptr = lutil_strcopy( ptr, "))" );
ptr[ 0 ] = '\0';
assert( filter->bv_len == ptr - filter->bv_val );
......@@ -483,7 +485,7 @@ bdb_monitor_open( BackendDB *be )
cb->mc_private = (void *)bdb;
rc = monitor_back_register_entry_attrs( NULL, a, cb,
base, LDAP_SCOPE_ONELEVEL, filter );
base, LDAP_SCOPE_SUBORDINATE, filter );
cleanup:;
if ( rc != 0 ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment