From: Kurt Zeilenga Date: Wed, 30 Jun 1999 02:50:40 +0000 (+0000) Subject: Reimplement connection counters. Format of "connection" attribute X-Git-Tag: OPENLDAP_REL_ENG_2_BP~214 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=14820afdd92de4be08fdebd88796ab24b45974b9;p=openldap Reimplement connection counters. Format of "connection" attribute changed significantly. --- diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 7546d42e1e..dd56160232 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -238,6 +238,8 @@ static Connection* connection_get( ber_socket_t s ) "connection_get(%d): got connid=%ld\n", s, c->c_connid, 0 ); + c->c_n_get++; + assert( c->c_struct_state == SLAP_C_USED ); assert( c->c_conn_state != SLAP_C_INVALID ); assert( ber_pvt_sb_in_use( c->c_sb ) ); @@ -349,11 +351,13 @@ long connection_init( c->c_client_addr = ch_strdup( addr ); c->c_n_ops_received = 0; -#ifdef LDAP_COUNTERS c->c_n_ops_executing = 0; c->c_n_ops_pending = 0; c->c_n_ops_completed = 0; -#endif + + c->c_n_get = 0; + c->c_n_read = 0; + c->c_n_write = 0; c->c_activitytime = c->c_starttime = slap_get_time(); @@ -602,11 +606,9 @@ connection_operation( void *arg_v ) ber_tag_t tag = arg->co_op->o_tag; Connection *conn = arg->co_conn; -#ifdef LDAP_COUNTERS ldap_pvt_thread_mutex_lock( &num_ops_mutex ); num_ops_initiated++; ldap_pvt_thread_mutex_unlock( &num_ops_mutex ); -#endif switch ( tag ) { case LDAP_REQ_BIND: @@ -651,17 +653,14 @@ connection_operation( void *arg_v ) break; } -#ifdef LDAP_COUNTERS ldap_pvt_thread_mutex_lock( &num_ops_mutex ); num_ops_completed++; ldap_pvt_thread_mutex_unlock( &num_ops_mutex ); -#endif ldap_pvt_thread_mutex_lock( &conn->c_mutex ); -#ifdef LDAP_COUNTERS + conn->c_n_ops_executing--; conn->c_n_ops_completed++; -#endif slap_op_remove( &conn->c_ops, arg->co_op ); slap_op_free( arg->co_op ); @@ -718,6 +717,8 @@ int connection_read(ber_socket_t s) return -1; } + c->c_n_read++; + if( c->c_conn_state == SLAP_C_CLOSING ) { Debug( LDAP_DEBUG_TRACE, "connection_read(%d): closing, ignoring input for id=%ld\n", @@ -826,9 +827,11 @@ connection_input( || conn->c_conn_state == SLAP_C_CLOSING ) { Debug( LDAP_DEBUG_ANY, "deferring operation\n", 0, 0, 0 ); + conn->c_n_ops_pending++; slap_op_add( &conn->c_pending_ops, op ); } else { + conn->c_n_ops_executing++; connection_op_activate( conn, op ); } @@ -869,6 +872,9 @@ connection_resched( Connection *conn ) /* pending operations should not be marked for abandonment */ assert(!op->o_abandon); + conn->c_n_ops_pending--; + conn->c_n_ops_executing++; + connection_op_activate( conn, op ); if ( conn->c_conn_state == SLAP_C_BINDING ) { @@ -947,6 +953,8 @@ int connection_write(ber_socket_t s) return -1; } + c->c_n_write++; + Debug( LDAP_DEBUG_TRACE, "connection_write(%d): waking output for id=%ld\n", s, c->c_connid, 0 ); diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index eccdcbec12..1e0a95546c 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -33,13 +33,10 @@ monitor_info( Connection *conn, Operation *op ) int nconns, nwritewaiters, nreadwaiters; struct tm *ltm; char *p; -#ifdef LDAP_COUNTERS - int i; - char buf2[22] - char buf3[22] + char buf2[22]; + char buf3[22]; Connection *c; int connindex; -#endif time_t currenttime; vals[0] = &val; @@ -71,7 +68,6 @@ monitor_info( Connection *conn, Operation *op ) nwritewaiters = 0; nreadwaiters = 0; -#ifdef LDAP_COUNTERS /* loop through the connections */ for ( c = connection_first( &connindex ); c != NULL; @@ -90,25 +86,45 @@ monitor_info( Connection *conn, Operation *op ) ltm = gmtime( &c->c_starttime ); strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm ); - ltm = gmtime( &c->.c_activitytime ); - strftime( buf3, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); + ltm = gmtime( &c->c_activitytime ); + strftime( buf3, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm ); #else ltm = localtime( &c->.c_starttime ); strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); - ltm = localtime( &c->.c_activitytime ); + ltm = localtime( &c->c_activitytime ); strftime( buf3, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); #endif ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); - sprintf( buf, "%d : %s : %d : %d : %s : %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" : "" + sprintf( buf, + "%ld : %ld " + ": %ld/%ld/%ld/%ld " + ": %ld/%ld/%ld " + ": %s%s%s%s " + ": %s : %s : %s " + ": %s : %s", + + c->c_connid, + (long) c->c_protocol, + + c->c_n_ops_received, c->c_n_ops_executing, + c->c_n_ops_pending, c->c_n_ops_completed, + + /* add low-level counters here */ + c->c_n_get, c->c_n_read, c->c_n_write, + + c->c_currentber ? "r" : "", + c->c_writewaiter ? "w" : "", + c->c_ops != NULL ? "x" : "", + c->c_pending_ops != NULL ? "p" : "", + + c->c_cdn ? c->c_cdn : "", + c->c_client_addr ? c->c_client_addr : "unknown", + c->c_client_name ? c->c_client_name : "unknown", + + buf2, buf3 ); @@ -117,7 +133,6 @@ monitor_info( Connection *conn, Operation *op ) attr_merge( e, "connection", vals ); } connection_done(c); -#endif sprintf( buf, "%d", nconns ); val.bv_val = buf; @@ -144,7 +159,6 @@ monitor_info( Connection *conn, Operation *op ) val.bv_len = strlen( buf ); attr_merge( e, "readwaiters", vals ); -#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); @@ -172,7 +186,6 @@ monitor_info( Connection *conn, Operation *op ) val.bv_val = buf; val.bv_len = strlen( buf ); attr_merge( e, "bytessent", vals ); -#endif currenttime = slap_get_time(); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index c9b944fc09..de4c6cd45c 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -553,6 +553,10 @@ typedef struct slap_conn { long c_n_ops_executing; /* num of ops currently executing */ long c_n_ops_pending; /* num of ops pending execution */ long c_n_ops_completed; /* num of ops completed */ + + long c_n_get; /* num of get calls */ + long c_n_read; /* num of read calls */ + long c_n_write; /* num of write calls */ } Connection; #if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)