]> git.sur5r.net Git - openldap/commitdiff
fix attr nvals & more improvements
authorPierangelo Masarati <ando@openldap.org>
Mon, 7 Apr 2003 23:22:27 +0000 (23:22 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 7 Apr 2003 23:22:27 +0000 (23:22 +0000)
14 files changed:
servers/slapd/back-monitor/back-monitor.h
servers/slapd/back-monitor/backend.c
servers/slapd/back-monitor/compare.c
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/database.c
servers/slapd/back-monitor/init.c
servers/slapd/back-monitor/listener.c
servers/slapd/back-monitor/log.c
servers/slapd/back-monitor/modify.c
servers/slapd/back-monitor/operation.c
servers/slapd/back-monitor/rww.c
servers/slapd/back-monitor/search.c
servers/slapd/back-monitor/sent.c
servers/slapd/back-monitor/thread.c

index a16f8fb7d9e369a442fffab8247e9e9a9a70cace..3037e8655e14d9c9576167c89134c37f54c92625 100644 (file)
@@ -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;
 
 /*
index e19d1d6e80ca3814a88b5e5eec8368e5d5742ed6..aab3ff7b26a4aa88815187a1d36f2908125e085c 100644 (file)
@@ -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 );
                        }
                }
                
index 798218dbdcf9266e27a25a5e04920c96716d7933..4e04e52b440a034460de8973509c2ff9c6b2ec93 100644 (file)
@@ -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 );
        }
index 651ef7df16ce2b0de1d6e444a005578d65c2c67c..8b8287f201da552083506f7e032dd3bf65d94976 100644 (file)
@@ -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;
index 05a6688f8aa9a71dbce4300c136768f2f66ecf1f..9fde6ca7110c594c46f7ca832aa5b8b8079ae80a 100644 (file)
@@ -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--; ) {
index 770f8e0bf86fbc57fee39de6680c8b1a122dd3df..a929562301db3b1a7a3033bfaa6388ba0aa4aa18 100644 (file)
@@ -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",
index c66e1c5f2fb01fb6286d9486f3caea623829355e..b862fcd0f8e3168df93482576c870582ce0d3790 100644 (file)
@@ -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 */
 
index d9823bf4c3e44ccef5f3a4f4bc1b30f2f715bb94..8bc0dd0d1835bc7ea50939b41816e6df78d2871c 100644 (file)
@@ -38,6 +38,7 @@
 #include <ac/string.h>
 
 #include "slap.h"
+#include <lber_pvt.h>
 #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;
        }
 
index 4383b7eaeec75a7792ab84ea6d16f5f84b1d1623..8aa426ecc2aff31866f30356e023483c4ffe068d 100644 (file)
@@ -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 )) {
index 5ce6d1db26fa81ed3b53adf4c2b80b854532b39d..571a2a0f77356554cc291914a8ee6dfa3a63533c 100644 (file)
@@ -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;
index c68dfab365b2e966c6be519a52f179c942b03dc2..5c2e88f5301352e32707b47effb5294470a1cec1 100644 (file)
@@ -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 );
index 401b08d68c61c992850d5e3e07682fe11e374b5d..6d7587c9feafb6a04a67ee52c9712d820afc8017 100644 (file)
@@ -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 );
        }
index 137e8efb8ce60b64756e721b44143d1f403a69e1..972331fd979e7ea326bb4d61031954f676204b8b 100644 (file)
@@ -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;
index 36d7d6132f3bad71c18a03877229e1834cbdfddb..7853a9faf1398f32f0ce2cbd87ac02a8b35b073f 100644 (file)
@@ -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 );