1 /* thread.c - deal with thread subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2004 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
25 #include <ac/string.h>
28 #include "back-monitor.h"
31 * * initializes log subentry
34 monitor_subsys_thread_init(
38 struct monitorinfo *mi;
40 static char buf[ BACKMONITOR_BUFSIZE ];
43 mi = ( struct monitorinfo * )be->be_private;
45 if ( monitor_cache_get( mi,
46 &monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn, &e ) )
49 LDAP_LOG( OPERATION, CRIT,
50 "monitor_subsys_thread_init: unable to get entry '%s'\n",
51 monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val, 0, 0 );
53 Debug( LDAP_DEBUG_ANY,
54 "monitor_subsys_thread_init: unable to get entry '%s'\n",
55 monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val,
61 /* initialize the thread number */
62 snprintf( buf, sizeof( buf ), "max=%d", connection_pool_max );
65 bv.bv_len = strlen( bv.bv_val );
67 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
69 monitor_cache_release( mi, e );
75 monitor_subsys_thread_update(
80 struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
82 struct berval *b = NULL;
83 char buf[ BACKMONITOR_BUFSIZE ];
87 snprintf( buf, sizeof( buf ), "backload=%d",
88 ldap_pvt_thread_pool_backload( &connection_pool ) );
90 a = attr_find( e->e_attrs, mi->mi_ad_monitoredInfo );
92 for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
93 if ( strncmp( b[0].bv_val, "backload=",
94 sizeof( "backload=" ) - 1 ) == 0 ) {
96 ber_str2bv( buf, 0, 1, &b[0] );
102 if ( b == NULL || b[0].bv_val == NULL ) {
106 bv.bv_len = strlen( buf );
107 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,