From: Howard Chu Date: Sat, 23 Apr 2005 00:28:43 +0000 (+0000) Subject: Add task names to runqueue entries. Display running tasks under X-Git-Tag: OPENLDAP_AC_BP~815 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cd1bdf99e227a4ffc4caba86cd7ce3b729b11518;p=openldap Add task names to runqueue entries. Display running tasks under cn=Runqueue,cn=Threads,cn=Monitor --- diff --git a/servers/slapd/back-bdb/config.c b/servers/slapd/back-bdb/config.c index e1c9e23f27..fcee27c978 100644 --- a/servers/slapd/back-bdb/config.c +++ b/servers/slapd/back-bdb/config.c @@ -470,7 +470,8 @@ bdb_cf_gen(ConfigArgs *c) re->interval.tv_sec = bdb->bi_txn_cp_min * 60; else bdb->bi_txn_cp_task = ldap_pvt_runqueue_insert( &slapd_rq, - bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb ); + bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb, + "bdb_checkpoint", c->be->be_suffix[0].bv_val ); } break; @@ -548,7 +549,8 @@ bdb_cf_gen(ConfigArgs *c) if ( bdb->bi_flags & BDB_IS_OPEN ) { /* Start the task as soon as we finish here */ ldap_pvt_runqueue_insert( &slapd_rq, 60, - bdb_online_index, c->be ); + bdb_online_index, c->be, + "bdb_online_index", c->be->be_suffix[0].bv_val ); } break; diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index feb88ddc70..b8a6831ce5 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -205,7 +205,8 @@ ldbm_back_db_open( { ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); ldap_pvt_runqueue_insert( &slapd_rq, li->li_dbsyncfreq, - ldbm_cache_sync_daemon, be ); + ldbm_cache_sync_daemon, be, + "ldbm_cache_sync", be->be_suffix[0].bv_val ); ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); } diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index 83ba5ce522..99c36b760e 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -27,6 +27,8 @@ #include "slap.h" #include "back-monitor.h" +#include + /* * * initializes log subentry * */ @@ -158,6 +160,57 @@ monitor_subsys_thread_init( *ep = e; ep = &mp->mp_next; + /* + * Runqueue runners + */ + snprintf( buf, sizeof( buf ), + "dn: cn=Runqueue,%s\n" + "objectClass: %s\n" + "structuralObjectClass: %s\n" + "cn: Runqueue\n" + "%s: 0\n" + "creatorsName: %s\n" + "modifiersName: %s\n" + "createTimestamp: %s\n" + "modifyTimestamp: %s\n", + ms->mss_dn.bv_val, + mi->mi_oc_monitoredObject->soc_cname.bv_val, + mi->mi_oc_monitoredObject->soc_cname.bv_val, + mi->mi_ad_monitoredInfo->ad_cname.bv_val, + mi->mi_creatorsName.bv_val, + mi->mi_creatorsName.bv_val, + mi->mi_startTime.bv_val, + mi->mi_startTime.bv_val ); + + e = str2entry( buf ); + if ( e == NULL ) { + Debug( LDAP_DEBUG_ANY, + "monitor_subsys_thread_init: " + "unable to create entry \"cn=Runqueue,%s\"\n", + ms->mss_ndn.bv_val, 0, 0 ); + return( -1 ); + } + + 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; + + if ( monitor_cache_add( mi, e ) ) { + Debug( LDAP_DEBUG_ANY, + "monitor_subsys_thread_init: " + "unable to add entry \"cn=Runqueue,%s\"\n", + ms->mss_ndn.bv_val, 0, 0 ); + return( -1 ); + } + + *ep = e; + ep = &mp->mp_next; + monitor_cache_release( mi, e_thread ); return( 0 ); @@ -173,29 +226,49 @@ monitor_subsys_thread_update( Attribute *a; char buf[ BACKMONITOR_BUFSIZE ]; static struct berval backload_bv = BER_BVC( "cn=backload" ); - struct berval rdn; + static struct berval runqueue_bv = BER_BVC( "cn=runqueue" ); + struct berval rdn, bv; ber_len_t len; + int which = 0; + struct re_s *re; assert( mi != NULL ); dnRdn( &e->e_nname, &rdn ); - if ( !dn_match( &rdn, &backload_bv ) ) { + if ( dn_match( &rdn, &backload_bv )) + which = 1; + else if ( dn_match( &rdn, &runqueue_bv )) + which = 2; + else return 0; - } - - a = attr_find( e->e_attrs, mi->mi_ad_monitoredInfo ); - if ( a == NULL ) { - return -1; - } - snprintf( buf, sizeof( buf ), "%d", + switch( which ) { + case 1: + a = attr_find( e->e_attrs, mi->mi_ad_monitoredInfo ); + if ( a == NULL ) { + return -1; + } + snprintf( buf, sizeof( buf ), "%d", ldap_pvt_thread_pool_backload( &connection_pool ) ); - len = strlen( buf ); - if ( len > a->a_vals[ 0 ].bv_len ) { - a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 ); + len = strlen( buf ); + if ( len > a->a_vals[ 0 ].bv_len ) { + a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 ); + } + a->a_vals[ 0 ].bv_len = len; + AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 ); + break; + case 2: + attr_delete( &e->e_attrs, mi->mi_ad_monitoredInfo ); + bv.bv_val = buf; + ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); + LDAP_STAILQ_FOREACH( re, &slapd_rq.run_list, rnext ) { + bv.bv_len = snprintf( buf, sizeof( buf ), "%s(%s)", + re->tname, re->tspec ); + attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL ); + } + ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); + break; } - a->a_vals[ 0 ].bv_len = len; - AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 ); /* FIXME: touch modifyTimestamp? */ diff --git a/servers/slapd/overlays/pcache.c b/servers/slapd/overlays/pcache.c index 88268f141e..8b9a479632 100644 --- a/servers/slapd/overlays/pcache.c +++ b/servers/slapd/overlays/pcache.c @@ -1741,7 +1741,8 @@ proxy_cache_open( if ( slapMode & SLAP_SERVER_MODE ) { ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex ); ldap_pvt_runqueue_insert( &slapd_rq, cm->cc_period, - consistency_check, on ); + consistency_check, on, + "pcache_consistency", be->be_suffix[0].bv_val ); ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex ); /* Cached database must have the rootdn */ diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index a5a5a3cad1..006cfd1bc0 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -2628,7 +2628,7 @@ add_syncrepl( si->si_be = be; init_syncrepl( si ); si->si_re = ldap_pvt_runqueue_insert( &slapd_rq, si->si_interval, - do_syncrepl, si ); + do_syncrepl, si, "do_syncrepl", be->be_suffix[0].bv_val ); if ( !si->si_re ) rc = -1; }