]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/conn.c
check consistency of referrals and result code (ITS#4861)
[openldap] / servers / slapd / back-monitor / conn.c
index 24e8cc4e5c136b932d4d0f99e6893b7ffcd89108..45ceade0546f23c1dd1a37f1c9841c0e3a5fcade 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2006 The OpenLDAP Foundation.
+ * Copyright 2001-2007 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -50,6 +50,7 @@ monitor_subsys_conn_init(
        monitor_info_t  *mi;
        Entry           *e, **ep, *e_conn;
        monitor_entry_t *mp;
+       char            buf[ BACKMONITOR_BUFSIZE ];
        struct berval   bv;
 
        assert( be != NULL );
@@ -71,6 +72,51 @@ monitor_subsys_conn_init(
        mp->mp_children = NULL;
        ep = &mp->mp_children;
 
+       /*
+        * Max file descriptors
+        */
+       BER_BVSTR( &bv, "cn=Max File Descriptors" );
+       e = monitor_entry_stub( &ms->mss_dn, &ms->mss_ndn, &bv,
+               mi->mi_oc_monitorCounterObject, mi, NULL, NULL );
+       
+       if ( e == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_subsys_conn_init: "
+                       "unable to create entry \"%s,%s\"\n",
+                       bv.bv_val, ms->mss_ndn.bv_val, 0 );
+               return( -1 );
+       }
+
+       if ( dtblsize ) {
+               bv.bv_val = buf;
+               bv.bv_len = snprintf( buf, sizeof( buf ), "%d", dtblsize );
+
+       } else {
+               BER_BVSTR( &bv, "0" );
+       }
+       attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, &bv );
+       
+       mp = monitor_entrypriv_create();
+       if ( mp == NULL ) {
+               return -1;
+       }
+       e->e_private = ( void * )mp;
+       mp->mp_info = ms;
+       mp->mp_flags = ms->mss_flags \
+               | MONITOR_F_SUB | MONITOR_F_PERSISTENT;
+       mp->mp_flags &= ~MONITOR_F_VOLATILE_CH;
+
+       if ( monitor_cache_add( mi, e ) ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_subsys_conn_init: "
+                       "unable to add entry \"cn=Total,%s\"\n",
+                       ms->mss_ndn.bv_val, 0, 0 );
+               return( -1 );
+       }
+
+       *ep = e;
+       ep = &mp->mp_next;
+       
        /*
         * Total conns
         */
@@ -86,7 +132,7 @@ monitor_subsys_conn_init(
                return( -1 );
        }
        
-       BER_BVSTR( &bv, "0" );
+       BER_BVSTR( &bv, "-1" );
        attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, &bv );
        
        mp = monitor_entrypriv_create();
@@ -337,8 +383,10 @@ conn_create(
                        c->c_dn.bv_len ? c->c_dn.bv_val : SLAPD_ANONYMOUS,
                        
                        c->c_listener_url.bv_val,
-                       c->c_peer_domain.bv_val,
-                       c->c_peer_name.bv_val,
+                       BER_BVISNULL( &c->c_peer_domain )
+                               ? "" : c->c_peer_domain.bv_val,
+                       BER_BVISNULL( &c->c_peer_name )
+                               ? "" : c->c_peer_name.bv_val,
                        c->c_sock_name.bv_val,
                        
                        buf2,
@@ -386,6 +434,7 @@ conn_create(
                &c->c_dn, &c->c_ndn );
 
        /* NOTE: client connections leave the c_peer_* fields NULL */
+       assert( !BER_BVISNULL( &c->c_listener_url ) );
        attr_merge_one( e, mi->mi_ad_monitorConnectionListener,
                &c->c_listener_url, NULL );
 
@@ -397,6 +446,7 @@ conn_create(
                BER_BVISNULL( &c->c_peer_name ) ? &bv_unknown : &c->c_peer_name,
                NULL );
 
+       assert( !BER_BVISNULL( &c->c_sock_name ) );
        attr_merge_one( e, mi->mi_ad_monitorConnectionLocalAddress,
                &c->c_sock_name, NULL );