ldap_pvt_thread_mutex_init( &bdb->bi_idx_mutex );
#endif /* BDB_MONITOR_IDX */
- bdb->bi_monitor.bdm_scope = -1;
-
return 0;
}
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
Attribute *a, *next;
monitor_callback_t *cb = NULL;
- struct berval suffix, *filter, *base;
- char *ptr;
int rc = 0;
BackendInfo *mi;
monitor_extra_t *mbe;
+ struct berval dummy = BER_BVC("");
if ( !SLAP_DBMONITORING( be ) ) {
return 0;
return 0;
}
- if ( bdb->bi_monitor.bdm_scope == -1 ) {
- bdb->bi_monitor.bdm_scope = LDAP_SCOPE_ONELEVEL;
- }
- base = &bdb->bi_monitor.bdm_nbase;
- BER_BVSTR( base, "cn=databases,cn=monitor" );
- filter = &bdb->bi_monitor.bdm_filter;
- BER_BVZERO( filter );
-
- suffix.bv_len = ldap_bv2escaped_filter_value_len( &be->be_nsuffix[ 0 ] );
- if ( suffix.bv_len == be->be_nsuffix[ 0 ].bv_len ) {
- suffix = be->be_nsuffix[ 0 ];
-
- } else {
- ldap_bv2escaped_filter_value( &be->be_nsuffix[ 0 ], &suffix );
- }
-
- if ( BER_BVISEMPTY( &suffix ) ) {
- /* frontend also has empty suffix, sigh! */
- filter->bv_len = STRLENOF( "(&(namingContexts:distinguishedNameMatch:=" )
- + suffix.bv_len + STRLENOF( ")(!(cn=frontend)))" );
- ptr = filter->bv_val = ch_malloc( filter->bv_len + 1 );
- ptr = lutil_strcopy( ptr, "(&(namingContexts:distinguishedNameMatch:=" );
- ptr = lutil_strncopy( ptr, suffix.bv_val, suffix.bv_len );
- ptr = lutil_strcopy( ptr, ")(!(cn=frontend)))" );
-
- } else {
- /* just look for the naming context */
- filter->bv_len = 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_strncopy( ptr, suffix.bv_val, suffix.bv_len );
- ptr = lutil_strcopy( ptr, ")" );
- }
- ptr[ 0 ] = '\0';
- assert( filter->bv_len == ptr - filter->bv_val );
-
- if ( suffix.bv_val != be->be_nsuffix[ 0 ].bv_val ) {
- ch_free( suffix.bv_val );
- }
-
/* alloc as many as required (plus 1 for objectClass) */
a = attrs_alloc( 1 + 4 );
if ( a == NULL ) {
cb->mc_private = (void *)bdb;
/* make sure the database is registered; then add monitor attributes */
- rc = mbe->register_database( be );
+ rc = mbe->register_database( be, &bdb->bi_monitor.bdm_ndn );
if ( rc == 0 ) {
- rc = mbe->register_entry_attrs( NULL, a, cb,
- base, bdb->bi_monitor.bdm_scope, filter );
+ rc = mbe->register_entry_attrs( &bdb->bi_monitor.bdm_ndn, a, cb,
+ &dummy, 0, &dummy );
}
cleanup:;
attrs_free( a );
a = NULL;
}
-
- if ( !BER_BVISNULL( filter ) ) {
- ch_free( filter->bv_val );
- BER_BVZERO( filter );
- }
}
/* store for cleanup */
return 0;
}
- if ( !BER_BVISNULL( &bdb->bi_monitor.bdm_filter ) ) {
+ if ( !BER_BVISNULL( &bdb->bi_monitor.bdm_ndn ) ) {
BackendInfo *mi = backend_info( "monitor" );
monitor_extra_t *mbe;
if ( mi && &mi->bi_extra ) {
mbe = mi->bi_extra;
- mbe->unregister_entry_callback( NULL,
+ mbe->unregister_entry_callback( &bdb->bi_monitor.bdm_ndn,
(monitor_callback_t *)bdb->bi_monitor.bdm_cb,
- &bdb->bi_monitor.bdm_nbase,
- bdb->bi_monitor.bdm_scope,
- &bdb->bi_monitor.bdm_filter );
- }
-
- if ( !BER_BVISNULL( &bdb->bi_monitor.bdm_filter ) ) {
- ch_free( bdb->bi_monitor.bdm_filter.bv_val );
+ NULL, 0, NULL );
}
memset( &bdb->bi_monitor, 0, sizeof( bdb->bi_monitor ) );
slap_overinst *el_on;
Entry *el_e;
Attribute *el_a;
- struct berval el_ndn;
+ struct berval *el_ndn;
struct berval el_nbase;
int el_scope;
struct berval el_filter;
int
monitor_back_register_database_limbo(
- BackendDB *be )
+ BackendDB *be,
+ struct berval *ndn )
{
entry_limbo_t **elpp, el = { 0 };
monitor_info_t *mi;
el.el_type = LIMBO_DATABASE;
el.el_be = be;
+ el.el_ndn = ndn;
for ( elpp = &mi->mi_entry_limbo;
*elpp;
entry_limbo_t **elpp, el = { 0 };
el.el_type = LIMBO_ATTRS;
- if ( !BER_BVISNULL( &ndn ) ) {
- ber_dupbv( &el.el_ndn, &ndn );
- }
+ el.el_ndn = ndn_in;
if ( !BER_BVISNULL( nbase ) ) {
ber_dupbv( &el.el_nbase, nbase);
}
if ( !BER_BVISNULL( &el.el_nbase ) ) {
ch_free( &el.el_nbase.bv_val );
}
- if ( !BER_BVISNULL( &el.el_ndn ) ) {
- ch_free( el.el_ndn.bv_val );
- }
return -1;
}
}
if ( el->el_a ) {
attrs_free( el->el_a );
}
- if ( !BER_BVISNULL( &el->el_ndn ) ) {
- ber_memfree( el->el_ndn.bv_val );
- }
if ( !BER_BVISNULL( &el->el_nbase ) ) {
ber_memfree( el->el_nbase.bv_val );
}
case LIMBO_ATTRS:
rc = monitor_back_register_entry_attrs(
- &el->el_ndn,
+ el->el_ndn,
el->el_a,
el->el_cb,
&el->el_nbase,
case LIMBO_CB:
rc = monitor_back_register_entry_callback(
- &el->el_ndn,
+ el->el_ndn,
el->el_cb,
&el->el_nbase,
el->el_scope,
break;
case LIMBO_DATABASE:
- rc = monitor_back_register_database( el->el_be );
+ rc = monitor_back_register_database( el->el_be, el->el_ndn );
break;
case LIMBO_OVERLAY_INFO: