1 /* readw.c - deal with read waiters subsystem */
3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
9 * This work has beed deveolped for the OpenLDAP Foundation
10 * in the hope that it may be useful to the Open Source community,
11 * but WITHOUT ANY WARRANTY.
13 * Permission is granted to anyone to use this software for any purpose
14 * on any computer system, and to alter it and redistribute it, subject
15 * to the following restrictions:
17 * 1. The author and SysNet s.n.c. are not responsible for the consequences
18 * of use of this software, no matter how awful, even if they arise from
21 * 2. The origin of this software must not be misrepresented, either by
22 * explicit claim or by omission. Since few users ever read sources,
23 * credits should appear in the documentation.
25 * 3. Altered versions must be plainly marked as such, and must not be
26 * misrepresented as being the original software. Since few users
27 * ever read sources, credits should appear in the documentation.
28 * SysNet s.n.c. cannot be responsible for the consequences of the
31 * 4. This notice may not be removed or altered.
39 #include "back-monitor.h"
41 static int monitor_subsys_readw_update_internal( struct monitorinfo *mi, Entry *e, int rw );
44 monitor_subsys_readw_update(
45 struct monitorinfo *mi,
49 return monitor_subsys_readw_update_internal( mi, e, 0 );
53 monitor_subsys_writew_update(
54 struct monitorinfo *mi,
58 return monitor_subsys_readw_update_internal( mi, e, 1 );
62 monitor_subsys_readw_update_internal(
63 struct monitorinfo *mi,
70 int nconns, nwritewaiters, nreadwaiters;
73 struct berval bv[2], *b = NULL;
84 nconns = nwritewaiters = nreadwaiters = 0;
85 for ( c = connection_first( &connindex );
87 c = connection_next( c, &connindex ), nconns++ ) {
88 if ( c->c_writewaiter ) {
91 if ( c->c_currentber != NULL ) {
103 str = "write waiters";
107 snprintf( buf, sizeof( buf ), "%s=%d", str, num );
109 if ( ( a = attr_find( e->e_attrs, monitor_ad_desc ) ) != NULL ) {
110 for ( b = a->a_vals; b[0].bv_val != NULL; b++ ) {
111 if ( strncmp( b[0].bv_val, str, strlen( str ) ) == 0 ) {
113 ber_str2bv( buf, 0, 1, b );
119 if ( b == NULL || b[0].bv_val == NULL ) {
121 bv[0].bv_len = strlen( buf );
122 attr_merge( e, monitor_ad_desc, bv );