first round of provisions for back-config

This commit is contained in:
Pierangelo Masarati 2005-06-19 22:41:12 +00:00
parent f86daac8c8
commit b836fc3ea2
5 changed files with 46 additions and 20 deletions

View File

@ -222,6 +222,11 @@ typedef struct metadncache_t {
long int ttl; /* seconds; 0: no cache, -1: no expiry */
} metadncache_t;
typedef struct metacandidates_t {
int mc_ntargets;
SlapReply *mc_candidates;
} metacandidates_t;
typedef struct metainfo_t {
int mi_ntargets;
int mi_defaulttarget;
@ -230,7 +235,7 @@ typedef struct metainfo_t {
int mi_nretries;
metatarget_t *mi_targets;
SlapReply *mi_candidates;
metacandidates_t *mi_candidates;
metadncache_t mi_cache;

View File

@ -129,7 +129,7 @@ metaconn_alloc(
assert( ntargets > 0 );
/* malloc once only; leave an extra one for one-past-end */
/* malloc all in one */
mc = ( metaconn_t * )ch_malloc( sizeof( metaconn_t )
+ sizeof( metasingleconn_t ) * ntargets );
if ( mc == NULL ) {
@ -512,39 +512,59 @@ meta_back_get_candidate(
}
static void
meta_back_candidate_keyfree(
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;
void *data = NULL;
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metacandidates_t *mc;
SlapReply *rs;
if ( op->o_threadctx ) {
void *data = NULL;
ldap_pvt_thread_pool_getkey( op->o_threadctx,
meta_back_candidate_keyfree, &data, NULL );
meta_back_candidates_keyfree, &data, NULL );
mc = (metacandidates_t *)data;
} else {
data = (void *)mi->mi_candidates;
mc = mi->mi_candidates;
}
if ( data == NULL ) {
data = ch_calloc( sizeof( SlapReply ), mi->mi_ntargets );
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_candidate_keyfree, data,
meta_back_candidate_keyfree );
meta_back_candidates_keyfree, data,
meta_back_candidates_keyfree );
} else {
mi->mi_candidates = (SlapReply *)data;
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_ntargets = mi->mi_ntargets;
mc->mc_candidates = ch_realloc( mc->mc_candidates,
sizeof( SlapReply ) * mc->mc_ntargets );
}
return (SlapReply *)data;
return mc->mc_candidates;
}
/*

View File

@ -108,7 +108,8 @@ meta_back_db_open(
int i, rc;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
if ( mi->mi_targets[ i ].mt_flags & LDAP_BACK_F_SUPPORT_T_F_DISCOVER ) {
if ( mi->mi_targets[ i ].mt_flags & LDAP_BACK_F_SUPPORT_T_F_DISCOVER )
{
mi->mi_targets[ i ].mt_flags &= ~LDAP_BACK_F_SUPPORT_T_F_DISCOVER;
rc = slap_discover_feature( mi->mi_targets[ i ].mt_uri,
mi->mi_targets[ i ].mt_version,

View File

@ -267,6 +267,7 @@ meta_back_search( Operation *op, SlapReply *rs )
if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
continue;
}
candidates[ i ].sr_err = LDAP_SUCCESS;
candidates[ i ].sr_matched = NULL;
candidates[ i ].sr_text = NULL;

View File

@ -38,7 +38,7 @@ meta_back_conn_destroy(
Connection *conn )
{
metainfo_t *mi = ( metainfo_t * )be->be_private;
metaconn_t *mc,
metaconn_t *mc,
mc_curr = { 0 };
Debug( LDAP_DEBUG_TRACE,
@ -63,12 +63,11 @@ meta_back_conn_destroy(
* Cleanup rewrite session
*/
for ( i = 0; i < mi->mi_ntargets; ++i ) {
if ( mc->mc_conns[ i ].msc_ld == NULL ) {
continue;
}
rewrite_session_delete( mi->mi_targets[ i ].mt_rwmap.rwm_rw, conn );
meta_clear_one_candidate( &mc->mc_conns[ i ] );
if ( mc->mc_conns[ i ].msc_ld != NULL ) {
meta_clear_one_candidate( &mc->mc_conns[ i ] );
}
}
meta_back_conn_free( mc );
}