X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fback-ldap%2Fmonitor.c;h=1086c144739e3c8be768304dd5b17ab37a15f239;hb=1add666e5a6ace4281df809ad5d37c4534333616;hp=6623a3af5214a704581dd8ffbe3ed032138aebd8;hpb=487d3966eea565e8768b5b7b06f1dca7181d467e;p=openldap diff --git a/servers/slapd/back-ldap/monitor.c b/servers/slapd/back-ldap/monitor.c index 6623a3af52..95999769c4 100644 --- a/servers/slapd/back-ldap/monitor.c +++ b/servers/slapd/back-ldap/monitor.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2003-2012 The OpenLDAP Foundation. + * Copyright 2003-2015 The OpenLDAP Foundation. * Portions Copyright 1999-2003 Howard Chu. * Portions Copyright 2000-2003 Pierangelo Masarati. * All rights reserved. @@ -37,6 +37,9 @@ static ObjectClass *oc_olmLDAPDatabase; static ObjectClass *oc_olmLDAPConnection; +static ObjectClass *oc_monitorContainer; +static ObjectClass *oc_monitorCounterObject; + static AttributeDescription *ad_olmDbURIList; static AttributeDescription *ad_olmDbOperations; static AttributeDescription *ad_olmDbBoundDN; @@ -155,6 +158,16 @@ static struct { { NULL } }; +static struct { + char *name; + ObjectClass **oc; +} s_moc[] = { + { "monitorContainer", &oc_monitorContainer }, + { "monitorCounterObject", &oc_monitorCounterObject }, + + { NULL } +}; + static struct { char *desc; ObjectClass **oc; @@ -377,6 +390,7 @@ ldap_back_monitor_subsystem_destroy( */ struct ldap_back_monitor_conn_arg { + Operation *op; monitor_subsys_t *ms; Entry **ep; }; @@ -467,29 +481,18 @@ ldap_back_monitor_conn_entry( { Entry *e; monitor_entry_t *mp; + monitor_extra_t *mbe = arg->op->o_bd->bd_info->bi_extra; char buf[SLAP_TEXT_BUFLEN]; char *ptr; - struct berval bv, dn, ndn; + struct berval bv; int i; - e = entry_alloc(); - bv.bv_val = buf; bv.bv_len = snprintf( bv.bv_val, SLAP_TEXT_BUFLEN, "cn=Connection %lu", lc->lc_connid ); - build_new_dn( &dn, &arg->ms->mss_dn, &bv, NULL ); - build_new_dn( &ndn, &arg->ms->mss_ndn, &bv, NULL ); - - e->e_name = dn; - e->e_nname = ndn; - - bv.bv_val += 3; - bv.bv_len -= 3; - attr_merge_normalize_one( e, slap_schema.si_ad_cn, &bv, NULL ); - - BER_BVSTR( &bv, "monitorContainer" ); - attr_merge_normalize_one( e, slap_schema.si_ad_objectClass, &bv, NULL ); + e = mbe->entry_stub( &arg->ms->mss_dn, &arg->ms->mss_ndn, &bv, + oc_monitorContainer, NULL, NULL ); attr_merge_normalize_one( e, ad_olmDbBoundDN, &lc->lc_bound_ndn, NULL ); @@ -511,7 +514,7 @@ ldap_back_monitor_conn_entry( attr_merge_normalize_one( e, ad_olmDbPeerAddress, &bv, NULL ); ch_free( bv.bv_val ); - mp = monitor_entrypriv_create(); + mp = mbe->entrypriv_create(); e->e_private = mp; mp->mp_info = arg->ms; mp->mp_flags = MONITOR_F_SUB | MONITOR_F_VOLATILE; @@ -545,6 +548,7 @@ ldap_back_monitor_conn_create( li = (ldapinfo_t *)ms->mss_private; arg = ch_calloc( 1, sizeof(struct ldap_back_monitor_conn_arg) ); + arg->op = op; arg->ep = ep; arg->ms = ms; @@ -574,14 +578,12 @@ ldap_back_monitor_conn_init( monitor_subsys_t *ms ) { ldapinfo_t *li = (ldapinfo_t *) ms->mss_private; - monitor_info_t *mi; monitor_extra_t *mbe; Entry *e; int rc; assert( be != NULL ); - mi = (monitor_info_t *) be->be_private; mbe = (monitor_extra_t *) be->bd_info->bi_extra; ms->mss_dn = ms->mss_ndn = li->li_monitor_info.lmi_ndn; @@ -589,9 +591,8 @@ ldap_back_monitor_conn_init( ms->mss_create = ldap_back_monitor_conn_create; ms->mss_destroy = ldap_back_monitor_subsystem_destroy; - e = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn, - &ms->mss_rdn, - mi->mi_oc_monitorContainer, mi, NULL, NULL ); + e = mbe->entry_stub( &ms->mss_dn, &ms->mss_ndn, + &ms->mss_rdn, oc_monitorContainer, NULL, NULL ); if ( e == NULL ) { Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_conn_init: " @@ -655,7 +656,7 @@ ldap_back_monitor_conn_init( cb->mc_free = ldap_back_monitor_free; cb->mc_private = (void *)li; - rc = mbe->register_entry_attrs( &ms->mss_ndn, a, cb, NULL, 0, NULL ); + rc = mbe->register_entry_attrs( &ms->mss_ndn, a, cb, NULL, -1, NULL ); attr_free( a->a_next ); attr_free( a ); @@ -733,7 +734,6 @@ ldap_back_monitor_ops_init( { ldapinfo_t *li = (ldapinfo_t *) ms->mss_private; - monitor_info_t *mi; monitor_extra_t *mbe; Entry *e, *parent; int rc; @@ -742,16 +742,14 @@ ldap_back_monitor_ops_init( assert( be != NULL ); - mi = (monitor_info_t *) be->be_private; mbe = (monitor_extra_t *) be->bd_info->bi_extra; ms->mss_dn = ms->mss_ndn = li->li_monitor_info.lmi_ndn; ms->mss_rdn = li->li_monitor_info.lmi_ops_rdn; ms->mss_destroy = ldap_back_monitor_subsystem_destroy; - parent = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn, - &ms->mss_rdn, - mi->mi_oc_monitorContainer, mi, NULL, NULL ); + parent = mbe->entry_stub( &ms->mss_dn, &ms->mss_ndn, + &ms->mss_rdn, oc_monitorContainer, NULL, NULL ); if ( parent == NULL ) { Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_ops_init: " @@ -779,9 +777,9 @@ ldap_back_monitor_ops_init( monitor_callback_t *cb; struct ldap_back_monitor_op_counter *counter; - e = monitor_entry_stub( &parent->e_name, &parent->e_nname, + e = mbe->entry_stub( &parent->e_name, &parent->e_nname, &ldap_back_monitor_op[op].rdn, - mi->mi_oc_monitorCounterObject, mi, NULL, NULL ); + oc_monitorCounterObject, NULL, NULL ); if ( e == NULL ) { Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_ops_init: " @@ -902,6 +900,17 @@ ldap_back_monitor_initialize( void ) } } + for ( i = 0; s_moc[ i ].name != NULL; i++ ) { + *s_moc[i].oc = oc_find( s_moc[ i ].name ); + if ( ! *s_moc[i].oc ) { + Debug( LDAP_DEBUG_ANY, + "ldap_back_monitor_initialize: failed to find objectClass (%s)\n", + s_moc[ i ].name, 0, 0 ); + return 5; + + } + } + return ( ldap_back_monitor_initialized_failure = LDAP_SUCCESS ); } @@ -990,7 +999,7 @@ ldap_back_monitor_db_open( BackendDB *be ) mss->mss_open = ldap_back_monitor_conn_init; mss->mss_private = li; - if ( mbe->register_subsys( mss ) ) + if ( mbe->register_subsys_late( mss ) ) { Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_db_open: " @@ -1005,7 +1014,7 @@ ldap_back_monitor_db_open( BackendDB *be ) mss->mss_open = ldap_back_monitor_ops_init; mss->mss_private = li; - if ( mbe->register_subsys( mss ) ) + if ( mbe->register_subsys_late( mss ) ) { Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_db_open: "