fix attr nvals & more improvements

This commit is contained in:
Pierangelo Masarati 2003-04-07 23:22:27 +00:00
parent 9e66d3d1f0
commit f73eddd426
14 changed files with 235 additions and 140 deletions

View file

@ -203,6 +203,7 @@ struct monitorsubsys {
extern struct monitorsubsys monitor_subsys[]; extern struct monitorsubsys monitor_subsys[];
extern AttributeDescription *monitor_ad_desc; extern AttributeDescription *monitor_ad_desc;
extern slap_mr_normalize_func *monitor_ad_normalize;
extern BackendDB *be_monitor; extern BackendDB *be_monitor;
/* /*

View file

@ -76,7 +76,8 @@ monitor_subsys_backend_init(
for ( i = nBackendInfo; i--; ) { for ( i = nBackendInfo; i--; ) {
char buf[1024]; char buf[1024];
BackendInfo *bi; BackendInfo *bi;
struct berval bv[ 2 ]; struct berval bv, nbv;
int rc;
bi = &backendInfo[i]; bi = &backendInfo[i];
@ -106,20 +107,34 @@ monitor_subsys_backend_init(
return( -1 ); return( -1 );
} }
bv[0].bv_val = bi->bi_type; bv.bv_val = bi->bi_type;
bv[0].bv_len = strlen( bv[0].bv_val ); bv.bv_len = strlen( bv.bv_val );
bv[1].bv_val = NULL;
attr_mergeit( e, monitor_ad_desc, bv ); nbv.bv_val = NULL;
attr_mergeit( e_backend, monitor_ad_desc, bv ); 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_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 ) { if ( bi->bi_controls ) {
int j; int j;
for ( j = 0; bi->bi_controls[ j ]; j++ ) { for ( j = 0; bi->bi_controls[ j ]; j++ ) {
bv[0].bv_val = bi->bi_controls[ j ]; bv.bv_val = bi->bi_controls[ j ];
bv[0].bv_len = strlen( bv[0].bv_val ); bv.bv_len = strlen( bv.bv_val );
attr_mergeit( e, slap_schema.si_ad_supportedControl, bv ); attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL );
} }
} }

View file

@ -49,15 +49,15 @@ monitor_back_compare( struct slap_op *op, struct slap_rep *rs)
/* get entry with reader lock */ /* get entry with reader lock */
monitor_cache_dn2entry( mi, &op->o_req_ndn, &e, &matched ); monitor_cache_dn2entry( mi, &op->o_req_ndn, &e, &matched );
if ( e == NULL ) { if ( e == NULL ) {
if ( matched ) {
rs->sr_matched = ch_strdup( matched->e_dn );
monitor_cache_release( mi, matched );
}
rs->sr_err = LDAP_NO_SUCH_OBJECT; rs->sr_err = LDAP_NO_SUCH_OBJECT;
if ( matched ) {
rs->sr_matched = matched->e_dn;
}
send_ldap_result( op, rs ); send_ldap_result( op, rs );
if ( matched ) {
monitor_cache_release( mi, matched );
rs->sr_matched = NULL; rs->sr_matched = NULL;
}
return( 0 ); return( 0 );
} }

View file

@ -51,7 +51,7 @@ monitor_subsys_conn_init(
Entry *e, *e_tmp, *e_conn; Entry *e, *e_tmp, *e_conn;
struct monitorentrypriv *mp; struct monitorentrypriv *mp;
char buf[1024]; char buf[1024];
struct berval bv[2]; struct berval bv;
assert( be != NULL ); assert( be != NULL );
@ -102,10 +102,9 @@ monitor_subsys_conn_init(
return( -1 ); return( -1 );
} }
bv[1].bv_val = NULL; bv.bv_val = "0";
bv[0].bv_val = "0"; bv.bv_len = 1;
bv[0].bv_len = 1; attr_merge_one( e, monitor_ad_desc, &bv, NULL );
attr_mergeit( e, monitor_ad_desc, bv );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -160,10 +159,9 @@ monitor_subsys_conn_init(
return( -1 ); return( -1 );
} }
bv[1].bv_val = NULL; bv.bv_val = "0";
bv[0].bv_val = "0"; bv.bv_len = 1;
bv[0].bv_len = 1; attr_merge_one( e, monitor_ad_desc, &bv, NULL );
attr_mergeit( e, monitor_ad_desc, bv );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -257,7 +255,7 @@ conn_create(
char buf2[ LDAP_LUTIL_GENTIME_BUFSIZE ]; char buf2[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char buf3[ LDAP_LUTIL_GENTIME_BUFSIZE ]; char buf3[ LDAP_LUTIL_GENTIME_BUFSIZE ];
struct berval bv[2]; struct berval bv;
Entry *e; Entry *e;
@ -333,10 +331,9 @@ conn_create(
buf3 buf3
); );
bv[1].bv_val = NULL; bv.bv_val = buf;
bv[0].bv_val = buf; bv.bv_len = strlen( buf );
bv[0].bv_len = strlen( buf ); attr_merge_one( e, monitor_ad_desc, &bv, NULL );
attr_mergeit( e, monitor_ad_desc, bv );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;

View file

@ -136,11 +136,11 @@ monitor_subsys_database_init(
} }
if ( be->be_flags & SLAP_BFLAG_MONITOR ) { if ( be->be_flags & SLAP_BFLAG_MONITOR ) {
attr_mergeit( e, ad_mc, be->be_suffix ); attr_merge( e, ad_mc, be->be_suffix, be->be_nsuffix );
attr_mergeit( e_database, ad_mc, be->be_suffix ); attr_merge( e_database, ad_mc, be->be_suffix, be->be_nsuffix );
} else { } else {
attr_mergeit( e, ad_nc, be->be_suffix ); attr_merge( e, ad_nc, be->be_suffix, be->be_nsuffix );
attr_mergeit( e_database, ad_nc, be->be_suffix ); attr_merge( e_database, ad_nc, be->be_suffix, be->be_nsuffix );
} }
for ( j = nBackendInfo; j--; ) { for ( j = nBackendInfo; j--; ) {

View file

@ -44,6 +44,7 @@
* used by many functions to add description to entries * used by many functions to add description to entries
*/ */
AttributeDescription *monitor_ad_desc = NULL; AttributeDescription *monitor_ad_desc = NULL;
slap_mr_normalize_func *monitor_ad_normalize = NULL;
BackendDB *be_monitor = NULL; BackendDB *be_monitor = NULL;
/* /*
@ -244,7 +245,7 @@ monitor_back_db_init(
char buf[1024], *end_of_line; char buf[1024], *end_of_line;
struct berval dn, ndn; struct berval dn, ndn;
const char *text; const char *text;
struct berval bv[2]; struct berval bv;
/* /*
* database monitor can be defined once only * database monitor can be defined once only
@ -281,8 +282,8 @@ monitor_back_db_init(
return -1; return -1;
} }
ber_dupbv( &bv[0], &dn ); ber_dupbv( &bv, &dn );
ber_bvarray_add( &be->be_suffix, &bv[0] ); ber_bvarray_add( &be->be_suffix, &bv );
ber_bvarray_add( &be->be_nsuffix, &ndn ); ber_bvarray_add( &be->be_nsuffix, &ndn );
mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 ); mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
@ -300,6 +301,10 @@ monitor_back_db_init(
return( -1 ); 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 * Create all the subsystem specific entries
*/ */
@ -417,15 +422,14 @@ monitor_back_db_init(
#endif #endif
return( -1 ); return( -1 );
} }
bv[1].bv_val = NULL; bv.bv_val = (char *) Versionstr;
bv[0].bv_val = (char *) Versionstr;
end_of_line = strchr( Versionstr, '\n' ); end_of_line = strchr( Versionstr, '\n' );
if ( end_of_line ) { if ( end_of_line ) {
bv[0].bv_len = end_of_line - Versionstr; bv.bv_len = end_of_line - Versionstr;
} else { } 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 #ifdef NEW_LOGGING
LDAP_LOG( OPERATION, CRIT, LDAP_LOG( OPERATION, CRIT,
"unable to add description to '%s' entry\n", "unable to add description to '%s' entry\n",

View file

@ -122,20 +122,54 @@ monitor_subsys_listener_init(
#ifdef HAVE_TLS #ifdef HAVE_TLS
if ( l[i]->sl_is_tls ) { if ( l[i]->sl_is_tls ) {
struct berval bv[2]; struct berval bv, nbv;
bv[1].bv_val = NULL;
bv[0].bv_val = "TLS"; bv.bv_val = "TLS";
bv[0].bv_len = sizeof("TLS")-1; bv.bv_len = sizeof("TLS")-1;
attr_mergeit( e, monitor_ad_desc, bv );
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 */ #endif /* HAVE_TLS */
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if ( l[i]->sl_is_udp ) { if ( l[i]->sl_is_udp ) {
struct berval bv[2]; struct berval bv, nbv;
bv[1].bv_val = NULL;
bv[0].bv_val = "UDP"; bv.bv_val = "UDP";
bv[0].bv_len = sizeof("UDP")-1; bv.bv_len = sizeof("UDP")-1;
attr_mergeit( e, monitor_ad_desc, bv );
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 */ #endif /* HAVE_TLS */

View file

@ -38,6 +38,7 @@
#include <ac/string.h> #include <ac/string.h>
#include "slap.h" #include "slap.h"
#include <lber_pvt.h>
#include "lutil.h" #include "lutil.h"
#include "ldif.h" #include "ldif.h"
#include "back-monitor.h" #include "back-monitor.h"
@ -49,27 +50,28 @@ ldap_pvt_thread_mutex_t monitor_log_mutex;
static struct { static struct {
int i; int i;
const char *s; struct berval s;
struct berval n;
} int_2_level[] = { } int_2_level[] = {
{ LDAP_DEBUG_TRACE, "Trace" }, { LDAP_DEBUG_TRACE, BER_BVC("Trace"), { 0, NULL } },
{ LDAP_DEBUG_PACKETS, "Packets" }, { LDAP_DEBUG_PACKETS, BER_BVC("Packets"), { 0, NULL } },
{ LDAP_DEBUG_ARGS, "Args" }, { LDAP_DEBUG_ARGS, BER_BVC("Args"), { 0, NULL } },
{ LDAP_DEBUG_CONNS, "Conns" }, { LDAP_DEBUG_CONNS, BER_BVC("Conns"), { 0, NULL } },
{ LDAP_DEBUG_BER, "BER" }, { LDAP_DEBUG_BER, BER_BVC("BER"), { 0, NULL } },
{ LDAP_DEBUG_FILTER, "Filter" }, { LDAP_DEBUG_FILTER, BER_BVC("Filter"), { 0, NULL } },
{ LDAP_DEBUG_CONFIG, "Config" }, /* useless */ { LDAP_DEBUG_CONFIG, BER_BVC("Config"), { 0, NULL } }, /* useless */
{ LDAP_DEBUG_ACL, "ACL" }, { LDAP_DEBUG_ACL, BER_BVC("ACL"), { 0, NULL } },
{ LDAP_DEBUG_STATS, "Stats" }, { LDAP_DEBUG_STATS, BER_BVC("Stats"), { 0, NULL } },
{ LDAP_DEBUG_STATS2, "Stats2" }, { LDAP_DEBUG_STATS2, BER_BVC("Stats2"), { 0, NULL } },
{ LDAP_DEBUG_SHELL, "Shell" }, { LDAP_DEBUG_SHELL, BER_BVC("Shell"), { 0, NULL } },
{ LDAP_DEBUG_PARSE, "Parse" }, { LDAP_DEBUG_PARSE, BER_BVC("Parse"), { 0, NULL } },
{ LDAP_DEBUG_CACHE, "Cache" }, { LDAP_DEBUG_CACHE, BER_BVC("Cache"), { 0, NULL } },
{ LDAP_DEBUG_INDEX, "Index" }, { LDAP_DEBUG_INDEX, BER_BVC("Index"), { 0, NULL } },
{ 0, NULL } { 0, { 0, NULL }, { 0, NULL } }
}; };
static int loglevel2int( const char *str ); static int loglevel2int( struct berval *l );
static const char * int2loglevel( int n ); static int int2loglevel( int n );
static int add_values( Entry *e, Modification *mod, int *newlevel ); static int add_values( Entry *e, Modification *mod, int *newlevel );
static int delete_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; bv[1].bv_val = NULL;
/* initialize the debug level */ /* initialize the debug level(s) */
for ( i = 0; int_2_level[ i ].i != 0; i++ ) { 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 static int
loglevel2int( const char *str ) loglevel2int( struct berval *l )
{ {
int i; int i;
for ( i = 0; int_2_level[ i ].i != 0; 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; return int_2_level[ i ].i;
} }
} }
@ -252,18 +272,18 @@ loglevel2int( const char *str )
return 0; return 0;
} }
static const char * static int
int2loglevel( int n ) int2loglevel( int n )
{ {
int i; int i;
for ( i = 0; int_2_level[ i ].i != 0; i++ ) { for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
if ( int_2_level[ i ].i == n ) { if ( int_2_level[ i ].i == n ) {
return int_2_level[ i ].s; return i;
} }
} }
return NULL; return -1;
} }
static int static int
@ -273,19 +293,26 @@ check_constraints( Modification *mod, int *newlevel )
for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) { for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int l; int l;
const char *s;
ber_len_t len;
l = loglevel2int( mod->sm_bvalues[i].bv_val ); l = loglevel2int( &mod->sm_bvalues[i] );
if ( !l ) { if ( !l ) {
return LDAP_CONSTRAINT_VIOLATION; return LDAP_CONSTRAINT_VIOLATION;
} }
s = int2loglevel( l ); if ( ( l = int2loglevel( l ) ) == -1 ) {
len = strlen( s ); return LDAP_OTHER;
assert( len == mod->sm_bvalues[i].bv_len ); }
AC_MEMCPY( mod->sm_bvalues[i].bv_val, s, len ); assert( int_2_level[ l ].s.bv_len
== mod->sm_bvalues[i].bv_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; *newlevel |= l;
} }
@ -347,7 +374,8 @@ add_values( Entry *e, Modification *mod, int *newlevel )
} }
/* no - add them */ /* 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 */ /* this should return result of attr_mergeit */
return LDAP_OTHER; return LDAP_OTHER;
} }
@ -472,7 +500,8 @@ replace_values( Entry *e, Modification *mod, int *newlevel )
} }
if ( mod->sm_bvalues != NULL && 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; return LDAP_OTHER;
} }

View file

@ -76,8 +76,8 @@ monitor_back_modify( Operation *op, SlapReply *rs )
if ( matched != NULL ) { if ( matched != NULL ) {
rs->sr_matched = NULL; rs->sr_matched = NULL;
monitor_cache_release( mi, matched ); monitor_cache_release( mi, matched );
return( 0 );
} }
return( 0 );
} }
if ( !acl_check_modlist( op, e, op->oq_modify.rs_modlist )) { if ( !acl_check_modlist( op, e, op->oq_modify.rs_modlist )) {

View file

@ -65,7 +65,7 @@ monitor_subsys_ops_init(
Entry *e, *e_tmp, *e_op, *e_children; Entry *e, *e_tmp, *e_op, *e_children;
struct monitorentrypriv *mp; struct monitorentrypriv *mp;
char buf[1024]; char buf[1024];
struct berval bv[2]; struct berval bv;
int i; int i;
assert( be != NULL ); assert( be != NULL );
@ -121,10 +121,9 @@ monitor_subsys_ops_init(
return( -1 ); return( -1 );
} }
bv[1].bv_val = NULL; bv.bv_val = "0";
bv[0].bv_val = "0"; bv.bv_len = 1;
bv[0].bv_len = 1; attr_merge_one( e, monitor_ad_desc, &bv, NULL );
attr_mergeit( e, monitor_ad_desc, bv );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -189,10 +188,9 @@ monitor_subsys_ops_init(
return( -1 ); return( -1 );
} }
bv[1].bv_val = NULL; bv.bv_val = "0";
bv[0].bv_val = "0"; bv.bv_len = 1;
bv[0].bv_len = 1; attr_merge_one( e, monitor_ad_desc, &bv, NULL );
attr_mergeit( e, monitor_ad_desc, bv );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -257,9 +255,9 @@ monitor_subsys_ops_init(
return( -1 ); return( -1 );
} }
bv[0].bv_val = "0"; bv.bv_val = "0";
bv[0].bv_len = 1; bv.bv_len = 1;
attr_mergeit( e, monitor_ad_desc, bv ); attr_merge_one( e, monitor_ad_desc, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -324,9 +322,9 @@ monitor_subsys_ops_init(
return( -1 ); return( -1 );
} }
bv[0].bv_val = "0"; bv.bv_val = "0";
bv[0].bv_len = 1; bv.bv_len = 1;
attr_mergeit( e, monitor_ad_desc, bv ); attr_merge_one( e, monitor_ad_desc, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;

View file

@ -70,7 +70,7 @@ monitor_subsys_readw_update_internal(
int nconns, nwritewaiters, nreadwaiters; int nconns, nwritewaiters, nreadwaiters;
Attribute *a; Attribute *a;
struct berval bv[2], *b = NULL; struct berval *b = NULL;
char buf[1024]; char buf[1024];
char *str = NULL; char *str = NULL;
@ -79,8 +79,6 @@ monitor_subsys_readw_update_internal(
assert( mi != NULL ); assert( mi != NULL );
assert( e != NULL ); assert( e != NULL );
bv[1].bv_val = NULL;
nconns = nwritewaiters = nreadwaiters = 0; nconns = nwritewaiters = nreadwaiters = 0;
for ( c = connection_first( &connindex ); for ( c = connection_first( &connindex );
c != NULL; c != NULL;
@ -117,9 +115,28 @@ monitor_subsys_readw_update_internal(
} }
if ( b == NULL || b[0].bv_val == NULL ) { if ( b == NULL || b[0].bv_val == NULL ) {
bv[0].bv_val = buf; struct berval bv, nbv;
bv[0].bv_len = strlen( buf );
attr_mergeit( e, monitor_ad_desc, bv ); 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 ); return( 0 );

View file

@ -156,12 +156,14 @@ monitor_back_search( Operation *op, SlapReply *rs )
if ( e == NULL ) { if ( e == NULL ) {
rs->sr_err = LDAP_NO_SUCH_OBJECT; rs->sr_err = LDAP_NO_SUCH_OBJECT;
if ( matched ) { if ( matched ) {
rs->sr_matched = ch_strdup( matched->e_dn ); rs->sr_matched = matched->e_dn;
monitor_cache_release( mi, matched );
} }
send_ldap_result( op, rs ); send_ldap_result( op, rs );
if ( matched ) {
monitor_cache_release( mi, matched );
rs->sr_matched = NULL; rs->sr_matched = NULL;
}
return( 0 ); return( 0 );
} }

View file

@ -48,7 +48,7 @@ monitor_subsys_sent_init(
Entry *e, *e_tmp, *e_sent; Entry *e, *e_tmp, *e_sent;
struct monitorentrypriv *mp; struct monitorentrypriv *mp;
char buf[1024]; char buf[1024];
struct berval bv[2]; struct berval bv;
assert( be != NULL ); assert( be != NULL );
@ -99,10 +99,9 @@ monitor_subsys_sent_init(
return( -1 ); return( -1 );
} }
bv[1].bv_val = NULL; bv.bv_val = "0";
bv[0].bv_val = "0"; bv.bv_len = 1;
bv[0].bv_len = 1; attr_merge_one( e, monitor_ad_desc, &bv, NULL );
attr_mergeit( e, monitor_ad_desc, bv );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -156,9 +155,9 @@ monitor_subsys_sent_init(
return( -1 ); return( -1 );
} }
bv[0].bv_val = "0"; bv.bv_val = "0";
bv[0].bv_len = 1; bv.bv_len = 1;
attr_mergeit( e, monitor_ad_desc, bv ); attr_merge_one( e, monitor_ad_desc, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -212,9 +211,9 @@ monitor_subsys_sent_init(
return( -1 ); return( -1 );
} }
bv[0].bv_val = "0"; bv.bv_val = "0";
bv[0].bv_len = 1; bv.bv_len = 1;
attr_mergeit( e, monitor_ad_desc, bv ); attr_merge_one( e, monitor_ad_desc, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;
@ -268,9 +267,9 @@ monitor_subsys_sent_init(
return( -1 ); return( -1 );
} }
bv[0].bv_val = "0"; bv.bv_val = "0";
bv[0].bv_len = 1; bv.bv_len = 1;
attr_mergeit( e, monitor_ad_desc, bv ); attr_merge_one( e, monitor_ad_desc, &bv, NULL );
mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 ); mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
e->e_private = ( void * )mp; e->e_private = ( void * )mp;

View file

@ -48,8 +48,8 @@ monitor_subsys_thread_init(
{ {
struct monitorinfo *mi; struct monitorinfo *mi;
Entry *e; Entry *e;
struct berval bv[2];
static char buf[1024]; static char buf[1024];
struct berval bv;
mi = ( struct monitorinfo * )be->be_private; mi = ( struct monitorinfo * )be->be_private;
@ -72,11 +72,10 @@ monitor_subsys_thread_init(
/* initialize the thread number */ /* initialize the thread number */
snprintf( buf, sizeof( buf ), "max=%d", connection_pool_max ); snprintf( buf, sizeof( buf ), "max=%d", connection_pool_max );
bv[1].bv_val = NULL; bv.bv_val = buf;
bv[0].bv_val = buf; bv.bv_len = strlen( bv.bv_val );
bv[0].bv_len = strlen( bv[0].bv_val );
attr_mergeit( e, monitor_ad_desc, bv ); attr_merge_one( e, monitor_ad_desc, &bv, NULL );
monitor_cache_release( mi, e ); monitor_cache_release( mi, e );
@ -90,11 +89,9 @@ monitor_subsys_thread_update(
) )
{ {
Attribute *a; Attribute *a;
struct berval bv[2], *b = NULL; struct berval *b = NULL;
char buf[1024]; char buf[1024];
bv[1].bv_val = NULL;
snprintf( buf, sizeof( buf ), "backload=%d", snprintf( buf, sizeof( buf ), "backload=%d",
ldap_pvt_thread_pool_backload( &connection_pool ) ); ldap_pvt_thread_pool_backload( &connection_pool ) );
@ -111,9 +108,11 @@ monitor_subsys_thread_update(
} }
if ( b == NULL || b[0].bv_val == NULL ) { if ( b == NULL || b[0].bv_val == NULL ) {
bv[0].bv_val = buf; struct berval bv;
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 );
} }
return( 0 ); return( 0 );