1 /* thread.c - deal with thread subsystem */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2003 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 * This work was initially developed by Pierangelo Masarati for inclusion
18 * in OpenLDAP Software.
20 /* This is an altered version */
22 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
24 * This work has beed deveolped for the OpenLDAP Foundation
25 * in the hope that it may be useful to the Open Source community,
26 * but WITHOUT ANY WARRANTY.
28 * Permission is granted to anyone to use this software for any purpose
29 * on any computer system, and to alter it and redistribute it, subject
30 * to the following restrictions:
32 * 1. The author and SysNet s.n.c. are not responsible for the consequences
33 * of use of this software, no matter how awful, even if they arise from
36 * 2. The origin of this software must not be misrepresented, either by
37 * explicit claim or by omission. Since few users ever read sources,
38 * credits should appear in the documentation.
40 * 3. Altered versions must be plainly marked as such, and must not be
41 * misrepresented as being the original software. Since few users
42 * ever read sources, credits should appear in the documentation.
43 * SysNet s.n.c. cannot be responsible for the consequences of the
46 * 4. This notice may not be removed or altered.
52 #include <ac/string.h>
55 #include "back-monitor.h"
58 * * initializes log subentry
61 monitor_subsys_thread_init(
65 struct monitorinfo *mi;
67 static char buf[ BACKMONITOR_BUFSIZE ];
70 mi = ( struct monitorinfo * )be->be_private;
72 if ( monitor_cache_get( mi,
73 &monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn, &e ) )
76 LDAP_LOG( OPERATION, CRIT,
77 "monitor_subsys_thread_init: unable to get entry '%s'\n",
78 monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val, 0, 0 );
80 Debug( LDAP_DEBUG_ANY,
81 "monitor_subsys_thread_init: unable to get entry '%s'\n",
82 monitor_subsys[SLAPD_MONITOR_THREAD].mss_ndn.bv_val,
88 /* initialize the thread number */
89 snprintf( buf, sizeof( buf ), "max=%d", connection_pool_max );
92 bv.bv_len = strlen( bv.bv_val );
94 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
96 monitor_cache_release( mi, e );
102 monitor_subsys_thread_update(
107 struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
109 struct berval *b = NULL;
110 char buf[ BACKMONITOR_BUFSIZE ];
112 assert( mi != NULL );
114 snprintf( buf, sizeof( buf ), "backload=%d",
115 ldap_pvt_thread_pool_backload( &connection_pool ) );
117 a = attr_find( e->e_attrs, mi->mi_ad_monitoredInfo );
119 for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
120 if ( strncmp( b[0].bv_val, "backload=",
121 sizeof( "backload=" ) - 1 ) == 0 ) {
123 ber_str2bv( buf, 0, 1, &b[0] );
129 if ( b == NULL || b[0].bv_val == NULL ) {
133 bv.bv_len = strlen( buf );
134 attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,