]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9628 Fix incorrect c_n_ops_executing counter when backend is asynchronous
authorNadezhda Ivanova <nivanova@symas.com>
Tue, 22 Jun 2021 14:03:44 +0000 (17:03 +0300)
committerOndřej Kuzník <ondra@openldap.org>
Thu, 12 Aug 2021 15:57:49 +0000 (15:57 +0000)
servers/slapd/back-monitor/back-monitor.h
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/init.c
servers/slapd/connection.c
servers/slapd/slap.h
servers/slapd/slapi/slapi_ops.c

index 3f3d81bd991b62527a6e2f119937f2a879b3ff12..b7126d025bec77a6bb5678f80ce18f4c17237b21 100644 (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
index 4d327f2430a7eab479f310074473e5da29edb221..f586e94deb8d696b30066ef1146b181737f96249 100644 (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 );
 
index b779619893baca876872bb6ff50a5f0a04abc4d3..52ec170238c1600aaebb5ccce0db0ef40adbd3bf 100644 (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 }
        };
 
index 02b2861ae037eb89dd547face07af34ca691da5b..785076da2de2b084bf4755ec89910d8baba57a11 100644 (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;
index 769da46c9d6ffcfe067bc148cf4a95869929b56c..89d3aa4ae45e7637ce673a891c830ab8e373fd78 100644 (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 */
index c58d9b3c8d6f6c93794830c68a4417bfc7743205..088a71a693003d0207cc996045d1616ac6c17886 100644 (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;