From: Ondřej Kuzník Date: Tue, 25 Jan 2022 14:13:07 +0000 (+0000) Subject: ITS#9789 slapd-asyncmeta: Reset op->o_counters every time we migrate to a new thread X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5d86968c7f953649cfab9a14187757789db22c2;p=thirdparty%2Fopenldap.git ITS#9789 slapd-asyncmeta: Reset op->o_counters every time we migrate to a new thread --- diff --git a/servers/slapd/back-asyncmeta/add.c b/servers/slapd/back-asyncmeta/add.c index 50905c730e..55277eecf5 100644 --- a/servers/slapd/back-asyncmeta/add.c +++ b/servers/slapd/back-asyncmeta/add.c @@ -51,6 +51,7 @@ asyncmeta_error_cleanup(Operation *op, } asyncmeta_drop_bc(mc, bc); slap_sl_mem_setctx(op->o_threadctx, op->o_tmpmemctx); + operation_counter_init( op, op->o_threadctx ); ldap_pvt_thread_mutex_unlock( &mc->mc_om_mutex); send_ldap_result(op, rs); return LDAP_SUCCESS; diff --git a/servers/slapd/back-asyncmeta/meta_result.c b/servers/slapd/back-asyncmeta/meta_result.c index 07863bbfb6..0ce279a1df 100644 --- a/servers/slapd/back-asyncmeta/meta_result.c +++ b/servers/slapd/back-asyncmeta/meta_result.c @@ -650,6 +650,7 @@ asyncmeta_send_all_pending_ops(a_metaconn_t *mc, int candidate, void *ctx, int d bc->op->o_threadctx = ctx; bc->op->o_tid = ldap_pvt_thread_pool_tid( ctx ); slap_sl_mem_setctx(ctx, bc->op->o_tmpmemctx); + operation_counter_init( bc->op, ctx ); bc->bc_active++; ret = asyncmeta_send_pending_op(bc, candidate); if (ret != META_SEARCH_CANDIDATE) { @@ -699,6 +700,7 @@ asyncmeta_return_bind_errors(a_metaconn_t *mc, int candidate, SlapReply *bind_re bc->op->o_threadctx = ctx; bc->op->o_tid = ldap_pvt_thread_pool_tid( ctx ); slap_sl_mem_setctx(ctx, bc->op->o_tmpmemctx); + operation_counter_init( bc->op, ctx ); bc->rs.sr_err = bind_result->sr_err; bc->rs.sr_text = bind_result->sr_text; mc->pending_ops--; @@ -1422,6 +1424,7 @@ asyncmeta_op_read_error(a_metaconn_t *mc, int candidate, int error, void* ctx) bc->op->o_threadctx = ctx; bc->op->o_tid = ldap_pvt_thread_pool_tid( ctx ); slap_sl_mem_setctx(ctx, bc->op->o_tmpmemctx); + operation_counter_init( bc->op, ctx ); op = bc->op; rs = &bc->rs; @@ -1569,6 +1572,7 @@ retry_bc: bc->op->o_threadctx = ctx; bc->op->o_tid = ldap_pvt_thread_pool_tid( ctx ); slap_sl_mem_setctx(ctx, bc->op->o_tmpmemctx); + operation_counter_init( bc->op, ctx ); if (bc->op->o_abandon) { ldap_pvt_thread_mutex_lock( &mc->mc_om_mutex ); asyncmeta_drop_bc( mc, bc); @@ -1668,12 +1672,14 @@ void* asyncmeta_timeout_loop(void *ctx, void *arg) } if (bc->op->o_abandon ) { - /* set our memctx */ - bc->op->o_threadctx = ctx; - bc->op->o_tid = ldap_pvt_thread_pool_tid( ctx ); - slap_sl_mem_setctx(ctx, bc->op->o_tmpmemctx); Operation *op = bc->op; + /* set our memctx */ + op->o_threadctx = ctx; + op->o_tid = ldap_pvt_thread_pool_tid( ctx ); + slap_sl_mem_setctx(ctx, op->o_tmpmemctx); + operation_counter_init( op, ctx ); + LDAP_STAILQ_REMOVE(&mc->mc_om_list, bc, bm_context_t, bc_next); mc->pending_ops--; for (j=0; jmi_ntargets; j++) { @@ -1730,6 +1736,7 @@ void* asyncmeta_timeout_loop(void *ctx, void *arg) bc->op->o_threadctx = ctx; bc->op->o_tid = ldap_pvt_thread_pool_tid( ctx ); slap_sl_mem_setctx(ctx, bc->op->o_tmpmemctx); + operation_counter_init( bc->op, ctx ); if (bc->searchtime) { timeout_err = LDAP_TIMELIMIT_EXCEEDED; diff --git a/servers/slapd/back-asyncmeta/search.c b/servers/slapd/back-asyncmeta/search.c index 69e5354aff..ab32c484bc 100644 --- a/servers/slapd/back-asyncmeta/search.c +++ b/servers/slapd/back-asyncmeta/search.c @@ -58,6 +58,7 @@ asyncmeta_handle_onerr_stop(Operation *op, } } slap_sl_mem_setctx(op->o_threadctx, op->o_tmpmemctx); + operation_counter_init( op, op->o_threadctx ); ldap_pvt_thread_mutex_unlock( &mc->mc_om_mutex); send_ldap_result(op, rs); }