]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/thread.c
Merge branch 'mdb.master' of ssh://git-master.openldap.org/~git/git/openldap
[openldap] / servers / slapd / back-monitor / thread.c
index 2c1b6e2d2bc16b5eba6c5c7aa06fab5f319eea6c..7ada40058cc60a456e7a15e60b844687a23d979d 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2007 The OpenLDAP Foundation.
+ * Copyright 2001-2011 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -40,26 +40,53 @@ typedef enum {
 
 static struct {
        struct berval                   rdn;
+       struct berval                   desc;
        struct berval                   nrdn;
        ldap_pvt_thread_pool_param_t    param;
        monitor_thread_t                mt;
 }              mt[] = {
-       { BER_BVC( "cn=Max" ),          BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_MAX,         MT_UNKNOWN },
-       { BER_BVC( "cn=Max Pending" ),  BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_MAX_PENDING, MT_UNKNOWN },
-       { BER_BVC( "cn=Open" ),         BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_OPEN,        MT_UNKNOWN },
-       { BER_BVC( "cn=Starting" ),     BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_STARTING,    MT_UNKNOWN },
-       { BER_BVC( "cn=Active" ),       BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_ACTIVE,      MT_UNKNOWN },
-       { BER_BVC( "cn=Pending" ),      BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_PENDING,     MT_UNKNOWN },
-       { BER_BVC( "cn=Backload" ),     BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD,    MT_UNKNOWN },
+       { BER_BVC( "cn=Max" ),
+               BER_BVC("Maximum number of threads as configured"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_MAX,         MT_UNKNOWN },
+       { BER_BVC( "cn=Max Pending" ),
+               BER_BVC("Maximum number of pending threads"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_MAX_PENDING, MT_UNKNOWN },
+       { BER_BVC( "cn=Open" ),         
+               BER_BVC("Number of open threads"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_OPEN,        MT_UNKNOWN },
+       { BER_BVC( "cn=Starting" ),     
+               BER_BVC("Number of threads being started"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_STARTING,    MT_UNKNOWN },
+       { BER_BVC( "cn=Active" ),       
+               BER_BVC("Number of active threads"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_ACTIVE,      MT_UNKNOWN },
+       { BER_BVC( "cn=Pending" ),      
+               BER_BVC("Number of pending threads"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_PENDING,     MT_UNKNOWN },
+       { BER_BVC( "cn=Backload" ),     
+               BER_BVC("Number of active plus pending threads"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD,    MT_UNKNOWN },
 #if 0  /* not meaningful right now */
-       { BER_BVC( "cn=Active Max" ),   BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_ACTIVE_MAX,  MT_UNKNOWN },
-       { BER_BVC( "cn=Pending Max" ),  BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_PENDING_MAX, MT_UNKNOWN },
-       { BER_BVC( "cn=Backload Max" ), BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD_MAX,MT_UNKNOWN },
+       { BER_BVC( "cn=Active Max" ),
+               BER_BVNULL,
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_ACTIVE_MAX,  MT_UNKNOWN },
+       { BER_BVC( "cn=Pending Max" ),
+               BER_BVNULL,
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_PENDING_MAX, MT_UNKNOWN },
+       { BER_BVC( "cn=Backload Max" ),
+               BER_BVNULL,
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_BACKLOAD_MAX,MT_UNKNOWN },
 #endif
-       { BER_BVC( "cn=State" ),        BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_STATE,       MT_UNKNOWN },
+       { BER_BVC( "cn=State" ),
+               BER_BVC("Thread pool state"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_STATE,       MT_UNKNOWN },
 
-       { BER_BVC( "cn=Runqueue" ),     BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN,     MT_RUNQUEUE },
-       { BER_BVC( "cn=Tasklist" ),     BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN,     MT_TASKLIST },
+       { BER_BVC( "cn=Runqueue" ),
+               BER_BVC("Queue of running threads - besides those handling operations"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN,     MT_RUNQUEUE },
+       { BER_BVC( "cn=Tasklist" ),
+               BER_BVC("List of running plus standby threads - besides those handling operations"),
+               BER_BVNULL,     LDAP_PVT_THREAD_POOL_PARAM_UNKNOWN,     MT_TASKLIST },
 
        { BER_BVNULL }
 };
@@ -92,7 +119,7 @@ monitor_subsys_thread_init(
        if ( monitor_cache_get( mi, &ms->mss_ndn, &e_thread ) ) {
                Debug( LDAP_DEBUG_ANY,
                        "monitor_subsys_thread_init: unable to get entry \"%s\"\n",
-                       ms->mss_ndn.bv_val, 
+                       ms->mss_dn.bv_val, 
                        0, 0 );
                return( -1 );
        }
@@ -153,6 +180,12 @@ monitor_subsys_thread_init(
                if ( !BER_BVISNULL( &bv ) ) {
                        attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
                }
+
+               if ( !BER_BVISNULL( &mt[ i ].desc ) ) {
+                       attr_merge_normalize_one( e,
+                               slap_schema.si_ad_description,
+                               &mt[ i ].desc, NULL );
+               }
        
                mp = monitor_entrypriv_create();
                if ( mp == NULL ) {
@@ -168,7 +201,7 @@ monitor_subsys_thread_init(
                                "monitor_subsys_thread_init: "
                                "unable to add entry \"%s,%s\"\n",
                                mt[ i ].rdn.bv_val,
-                               ms->mss_ndn.bv_val, 0 );
+                               ms->mss_dn.bv_val, 0 );
                        return( -1 );
                }
        
@@ -227,6 +260,7 @@ monitor_subsys_thread_update(
                                ber_bvarray_free( a->a_vals );
                                a->a_vals = NULL;
                                a->a_nvals = NULL;
+                               a->a_numvals = 0;
                        }
 
                        i = 0;
@@ -245,6 +279,9 @@ monitor_subsys_thread_update(
                        if ( vals ) {
                                attr_merge_normalize( e, mi->mi_ad_monitoredInfo, vals, NULL );
                                ber_bvarray_free( vals );
+
+                       } else {
+                               attr_delete( &e->e_attrs, mi->mi_ad_monitoredInfo );
                        }
                        break;
 
@@ -256,6 +293,7 @@ monitor_subsys_thread_update(
                                ber_bvarray_free( a->a_vals );
                                a->a_vals = NULL;
                                a->a_nvals = NULL;
+                               a->a_numvals = 0;
                        }
        
                        i = 0;
@@ -274,6 +312,9 @@ monitor_subsys_thread_update(
                        if ( vals ) {
                                attr_merge_normalize( e, mi->mi_ad_monitoredInfo, vals, NULL );
                                ber_bvarray_free( vals );
+
+                       } else {
+                               attr_delete( &e->e_attrs, mi->mi_ad_monitoredInfo );
                        }
                        break;