From: Pierangelo Masarati Date: Mon, 7 Apr 2003 23:22:27 +0000 (+0000) Subject: fix attr nvals & more improvements X-Git-Tag: OPENLDAP_REL_ENG_2_2_0ALPHA~430 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f73eddd42633a08e7a10236d8b2b593487b9e867;p=openldap fix attr nvals & more improvements --- diff --git a/servers/slapd/back-monitor/back-monitor.h b/servers/slapd/back-monitor/back-monitor.h index a16f8fb7d9..3037e8655e 100644 --- a/servers/slapd/back-monitor/back-monitor.h +++ b/servers/slapd/back-monitor/back-monitor.h @@ -203,6 +203,7 @@ struct monitorsubsys { extern struct monitorsubsys monitor_subsys[]; extern AttributeDescription *monitor_ad_desc; +extern slap_mr_normalize_func *monitor_ad_normalize; extern BackendDB *be_monitor; /* diff --git a/servers/slapd/back-monitor/backend.c b/servers/slapd/back-monitor/backend.c index e19d1d6e80..aab3ff7b26 100644 --- a/servers/slapd/back-monitor/backend.c +++ b/servers/slapd/back-monitor/backend.c @@ -76,7 +76,8 @@ monitor_subsys_backend_init( for ( i = nBackendInfo; i--; ) { char buf[1024]; BackendInfo *bi; - struct berval bv[ 2 ]; + struct berval bv, nbv; + int rc; bi = &backendInfo[i]; @@ -106,20 +107,34 @@ monitor_subsys_backend_init( return( -1 ); } - bv[0].bv_val = bi->bi_type; - bv[0].bv_len = strlen( bv[0].bv_val ); - bv[1].bv_val = NULL; + bv.bv_val = bi->bi_type; + bv.bv_len = strlen( bv.bv_val ); + + nbv.bv_val = NULL; + if ( monitor_ad_normalize ) { + rc = monitor_ad_normalize( + 0, + monitor_ad_desc->ad_type->sat_syntax, + monitor_ad_desc->ad_type->sat_equality, + &bv, &nbv ); + if ( rc ) { + return( -1 ); + } + } - attr_mergeit( e, monitor_ad_desc, bv ); - attr_mergeit( e_backend, monitor_ad_desc, bv ); + attr_merge_one( e, monitor_ad_desc, &bv, + nbv.bv_val ? &nbv : NULL ); + attr_merge_one( e_backend, monitor_ad_desc, &bv, + nbv.bv_val ? &nbv : NULL ); + ch_free( nbv.bv_val ); if ( bi->bi_controls ) { int j; for ( j = 0; bi->bi_controls[ j ]; j++ ) { - bv[0].bv_val = bi->bi_controls[ j ]; - bv[0].bv_len = strlen( bv[0].bv_val ); - attr_mergeit( e, slap_schema.si_ad_supportedControl, bv ); + bv.bv_val = bi->bi_controls[ j ]; + bv.bv_len = strlen( bv.bv_val ); + attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL ); } } diff --git a/servers/slapd/back-monitor/compare.c b/servers/slapd/back-monitor/compare.c index 798218dbdc..4e04e52b44 100644 --- a/servers/slapd/back-monitor/compare.c +++ b/servers/slapd/back-monitor/compare.c @@ -49,15 +49,15 @@ monitor_back_compare( struct slap_op *op, struct slap_rep *rs) /* get entry with reader lock */ monitor_cache_dn2entry( mi, &op->o_req_ndn, &e, &matched ); if ( e == NULL ) { + rs->sr_err = LDAP_NO_SUCH_OBJECT; if ( matched ) { - rs->sr_matched = ch_strdup( matched->e_dn ); - monitor_cache_release( mi, matched ); + rs->sr_matched = matched->e_dn; } - rs->sr_err = LDAP_NO_SUCH_OBJECT; - send_ldap_result( op, rs ); - - rs->sr_matched = NULL; + if ( matched ) { + monitor_cache_release( mi, matched ); + rs->sr_matched = NULL; + } return( 0 ); } diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 651ef7df16..8b8287f201 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -51,7 +51,7 @@ monitor_subsys_conn_init( Entry *e, *e_tmp, *e_conn; struct monitorentrypriv *mp; char buf[1024]; - struct berval bv[2]; + struct berval bv; assert( be != NULL ); @@ -102,10 +102,9 @@ monitor_subsys_conn_init( return( -1 ); } - bv[1].bv_val = NULL; - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -160,10 +159,9 @@ monitor_subsys_conn_init( return( -1 ); } - bv[1].bv_val = NULL; - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -257,7 +255,7 @@ conn_create( char buf2[ LDAP_LUTIL_GENTIME_BUFSIZE ]; char buf3[ LDAP_LUTIL_GENTIME_BUFSIZE ]; - struct berval bv[2]; + struct berval bv; Entry *e; @@ -333,10 +331,9 @@ conn_create( buf3 ); - bv[1].bv_val = NULL; - bv[0].bv_val = buf; - bv[0].bv_len = strlen( buf ); - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = buf; + bv.bv_len = strlen( buf ); + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index 05a6688f8a..9fde6ca711 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -136,11 +136,11 @@ monitor_subsys_database_init( } if ( be->be_flags & SLAP_BFLAG_MONITOR ) { - attr_mergeit( e, ad_mc, be->be_suffix ); - attr_mergeit( e_database, ad_mc, be->be_suffix ); + attr_merge( e, ad_mc, be->be_suffix, be->be_nsuffix ); + attr_merge( e_database, ad_mc, be->be_suffix, be->be_nsuffix ); } else { - attr_mergeit( e, ad_nc, be->be_suffix ); - attr_mergeit( e_database, ad_nc, be->be_suffix ); + attr_merge( e, ad_nc, be->be_suffix, be->be_nsuffix ); + attr_merge( e_database, ad_nc, be->be_suffix, be->be_nsuffix ); } for ( j = nBackendInfo; j--; ) { diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 770f8e0bf8..a929562301 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -44,6 +44,7 @@ * used by many functions to add description to entries */ AttributeDescription *monitor_ad_desc = NULL; +slap_mr_normalize_func *monitor_ad_normalize = NULL; BackendDB *be_monitor = NULL; /* @@ -244,7 +245,7 @@ monitor_back_db_init( char buf[1024], *end_of_line; struct berval dn, ndn; const char *text; - struct berval bv[2]; + struct berval bv; /* * database monitor can be defined once only @@ -281,8 +282,8 @@ monitor_back_db_init( return -1; } - ber_dupbv( &bv[0], &dn ); - ber_bvarray_add( &be->be_suffix, &bv[0] ); + ber_dupbv( &bv, &dn ); + ber_bvarray_add( &be->be_suffix, &bv ); ber_bvarray_add( &be->be_nsuffix, &ndn ); mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 ); @@ -300,6 +301,10 @@ monitor_back_db_init( return( -1 ); } + if ( monitor_ad_desc->ad_type->sat_equality ) { + monitor_ad_normalize = monitor_ad_desc->ad_type->sat_equality->smr_normalize; + } + /* * Create all the subsystem specific entries */ @@ -417,15 +422,14 @@ monitor_back_db_init( #endif return( -1 ); } - bv[1].bv_val = NULL; - bv[0].bv_val = (char *) Versionstr; + bv.bv_val = (char *) Versionstr; end_of_line = strchr( Versionstr, '\n' ); if ( end_of_line ) { - bv[0].bv_len = end_of_line - Versionstr; + bv.bv_len = end_of_line - Versionstr; } else { - bv[0].bv_len = strlen( Versionstr ); + bv.bv_len = strlen( Versionstr ); } - if ( attr_mergeit( e, monitor_ad_desc, bv ) ) { + if ( attr_merge_one( e, monitor_ad_desc, &bv, NULL ) ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, CRIT, "unable to add description to '%s' entry\n", diff --git a/servers/slapd/back-monitor/listener.c b/servers/slapd/back-monitor/listener.c index c66e1c5f2f..b862fcd0f8 100644 --- a/servers/slapd/back-monitor/listener.c +++ b/servers/slapd/back-monitor/listener.c @@ -122,20 +122,54 @@ monitor_subsys_listener_init( #ifdef HAVE_TLS if ( l[i]->sl_is_tls ) { - struct berval bv[2]; - bv[1].bv_val = NULL; - bv[0].bv_val = "TLS"; - bv[0].bv_len = sizeof("TLS")-1; - attr_mergeit( e, monitor_ad_desc, bv ); + struct berval bv, nbv; + + bv.bv_val = "TLS"; + bv.bv_len = sizeof("TLS")-1; + + nbv.bv_val = NULL; + if ( monitor_ad_normalize ) { + int rc; + + rc = monitor_ad_normalize( + 0, + monitor_ad_desc->ad_type->sat_syntax, + monitor_ad_desc->ad_type->sat_equality, + &bv, &nbv ); + if ( rc ) { + return( -1 ); + } + } + + attr_merge_one( e, monitor_ad_desc, &bv, + nbv.bv_val ? &nbv : NULL ); + ch_free( nbv.bv_val ); } #endif /* HAVE_TLS */ #ifdef LDAP_CONNECTIONLESS if ( l[i]->sl_is_udp ) { - struct berval bv[2]; - bv[1].bv_val = NULL; - bv[0].bv_val = "UDP"; - bv[0].bv_len = sizeof("UDP")-1; - attr_mergeit( e, monitor_ad_desc, bv ); + struct berval bv, nbv; + + bv.bv_val = "UDP"; + bv.bv_len = sizeof("UDP")-1; + + nbv.bv_val = NULL; + if ( monitor_ad_normalize ) { + int rc; + + rc = monitor_ad_normalize( + 0, + monitor_ad_desc->ad_type->sat_syntax, + monitor_ad_desc->ad_type->sat_equality, + &bv, &nbv ); + if ( rc ) { + return( -1 ); + } + } + + attr_merge_one( e, monitor_ad_desc, &bv, + nbv.bv_val ? &nbv : NULL ); + ch_free( nbv.bv_val ); } #endif /* HAVE_TLS */ diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index d9823bf4c3..8bc0dd0d18 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -38,6 +38,7 @@ #include #include "slap.h" +#include #include "lutil.h" #include "ldif.h" #include "back-monitor.h" @@ -49,27 +50,28 @@ ldap_pvt_thread_mutex_t monitor_log_mutex; static struct { int i; - const char *s; + struct berval s; + struct berval n; } int_2_level[] = { - { LDAP_DEBUG_TRACE, "Trace" }, - { LDAP_DEBUG_PACKETS, "Packets" }, - { LDAP_DEBUG_ARGS, "Args" }, - { LDAP_DEBUG_CONNS, "Conns" }, - { LDAP_DEBUG_BER, "BER" }, - { LDAP_DEBUG_FILTER, "Filter" }, - { LDAP_DEBUG_CONFIG, "Config" }, /* useless */ - { LDAP_DEBUG_ACL, "ACL" }, - { LDAP_DEBUG_STATS, "Stats" }, - { LDAP_DEBUG_STATS2, "Stats2" }, - { LDAP_DEBUG_SHELL, "Shell" }, - { LDAP_DEBUG_PARSE, "Parse" }, - { LDAP_DEBUG_CACHE, "Cache" }, - { LDAP_DEBUG_INDEX, "Index" }, - { 0, NULL } + { LDAP_DEBUG_TRACE, BER_BVC("Trace"), { 0, NULL } }, + { LDAP_DEBUG_PACKETS, BER_BVC("Packets"), { 0, NULL } }, + { LDAP_DEBUG_ARGS, BER_BVC("Args"), { 0, NULL } }, + { LDAP_DEBUG_CONNS, BER_BVC("Conns"), { 0, NULL } }, + { LDAP_DEBUG_BER, BER_BVC("BER"), { 0, NULL } }, + { LDAP_DEBUG_FILTER, BER_BVC("Filter"), { 0, NULL } }, + { LDAP_DEBUG_CONFIG, BER_BVC("Config"), { 0, NULL } }, /* useless */ + { LDAP_DEBUG_ACL, BER_BVC("ACL"), { 0, NULL } }, + { LDAP_DEBUG_STATS, BER_BVC("Stats"), { 0, NULL } }, + { LDAP_DEBUG_STATS2, BER_BVC("Stats2"), { 0, NULL } }, + { LDAP_DEBUG_SHELL, BER_BVC("Shell"), { 0, NULL } }, + { LDAP_DEBUG_PARSE, BER_BVC("Parse"), { 0, NULL } }, + { LDAP_DEBUG_CACHE, BER_BVC("Cache"), { 0, NULL } }, + { LDAP_DEBUG_INDEX, BER_BVC("Index"), { 0, NULL } }, + { 0, { 0, NULL }, { 0, NULL } } }; -static int loglevel2int( const char *str ); -static const char * int2loglevel( int n ); +static int loglevel2int( struct berval *l ); +static int int2loglevel( int n ); static int add_values( Entry *e, Modification *mod, int *newlevel ); static int delete_values( Entry *e, Modification *mod, int *newlevel ); @@ -111,13 +113,27 @@ monitor_subsys_log_init( bv[1].bv_val = NULL; - /* initialize the debug level */ + /* initialize the debug level(s) */ for ( i = 0; int_2_level[ i ].i != 0; i++ ) { - if ( int_2_level[ i ].i & ldap_syslog ) { - bv[0].bv_val = ( char * )int_2_level[ i ].s; - bv[0].bv_len = strlen( bv[0].bv_val ); - attr_mergeit( e, monitor_ad_desc, bv ); + if ( monitor_ad_normalize ) { + int rc; + + rc = monitor_ad_normalize( + 0, + monitor_ad_desc->ad_type->sat_syntax, + monitor_ad_desc->ad_type->sat_equality, + &int_2_level[ i ].s, + &int_2_level[ i ].n ); + if ( rc ) { + return( -1 ); + } + } + + if ( int_2_level[ i ].i & ldap_syslog ) { + attr_merge_one( e, monitor_ad_desc, + &int_2_level[ i ].s, + &int_2_level[ i ].n ); } } @@ -239,12 +255,16 @@ cleanup:; } static int -loglevel2int( const char *str ) +loglevel2int( struct berval *l ) { int i; for ( i = 0; int_2_level[ i ].i != 0; i++ ) { - if ( strcasecmp( str, int_2_level[ i ].s ) == 0 ) { + if ( l->bv_len != int_2_level[ i ].s.bv_len ) { + continue; + } + + if ( strcasecmp( l->bv_val, int_2_level[ i ].s.bv_val ) == 0 ) { return int_2_level[ i ].i; } } @@ -252,18 +272,18 @@ loglevel2int( const char *str ) return 0; } -static const char * +static int int2loglevel( int n ) { int i; for ( i = 0; int_2_level[ i ].i != 0; i++ ) { if ( int_2_level[ i ].i == n ) { - return int_2_level[ i ].s; + return i; } } - return NULL; + return -1; } static int @@ -272,20 +292,27 @@ check_constraints( Modification *mod, int *newlevel ) int i; for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) { - int l; - const char *s; - ber_len_t len; + int l; - l = loglevel2int( mod->sm_bvalues[i].bv_val ); + l = loglevel2int( &mod->sm_bvalues[i] ); if ( !l ) { return LDAP_CONSTRAINT_VIOLATION; } - s = int2loglevel( l ); - len = strlen( s ); - assert( len == mod->sm_bvalues[i].bv_len ); + if ( ( l = int2loglevel( l ) ) == -1 ) { + return LDAP_OTHER; + } + + assert( int_2_level[ l ].s.bv_len + == mod->sm_bvalues[i].bv_len ); - AC_MEMCPY( mod->sm_bvalues[i].bv_val, s, len ); + AC_MEMCPY( mod->sm_bvalues[i].bv_val, + int_2_level[ l ].s.bv_val, + int_2_level[ l ].s.bv_len ); + + AC_MEMCPY( mod->sm_nvalues[i].bv_val, + int_2_level[ l ].n.bv_val, + int_2_level[ l ].n.bv_len ); *newlevel |= l; } @@ -347,7 +374,8 @@ add_values( Entry *e, Modification *mod, int *newlevel ) } /* no - add them */ - if ( attr_mergeit( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) { + if ( attr_merge( e, mod->sm_desc, mod->sm_bvalues, + mod->sm_nvalues ) != 0 ) { /* this should return result of attr_mergeit */ return LDAP_OTHER; } @@ -472,7 +500,8 @@ replace_values( Entry *e, Modification *mod, int *newlevel ) } if ( mod->sm_bvalues != NULL && - attr_mergeit( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) { + attr_merge( e, mod->sm_desc, mod->sm_bvalues, + mod->sm_nvalues ) != 0 ) { return LDAP_OTHER; } diff --git a/servers/slapd/back-monitor/modify.c b/servers/slapd/back-monitor/modify.c index 4383b7eaee..8aa426ecc2 100644 --- a/servers/slapd/back-monitor/modify.c +++ b/servers/slapd/back-monitor/modify.c @@ -76,8 +76,8 @@ monitor_back_modify( Operation *op, SlapReply *rs ) if ( matched != NULL ) { rs->sr_matched = NULL; monitor_cache_release( mi, matched ); - return( 0 ); } + return( 0 ); } if ( !acl_check_modlist( op, e, op->oq_modify.rs_modlist )) { diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index 5ce6d1db26..571a2a0f77 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -65,7 +65,7 @@ monitor_subsys_ops_init( Entry *e, *e_tmp, *e_op, *e_children; struct monitorentrypriv *mp; char buf[1024]; - struct berval bv[2]; + struct berval bv; int i; assert( be != NULL ); @@ -121,10 +121,9 @@ monitor_subsys_ops_init( return( -1 ); } - bv[1].bv_val = NULL; - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -189,10 +188,9 @@ monitor_subsys_ops_init( return( -1 ); } - bv[1].bv_val = NULL; - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -257,9 +255,9 @@ monitor_subsys_ops_init( return( -1 ); } - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -324,9 +322,9 @@ monitor_subsys_ops_init( return( -1 ); } - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; diff --git a/servers/slapd/back-monitor/rww.c b/servers/slapd/back-monitor/rww.c index c68dfab365..5c2e88f530 100644 --- a/servers/slapd/back-monitor/rww.c +++ b/servers/slapd/back-monitor/rww.c @@ -70,7 +70,7 @@ monitor_subsys_readw_update_internal( int nconns, nwritewaiters, nreadwaiters; Attribute *a; - struct berval bv[2], *b = NULL; + struct berval *b = NULL; char buf[1024]; char *str = NULL; @@ -79,8 +79,6 @@ monitor_subsys_readw_update_internal( assert( mi != NULL ); assert( e != NULL ); - bv[1].bv_val = NULL; - nconns = nwritewaiters = nreadwaiters = 0; for ( c = connection_first( &connindex ); c != NULL; @@ -117,9 +115,28 @@ monitor_subsys_readw_update_internal( } if ( b == NULL || b[0].bv_val == NULL ) { - bv[0].bv_val = buf; - bv[0].bv_len = strlen( buf ); - attr_mergeit( e, monitor_ad_desc, bv ); + struct berval bv, nbv; + + bv.bv_val = buf; + bv.bv_len = strlen( buf ); + + nbv.bv_val = NULL; + if ( monitor_ad_normalize ) { + int rc; + + rc = monitor_ad_normalize( + 0, + monitor_ad_desc->ad_type->sat_syntax, + monitor_ad_desc->ad_type->sat_equality, + &bv, &nbv ); + if ( rc ) { + return( -1 ); + } + } + + attr_merge_one( e, monitor_ad_desc, &bv, + nbv.bv_val ? &nbv : NULL ); + ch_free( nbv.bv_val ); } return( 0 ); diff --git a/servers/slapd/back-monitor/search.c b/servers/slapd/back-monitor/search.c index 401b08d68c..6d7587c9fe 100644 --- a/servers/slapd/back-monitor/search.c +++ b/servers/slapd/back-monitor/search.c @@ -156,12 +156,14 @@ monitor_back_search( Operation *op, SlapReply *rs ) if ( e == NULL ) { rs->sr_err = LDAP_NO_SUCH_OBJECT; if ( matched ) { - rs->sr_matched = ch_strdup( matched->e_dn ); - monitor_cache_release( mi, matched ); + rs->sr_matched = matched->e_dn; } send_ldap_result( op, rs ); - rs->sr_matched = NULL; + if ( matched ) { + monitor_cache_release( mi, matched ); + rs->sr_matched = NULL; + } return( 0 ); } diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index 137e8efb8c..972331fd97 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -48,7 +48,7 @@ monitor_subsys_sent_init( Entry *e, *e_tmp, *e_sent; struct monitorentrypriv *mp; char buf[1024]; - struct berval bv[2]; + struct berval bv; assert( be != NULL ); @@ -99,10 +99,9 @@ monitor_subsys_sent_init( return( -1 ); } - bv[1].bv_val = NULL; - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -156,9 +155,9 @@ monitor_subsys_sent_init( return( -1 ); } - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -212,9 +211,9 @@ monitor_subsys_sent_init( return( -1 ); } - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; @@ -268,9 +267,9 @@ monitor_subsys_sent_init( return( -1 ); } - bv[0].bv_val = "0"; - bv[0].bv_len = 1; - attr_mergeit( e, monitor_ad_desc, bv ); + bv.bv_val = "0"; + bv.bv_len = 1; + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); e->e_private = ( void * )mp; diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index 36d7d6132f..7853a9faf1 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -48,8 +48,8 @@ monitor_subsys_thread_init( { struct monitorinfo *mi; Entry *e; - struct berval bv[2]; static char buf[1024]; + struct berval bv; mi = ( struct monitorinfo * )be->be_private; @@ -72,11 +72,10 @@ monitor_subsys_thread_init( /* initialize the thread number */ snprintf( buf, sizeof( buf ), "max=%d", connection_pool_max ); - bv[1].bv_val = NULL; - bv[0].bv_val = buf; - bv[0].bv_len = strlen( bv[0].bv_val ); + bv.bv_val = buf; + bv.bv_len = strlen( bv.bv_val ); - attr_mergeit( e, monitor_ad_desc, bv ); + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); monitor_cache_release( mi, e ); @@ -90,11 +89,9 @@ monitor_subsys_thread_update( ) { Attribute *a; - struct berval bv[2], *b = NULL; + struct berval *b = NULL; char buf[1024]; - bv[1].bv_val = NULL; - snprintf( buf, sizeof( buf ), "backload=%d", ldap_pvt_thread_pool_backload( &connection_pool ) ); @@ -111,9 +108,11 @@ monitor_subsys_thread_update( } if ( b == NULL || b[0].bv_val == NULL ) { - bv[0].bv_val = buf; - bv[0].bv_len = strlen( buf ); - attr_mergeit( e, monitor_ad_desc, bv ); + struct berval bv; + + bv.bv_val = buf; + bv.bv_len = strlen( buf ); + attr_merge_one( e, monitor_ad_desc, &bv, NULL ); } return( 0 );