]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/sent.c
Fix LBER_ERROR vs. -1 confusion.
[openldap] / servers / slapd / back-monitor / sent.c
index 4e6fb54d722b0a93262bce89dfaf6ce2cf3cc8b0..99bd329a78a552972ca105308a4d2612b9f5efd9 100644 (file)
@@ -1,12 +1,9 @@
 /* sent.c - deal with data sent subsystem */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 /*
- * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- * 
  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
  * 
  * This work has beed deveolped for the OpenLDAP Foundation 
@@ -51,24 +48,24 @@ monitor_subsys_sent_init(
        Entry                   *e, *e_tmp, *e_sent;
        struct monitorentrypriv *mp;
        char                    buf[1024];
-       struct berval           val, *bv[2] = { &val, NULL };
+       struct berval           bv[2];
 
        assert( be != NULL );
 
        mi = ( struct monitorinfo * )be->be_private;
 
        if ( monitor_cache_get( mi,
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, &e_sent ) ) {
+                       &monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn, &e_sent ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to get entry '%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to get entry '%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val, 
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 
                        "", "" );
 #endif
                return( -1 );
@@ -81,35 +78,30 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=Entries,%s\n"
-                       "objectClass: top\n"
-                       "objectClass: LDAPsubEntry\n"
-#ifdef SLAPD_MONITORSUBENTRY
-                       "objectClass: monitorSubEntry\n"
-#else /* !SLAPD_MONITORSUBENTRY */
-                       "objectClass: extensibleObject\n"
-#endif /* !SLAPD_MONITORSUBENTRY */
+                       SLAPD_MONITOR_OBJECTCLASSES
                        "cn: Entries\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=Entries,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=Entries,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
        }
        
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[1].bv_val = NULL;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -122,15 +114,15 @@ monitor_subsys_sent_init(
 
        if ( monitor_cache_add( mi, e ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=Entries,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=Entries,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
@@ -143,35 +135,29 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=Referrals,%s\n"
-                       "objectClass: top\n"
-                       "objectClass: LDAPsubEntry\n"
-#ifdef SLAPD_MONITORSUBENTRY
-                       "objectClass: monitorSubEntry\n"
-#else /* !SLAPD_MONITORSUBENTRY */
-                       "objectClass: extensibleObject\n"
-#endif /* !SLAPD_MONITORSUBENTRY */
+                       SLAPD_MONITOR_OBJECTCLASSES
                        "cn: Referrals\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=Referrals,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=Referrals,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
        }
 
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -184,15 +170,15 @@ monitor_subsys_sent_init(
 
        if ( monitor_cache_add( mi, e ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=Referrals,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=Referrals,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
@@ -205,35 +191,29 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=PDU,%s\n"
-                       "objectClass: top\n"
-                       "objectClass: LDAPsubEntry\n"
-#ifdef SLAPD_MONITORSUBENTRY
-                       "objectClass: monitorSubEntry\n"
-#else /* !SLAPD_MONITORSUBENTRY */
-                       "objectClass: extensibleObject\n"
-#endif /* !SLAPD_MONITORSUBENTRY */
+                       SLAPD_MONITOR_OBJECTCLASSES
                        "cn: PDU\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=PDU,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=PDU,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
        }
 
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -246,15 +226,15 @@ monitor_subsys_sent_init(
 
        if ( monitor_cache_add( mi, e ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=PDU,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=PDU,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
@@ -267,35 +247,29 @@ monitor_subsys_sent_init(
         */
        snprintf( buf, sizeof( buf ),
                        "dn: cn=Bytes,%s\n"
-                       "objectClass: top\n"
-                       "objectClass: LDAPsubEntry\n"
-#ifdef SLAPD_MONITORSUBENTRY
-                       "objectClass: monitorSubEntry\n"
-#else /* !SLAPD_MONITORSUBENTRY */
-                       "objectClass: extensibleObject\n"
-#endif /* !SLAPD_MONITORSUBENTRY */
+                       SLAPD_MONITOR_OBJECTCLASSES
                        "cn: Bytes\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn->bv_val );
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_dn.bv_val );
 
        e = str2entry( buf );
        if ( e == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=Bytes,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to create entry 'cn=Bytes,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
        }
 
-       val.bv_val = "0";
-       val.bv_len = 1;
+       bv[0].bv_val = "0";
+       bv[0].bv_len = 1;
        attr_merge( e, monitor_ad_desc, bv );
        
        mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
@@ -308,15 +282,15 @@ monitor_subsys_sent_init(
 
        if ( monitor_cache_add( mi, e ) ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+               LDAP_LOG( OPERATION, CRIT,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=Bytes,%s'\n",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val ));
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_sent_init: "
                        "unable to add entry 'cn=Bytes,%s'\n%s%s",
-                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn->bv_val,
+                       monitor_subsys[SLAPD_MONITOR_SENT].mss_ndn.bv_val,
                        "", "" );
 #endif
                return( -1 );
@@ -343,26 +317,26 @@ monitor_subsys_sent_update(
        assert( mi );
        assert( e );
        
-       if ( strncasecmp( e->e_ndn, "CN=ENTRIES", 
-                               sizeof("CN=ENTRIES")-1 ) == 0 ) {
+       if ( strncasecmp( e->e_ndn, "cn=entries", 
+                               sizeof("cn=entries")-1 ) == 0 ) {
                ldap_pvt_thread_mutex_lock(&num_sent_mutex);
                n = num_entries_sent;
                ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
 
-       } else if ( strncasecmp( e->e_ndn, "CN=REFERRALS", 
-                               sizeof("CN=REFERRALS")-1 ) == 0 ) {
+       } else if ( strncasecmp( e->e_ndn, "cn=referrals", 
+                               sizeof("cn=referrals")-1 ) == 0 ) {
                ldap_pvt_thread_mutex_lock(&num_sent_mutex);
                n = num_refs_sent;
                ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
 
-       } else if ( strncasecmp( e->e_ndn, "CN=PDU", 
-                               sizeof("CN=PDU")-1 ) == 0 ) {
+       } else if ( strncasecmp( e->e_ndn, "cn=pdu", 
+                               sizeof("cn=pdu")-1 ) == 0 ) {
                ldap_pvt_thread_mutex_lock(&num_sent_mutex);
                n = num_pdu_sent;
                ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
 
-       } else if ( strncasecmp( e->e_ndn, "CN=BYTES", 
-                               sizeof("CN=BYTES")-1 ) == 0 ) {
+       } else if ( strncasecmp( e->e_ndn, "cn=bytes", 
+                               sizeof("cn=bytes")-1 ) == 0 ) {
                ldap_pvt_thread_mutex_lock(&num_sent_mutex);
                n = num_bytes_sent;
                ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
@@ -378,8 +352,8 @@ monitor_subsys_sent_update(
                }
 
                snprintf( buf, sizeof( buf ), "%ld", n );
-               ber_bvfree( a->a_vals[ 0 ] );
-               a->a_vals[ 0 ] = ber_bvstrdup( buf );
+               free( a->a_vals[ 0 ].bv_val );
+               ber_str2bv( buf, 0, 1, a->a_vals );
        }
 
        return( 0 );