From ca646cd02d17ba57f5f7c3f82b62d31181a5ca6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Wed, 14 Feb 2018 15:44:51 +0000 Subject: [PATCH] Fix operation counts Trying to abandon an operation does not automatically make it completed, it might have failed already but we're just racing to reach the client to record that. --- servers/lloadd/operation.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/servers/lloadd/operation.c b/servers/lloadd/operation.c index 40204d2ba8..efd2531a5a 100644 --- a/servers/lloadd/operation.c +++ b/servers/lloadd/operation.c @@ -609,10 +609,6 @@ operation_abandon( LloadOperation *op ) int rc = LDAP_SUCCESS; ldap_pvt_thread_mutex_lock( &op->o_link_mutex ); - /* for now consider all abandoned operations completed, - * perhaps add a separate counter later */ - op->o_res = LLOAD_OP_COMPLETED; - c = op->o_upstream; if ( !c ) { ldap_pvt_thread_mutex_unlock( &op->o_link_mutex ); @@ -621,6 +617,11 @@ operation_abandon( LloadOperation *op ) CONNECTION_LOCK(c); ldap_pvt_thread_mutex_unlock( &op->o_link_mutex ); + + /* for now consider all abandoned operations completed, + * perhaps add a separate counter later */ + op->o_res = LLOAD_OP_COMPLETED; + if ( tavl_delete( &c->c_ops, op, operation_upstream_cmp ) == NULL ) { /* The operation has already been abandoned or finished */ Debug( LDAP_DEBUG_TRACE, "operation_abandon: " @@ -806,6 +807,7 @@ operation_lost_upstream( LloadOperation *op ) { LloadConnection *c = op->o_upstream; CONNECTION_LOCK(c); + op->o_res = LLOAD_OP_FAILED; op->o_upstream_refcnt++; /* Matching the op reference on the connection as well */ CONNECTION_UNLOCK_INCREF(c); @@ -815,7 +817,6 @@ operation_lost_upstream( LloadOperation *op ) CONNECTION_LOCK_DECREF(c); op->o_upstream_refcnt--; - op->o_res = LLOAD_OP_FAILED; operation_destroy_from_upstream( op ); CONNECTION_UNLOCK(c); } @@ -1021,7 +1022,8 @@ done: void operation_update_global_rejected( LloadOperation *op ) { - if ( op->o_res == LLOAD_OP_REJECTED && op->o_upstream_connid == 0 ) { + if ( op->o_res == LLOAD_OP_REJECTED ) { + assert( op->o_upstream_connid == 0 ); switch ( op->o_tag ) { case LDAP_REQ_BIND: lload_stats.counters[LLOAD_STATS_OPS_BIND].lc_ops_rejected++;