* is provided ``as is'' without express or implied warranty.
*/
-/* Revision history
- *
- * 5-Jun-96 jeff.hodges@stanford.edu
- * Added locking of new_conn_mutex when traversing the c[] array.
- * Added locking of currenttime_mutex to protect call(s) to localtime().
- */
-
#include "portable.h"
#include <stdio.h>
struct berval *vals[2];
int i, nconns, nwritewaiters, nreadwaiters;
struct tm *ltm;
- char *p, *tmpdn;
+ char *p;
+ Connection *c;
+ time_t currenttime;
vals[0] = &val;
vals[1] = NULL;
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
/* initialize reader/writer lock */
- entry_rdwr_init(e);
e->e_attrs = NULL;
e->e_dn = ch_strdup( SLAPD_MONITOR_DN );
e->e_ndn = dn_normalize_case( ch_strdup(SLAPD_MONITOR_DN) );
+ e->e_private = NULL;
val.bv_val = Versionstr;
if (( p = strchr( Versionstr, '\n' )) == NULL ) {
}
attr_merge( e, "version", vals );
+ ldap_pvt_thread_mutex_lock( &active_threads_mutex );
sprintf( buf, "%d", active_threads );
+ ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "threads", vals );
nwritewaiters = 0;
nreadwaiters = 0;
- ldap_pvt_thread_mutex_lock( &new_conn_mutex );
- for ( i = 0; i < dtblsize; i++ ) {
- if ( c[i].c_sb.sb_sd != -1 ) {
- nconns++;
- if ( c[i].c_writewaiter ) {
- nwritewaiters++;
- }
- if ( c[i].c_gettingber ) {
- nreadwaiters++;
- }
- ldap_pvt_thread_mutex_lock( ¤ttime_mutex );
+#ifdef LDAP_COUNTERS
+ /* loop through the connections */
+ for ( c = connection_first() ; c != NULL; c = connection_next(c) ) {
+ nconns++;
+ if ( c->c_writewaiter ) {
+ nwritewaiters++;
+ }
+ if ( c->c_currentber != NULL ) {
+ nreadwaiters++;
+ }
+
+ ldap_pvt_thread_mutex_lock( &gmtime_mutex );
#ifndef LDAP_LOCALTIME
- ltm = gmtime( &c[i].c_starttime );
- strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm );
+ ltm = gmtime( &c->c_starttime );
+ strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm );
#else
- ltm = localtime( &c[i].c_starttime );
- strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm );
+ ltm = localtime( &c->.c_starttime );
+ strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm );
#endif
- ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );
-
- ldap_pvt_thread_mutex_lock( &c[i].c_dnmutex );
- sprintf( buf, "%d : %s : %d : %d : %s : %s%s", i,
- buf2, c[i].c_opsinitiated, c[i].c_opscompleted,
- c[i].c_cdn ? c[i].c_cdn : "NULLDN",
- c[i].c_gettingber ? "r" : "",
- c[i].c_writewaiter ? "w" : "" );
- ldap_pvt_thread_mutex_unlock( &c[i].c_dnmutex );
- val.bv_val = buf;
- val.bv_len = strlen( buf );
- attr_merge( e, "connection", vals );
- }
+ ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+
+ sprintf( buf, "%d : %s : %d : %d : %s : %s%s%s%s", i,
+ buf2, c[i].c_n_ops_received, c[i].c_n_ops_completed,
+ c[i].c_cdn ? c[i].c_cdn : "NULLDN",
+ c[i].c_currentber ? "r" : "",
+ c[i].c_writewaiter ? "w" : "",
+ c[i].c_ops != NULL ? "x" : "",
+ c[i].c_pending_ops != NULL ? "p" : ""
+ );
+
+ val.bv_val = buf;
+ val.bv_len = strlen( buf );
+ attr_merge( e, "connection", vals );
}
- ldap_pvt_thread_mutex_unlock( &new_conn_mutex );
+ connection_done(c);
+#endif
sprintf( buf, "%d", nconns );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "currentconnections", vals );
- sprintf( buf, "%d", num_conns );
+ sprintf( buf, "%ld", connections_nextid() );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "totalconnections", vals );
val.bv_len = strlen( buf );
attr_merge( e, "readwaiters", vals );
- sprintf( buf, "%ld", ops_initiated );
+#ifdef LDAP_COUNTERS
+ ldap_pvt_thread_mutex_lock(&num_ops_mutex);
+ sprintf( buf, "%ld", num_ops_initiated );
+ ldap_pvt_thread_mutex_unlock(&num_ops_mutex);
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "opsinitiated", vals );
- sprintf( buf, "%ld", ops_completed );
+ ldap_pvt_thread_mutex_lock(&num_ops_mutex);
+ sprintf( buf, "%ld", num_ops_completed );
+ ldap_pvt_thread_mutex_unlock(&num_ops_mutex);
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "opscompleted", vals );
+ ldap_pvt_thread_mutex_lock(&num_sent_mutex);
sprintf( buf, "%ld", num_entries_sent );
+ ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "entriessent", vals );
+ ldap_pvt_thread_mutex_lock(&num_sent_mutex);
sprintf( buf, "%ld", num_bytes_sent );
+ ldap_pvt_thread_mutex_unlock(&num_sent_mutex);
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "bytessent", vals );
+#endif
- ldap_pvt_thread_mutex_lock( ¤ttime_mutex );
+ currenttime = slap_get_time();
+
+ ldap_pvt_thread_mutex_lock( &gmtime_mutex );
#ifndef LDAP_LOCALTIME
ltm = gmtime( ¤ttime );
strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
ltm = localtime( ¤ttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
#endif
- ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "currenttime", vals );
- ldap_pvt_thread_mutex_lock( ¤ttime_mutex );
#ifndef LDAP_LOCALTIME
ltm = gmtime( &starttime );
strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
ltm = localtime( &starttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
#endif
- ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );
+ ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "starttime", vals );
attr_merge( e, "nbackends", vals );
#ifdef HAVE_THREAD_CONCURRENCY
- sprintf( buf, "%d", ldap_pvt_thread_getconcurrency() );
+ sprintf( buf, "%d", ldap_pvt_thread_get_concurrency() );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "concurrency", vals );