From 3fa3e6ac17cbab8003ce3b3ae87928de5f5eaaf4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 3 Jun 2024 07:34:56 +0200 Subject: Adding upstream version 2.6.8+dfsg. Signed-off-by: Daniel Baumann --- servers/slapd/back-meta/conn.c | 70 ++++++------------------------------------ 1 file changed, 10 insertions(+), 60 deletions(-) (limited to 'servers/slapd/back-meta/conn.c') diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 91fdad3..f9a1f23 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1999-2022 The OpenLDAP Foundation. + * Copyright 1999-2024 The OpenLDAP Foundation. * Portions Copyright 2001-2003 Pierangelo Masarati. * Portions Copyright 1999-2003 Howard Chu. * All rights reserved. @@ -699,7 +699,8 @@ meta_back_retry( SlapReply *rs, metaconn_t **mcp, int candidate, - ldap_back_send_t sendok ) + ldap_back_send_t sendok, + SlapReply *candidates ) { metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; metatarget_t *mt = mi->mi_targets[ candidate ]; @@ -971,64 +972,14 @@ meta_back_get_candidate( return candidate; } -static void *meta_back_candidates_dummy; - -static void -meta_back_candidates_keyfree( - void *key, - void *data ) -{ - metacandidates_t *mc = (metacandidates_t *)data; - - ber_memfree_x( mc->mc_candidates, NULL ); - ber_memfree_x( data, NULL ); -} - SlapReply * meta_back_candidates_get( Operation *op ) { metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; - metacandidates_t *mc; - - if ( op->o_threadctx ) { - void *data = NULL; - - ldap_pvt_thread_pool_getkey( op->o_threadctx, - &meta_back_candidates_dummy, &data, NULL ); - mc = (metacandidates_t *)data; + SlapReply *candidates; - } else { - mc = mi->mi_candidates; - } - - if ( mc == NULL ) { - mc = ch_calloc( sizeof( metacandidates_t ), 1 ); - mc->mc_ntargets = mi->mi_ntargets; - mc->mc_candidates = ch_calloc( sizeof( SlapReply ), mc->mc_ntargets ); - if ( op->o_threadctx ) { - void *data = NULL; - - data = (void *)mc; - ldap_pvt_thread_pool_setkey( op->o_threadctx, - &meta_back_candidates_dummy, data, - meta_back_candidates_keyfree, - NULL, NULL ); - - } else { - mi->mi_candidates = mc; - } - - } else if ( mc->mc_ntargets < mi->mi_ntargets ) { - /* NOTE: in the future, may want to allow back-config - * to add/remove targets from back-meta... */ - mc->mc_candidates = ch_realloc( mc->mc_candidates, - sizeof( SlapReply ) * mi->mi_ntargets ); - memset( &mc->mc_candidates[ mc->mc_ntargets ], 0, - sizeof( SlapReply ) * ( mi->mi_ntargets - mc->mc_ntargets ) ); - mc->mc_ntargets = mi->mi_ntargets; - } - - return mc->mc_candidates; + candidates = op->o_tmpcalloc( mi->mi_ntargets, sizeof( SlapReply ), op->o_tmpmemctx ); + return candidates; } /* @@ -1066,10 +1017,11 @@ meta_back_candidates_get( Operation *op ) */ metaconn_t * meta_back_getconn( - Operation *op, + Operation *op, SlapReply *rs, int *candidate, - ldap_back_send_t sendok ) + ldap_back_send_t sendok, + SlapReply *candidates ) { metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; metaconn_t *mc = NULL, @@ -1090,8 +1042,6 @@ meta_back_getconn( struct berval ndn = op->o_req_ndn, pndn; - SlapReply *candidates = meta_back_candidates_get( op ); - /* Internal searches are privileged and shared. So is root. */ if ( ( !BER_BVISEMPTY( &op->o_ndn ) && META_BACK_PROXYAUTHZ_ALWAYS( mi ) ) || ( BER_BVISEMPTY( &op->o_ndn ) && META_BACK_PROXYAUTHZ_ANON( mi ) ) @@ -1474,7 +1424,7 @@ retry_lock2:; /* * Clear all other candidates */ - ( void )meta_clear_unused_candidates( op, i ); + ( void )meta_clear_unused_candidates( op, i, candidates ); mt = mi->mi_targets[ i ]; msc = &mc->mc_conns[ i ]; -- cgit v1.2.3