ITS#9628 Fix incorrect c_n_ops_executing counter when backend is asynchronous

This commit is contained in:
Nadezhda Ivanova 2021-06-22 17:03:44 +03:00 committed by Ondřej Kuzník
parent ee7a87b017
commit 81ed9e0d0e
6 changed files with 19 additions and 3 deletions

View File

@ -132,6 +132,7 @@ typedef struct monitor_info_t {
AttributeDescription *mi_ad_monitorUpdateRef;
AttributeDescription *mi_ad_monitorRuntimeConfig;
AttributeDescription *mi_ad_monitorSuperiorDN;
AttributeDescription *mi_ad_monitorConnectionOpsAsync;
/*
* Generic description attribute

View File

@ -369,6 +369,9 @@ conn_create(
bv.bv_len = snprintf( buf, sizeof( buf ), "%ld", c->c_n_ops_completed );
attr_merge_one( e, mi->mi_ad_monitorConnectionOpsCompleted, &bv, NULL );
bv.bv_len = snprintf( buf, sizeof( buf ), "%ld", c->c_n_ops_async );
attr_merge_one( e, mi->mi_ad_monitorConnectionOpsAsync, &bv, NULL );
bv.bv_len = snprintf( buf, sizeof( buf ), "%ld", c->c_n_get );
attr_merge_one( e, mi->mi_ad_monitorConnectionGet, &bv, NULL );

View File

@ -1951,6 +1951,13 @@ monitor_back_initialize(
"NO-USER-MODIFICATION "
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
offsetof(monitor_info_t, mi_ad_monitorSuperiorDN) },
{ "( 1.3.6.1.4.1.4203.666.1.55.31 "
"NAME 'monitorConnectionOpsAsync' "
"DESC 'monitor number of asynchronous operations in execution within the connection' "
"SUP monitorCounter "
"NO-USER-MODIFICATION "
"USAGE dSAOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
offsetof(monitor_info_t, mi_ad_monitorConnectionOpsAsync) },
{ NULL, 0, -1 }
};

View File

@ -212,7 +212,7 @@ int connections_timeout_idle(time_t now)
/* Don't timeout a slow-running request or a persistent
* outbound connection.
*/
if(( c->c_n_ops_executing && !c->c_writewaiter)
if((( c->c_n_ops_executing || c->c_n_ops_async ) && !c->c_writewaiter)
|| c->c_conn_state == SLAP_C_CLIENT ) {
continue;
}
@ -244,7 +244,7 @@ void connections_drop()
/* Don't close a slow-running request or a persistent
* outbound connection.
*/
if(( c->c_n_ops_executing && !c->c_writewaiter)
if((( c->c_n_ops_executing || c->c_n_ops_async ) && !c->c_writewaiter)
|| c->c_conn_state == SLAP_C_CLIENT ) {
continue;
}
@ -428,6 +428,7 @@ Connection * connection_init(
c->c_n_ops_executing = 0;
c->c_n_ops_pending = 0;
c->c_n_ops_completed = 0;
c->c_n_ops_async = 0;
c->c_n_get = 0;
c->c_n_read = 0;
@ -1004,7 +1005,7 @@ connection_op_finish( Operation *op, int lock )
LDAP_STAILQ_REMOVE( &conn->c_ops, op, Operation, o_next);
LDAP_STAILQ_NEXT(op, o_next) = NULL;
conn->c_n_ops_executing--;
conn->c_n_ops_async--;
conn->c_n_ops_completed++;
connection_resched( conn );
if ( lock )
@ -1122,6 +1123,8 @@ operations_error:
*/
slap_sl_mem_setctx( ctx, NULL );
ldap_pvt_thread_mutex_lock( &conn->c_mutex );
conn->c_n_ops_executing--;
conn->c_n_ops_async++;
connection_resched( conn );
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
return NULL;

View File

@ -2975,6 +2975,7 @@ struct Connection {
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_ops_async; /* mum of ops currently executing asynchronously */
long c_n_get; /* num of get calls */
long c_n_read; /* num of read calls */

View File

@ -233,6 +233,7 @@ slapi_int_connection_init_pb( Slapi_PBlock *pb, ber_tag_t tag )
conn->c_n_ops_executing = 0;
conn->c_n_ops_pending = 0;
conn->c_n_ops_completed = 0;
conn->c_n_ops_async = 0;
conn->c_n_get = 0;
conn->c_n_read = 0;