From: Pierangelo Masarati Date: Thu, 21 Apr 2005 22:22:43 +0000 (+0000) Subject: fix previous commit X-Git-Tag: OPENLDAP_AC_BP~844 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=95d3db5d256169202d6d279043b793ff31ce25d9;p=openldap fix previous commit --- diff --git a/servers/slapd/back-meta/back-meta.h b/servers/slapd/back-meta/back-meta.h index 84dd36d743..3117cc4805 100644 --- a/servers/slapd/back-meta/back-meta.h +++ b/servers/slapd/back-meta/back-meta.h @@ -148,9 +148,9 @@ extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals ); struct metasingleconn { int msc_candidate; -#define META_NOT_CANDIDATE ((char)0) -#define META_CANDIDATE ((char)1) -#define META_LAST_CONN ((char)(-1)) +#define META_NOT_CANDIDATE ((ber_tag_t)0) +#define META_CANDIDATE ((ber_tag_t)1) +#define META_LAST_CONN ((ber_tag_t)(-1)) LDAP *msc_ld; struct berval msc_bound_ndn; @@ -206,7 +206,7 @@ struct metainfo { int mi_network_timeout; #define META_DEFAULT_TARGET_NONE (-1) struct metatarget **mi_targets; - char *mi_candidates; + SlapReply *mi_candidates; struct metadncache mi_cache; @@ -230,7 +230,7 @@ typedef enum meta_op_type { META_OP_REQUIRE_ALL } meta_op_type; -char * +SlapReply * meta_back_candidates_get( Operation *op ); extern struct metaconn * diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 1fc44d8f94..b18bde5d70 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -51,7 +51,7 @@ meta_back_bind( Operation *op, SlapReply *rs ) int rc = LDAP_OTHER, i, gotit = 0, isroot = 0; - char *candidates = meta_back_candidates_get( op ); + SlapReply *candidates = meta_back_candidates_get( op ); rs->sr_err = LDAP_SUCCESS; @@ -97,7 +97,7 @@ meta_back_bind( Operation *op, SlapReply *rs ) /* * Skip non-candidates */ - if ( candidates[ i ] != META_CANDIDATE ) { + if ( candidates[ i ].sr_tag != META_CANDIDATE ) { continue; } @@ -126,7 +126,7 @@ meta_back_bind( Operation *op, SlapReply *rs ) lerr = meta_back_single_bind( &op2, rs, mc, i ); if ( lerr != LDAP_SUCCESS ) { rs->sr_err = lerr; - candidates[ i ] = META_NOT_CANDIDATE; + candidates[ i ].sr_tag = META_NOT_CANDIDATE; } else { rc = LDAP_SUCCESS; @@ -362,7 +362,7 @@ meta_back_dobind( struct metaconn *mc, Operation *op, ldap_back_send_t sendok ) struct metasingleconn *msc; int bound = 0, i; - char *candidates = meta_back_candidates_get( op ); + SlapReply *candidates = meta_back_candidates_get( op ); ldap_pvt_thread_mutex_lock( &mc->mc_mutex ); @@ -405,14 +405,14 @@ meta_back_dobind( struct metaconn *mc, Operation *op, ldap_back_send_t sendok ) * due to technical reasons (remote host down?) * so better clear the handle */ - candidates[ i ] = META_NOT_CANDIDATE; + candidates[ i ].sr_tag = META_NOT_CANDIDATE; #if 0 ( void )meta_clear_one_candidate( msc ); #endif continue; } /* else */ - candidates[ i ] = META_CANDIDATE; + candidates[ i ].sr_tag = META_CANDIDATE; msc->msc_bound = META_ANONYMOUS; ++bound; } diff --git a/servers/slapd/back-meta/candidates.c b/servers/slapd/back-meta/candidates.c index 6e846ec172..2c2eb10285 100644 --- a/servers/slapd/back-meta/candidates.c +++ b/servers/slapd/back-meta/candidates.c @@ -147,13 +147,13 @@ meta_clear_unused_candidates( { struct metainfo *li = ( struct metainfo * )op->o_bd->be_private; int i; - char *candidates = meta_back_candidates_get( op ); + SlapReply *candidates = meta_back_candidates_get( op ); for ( i = 0; i < li->mi_ntargets; ++i ) { if ( i == candidate ) { continue; } - candidates[ i ] = META_NOT_CANDIDATE; + candidates[ i ].sr_tag = META_NOT_CANDIDATE; } return 0; diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index b2c584ba99..edc6d8d3bb 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -50,7 +50,7 @@ meta_back_compare( Operation *op, SlapReply *rs ) *msgid; dncookie dc; - char *candidates = meta_back_candidates_get( op ); + SlapReply *candidates = meta_back_candidates_get( op ); lc = meta_back_getconn( op, rs, NULL, LDAP_BACK_SENDERR ); if ( !lc || !meta_back_dobind( lc, op, LDAP_BACK_SENDERR ) ) { @@ -74,7 +74,7 @@ meta_back_compare( Operation *op, SlapReply *rs ) struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname; struct berval mapped_value = op->orc_ava->aa_value; - if ( candidates[ i ] != META_CANDIDATE ) { + if ( candidates[ i ].sr_tag != META_CANDIDATE ) { msgid[ i ] = -1; continue; } diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index eac32a6fba..650ab4b558 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -512,7 +512,7 @@ meta_back_candidate_keyfree( void *key, void *data ) ber_memfree_x( data, NULL ); } -char * +SlapReply * meta_back_candidates_get( Operation *op ) { struct metainfo *mi = ( struct metainfo * )op->o_bd->be_private; @@ -526,18 +526,18 @@ meta_back_candidates_get( Operation *op ) } if ( data == NULL ) { - data = ber_memalloc_x( sizeof( char ) * mi->mi_ntargets, NULL ); + data = ber_memalloc( sizeof( SlapReply ) * mi->mi_ntargets ); if ( op->o_threadctx ) { ldap_pvt_thread_pool_setkey( op->o_threadctx, meta_back_candidate_keyfree, data, meta_back_candidate_keyfree ); } else { - mi->mi_candidates = (char *)data; + mi->mi_candidates = (SlapReply *)data; } } - return (char *)data; + return (SlapReply *)data; } /* @@ -593,7 +593,7 @@ meta_back_getconn( struct berval ndn = op->o_req_ndn, pndn; - char *candidates = meta_back_candidates_get( op ); + SlapReply *candidates = meta_back_candidates_get( op ); /* Searches for a metaconn in the avl tree */ mc_curr.mc_conn = op->o_conn; @@ -663,7 +663,7 @@ meta_back_getconn( int lerr = meta_back_init_one_conn( op, rs, mi->mi_targets[ i ], &mc->mc_conns[ i ], sendok ); if ( lerr == LDAP_SUCCESS ) { - candidates[ i ] = META_CANDIDATE; + candidates[ i ].sr_tag = META_CANDIDATE; } else { @@ -672,7 +672,7 @@ meta_back_getconn( * be init'd, should the other ones * be tried? */ - candidates[ i ] = META_NOT_CANDIDATE; + candidates[ i ].sr_tag = META_NOT_CANDIDATE; err = lerr; continue; } @@ -688,8 +688,11 @@ meta_back_getconn( } if ( op_type == META_OP_REQUIRE_SINGLE ) { + int j; - memset( candidates, META_NOT_CANDIDATE, sizeof( char ) * mi->mi_ntargets ); + for ( j = 0; j < mi->mi_ntargets; j++ ) { + candidates[ j ].sr_tag = META_NOT_CANDIDATE; + } /* * tries to get a unique candidate @@ -753,7 +756,7 @@ meta_back_getconn( err = meta_back_init_one_conn( op, rs, mi->mi_targets[ i ], &mc->mc_conns[ i ], sendok ); if ( err == LDAP_SUCCESS ) { - candidates[ i ] = META_CANDIDATE; + candidates[ i ].sr_tag = META_CANDIDATE; } else { @@ -762,7 +765,7 @@ meta_back_getconn( * be init'd, should the other ones * be tried? */ - candidates[ i ] = META_NOT_CANDIDATE; + candidates[ i ].sr_tag = META_NOT_CANDIDATE; if ( new_conn ) { ( void )meta_clear_one_candidate( &mc->mc_conns[ i ] ); meta_back_conn_free( mc ); @@ -800,7 +803,7 @@ meta_back_getconn( mi->mi_targets[ i ], &mc->mc_conns[ i ], sendok ); if ( lerr == LDAP_SUCCESS ) { - candidates[ i ] = META_CANDIDATE; + candidates[ i ].sr_tag = META_CANDIDATE; } else { @@ -809,7 +812,7 @@ meta_back_getconn( * be init'd, should the other ones * be tried? */ - candidates[ i ] = META_NOT_CANDIDATE; + candidates[ i ].sr_tag = META_NOT_CANDIDATE; err = lerr; Debug( LDAP_DEBUG_ANY, "%s: meta_back_init_one_conn(%d) failed: %d\n", @@ -819,7 +822,7 @@ meta_back_getconn( } } else { - candidates[ i ] = META_NOT_CANDIDATE; + candidates[ i ].sr_tag = META_NOT_CANDIDATE; } } } diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index d88b1efc74..1a72af7d37 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -227,7 +227,7 @@ meta_back_search( Operation *op, SlapReply *rs ) struct metasingleconn *msc; struct timeval tv = { 0, 0 }; LDAPMessage *res = NULL, *e; - int rc = 0, *msgid, sres = LDAP_SUCCESS; + int rc = 0, sres = LDAP_SUCCESS; char *err = NULL; struct berval match = BER_BVNULL, mmatch = BER_BVNULL; BerVarray v2refs = NULL; @@ -240,7 +240,7 @@ meta_back_search( Operation *op, SlapReply *rs ) void *savepriv; - char *candidates = meta_back_candidates_get( op ); + SlapReply *candidates = meta_back_candidates_get( op ); /* * controls are set in ldap_back_dobind() @@ -253,16 +253,6 @@ meta_back_search( Operation *op, SlapReply *rs ) return rs->sr_err; } - /* - * Array of message id of each target - */ - msgid = ch_calloc( sizeof( int ), mi->mi_ntargets ); - if ( msgid == NULL ) { - rs->sr_err = LDAP_OTHER; - send_ldap_result( op, rs ); - return -1; - } - dc.conn = op->o_conn; dc.rs = rs; @@ -270,13 +260,13 @@ meta_back_search( Operation *op, SlapReply *rs ) * Inits searches */ for ( i = 0, msc = &lc->mc_conns[ 0 ]; !META_LAST( msc ); ++i, ++msc ) { - msgid[ i ] = -1; + candidates[ i ].sr_msgid = -1; - if ( candidates[ i ] != META_CANDIDATE ) { + if ( candidates[ i ].sr_tag != META_CANDIDATE ) { continue; } - switch ( meta_back_search_start( op, rs, &dc, msc, i, &msgid[ i ] ) ) + switch ( meta_back_search_start( op, rs, &dc, msc, i, &candidates[ i ].sr_msgid ) ) { case 0: break; @@ -299,7 +289,7 @@ meta_back_search( Operation *op, SlapReply *rs ) int i; for ( i = 0; i < mi->mi_ntargets; i++ ) { - if ( candidates[ i ] == META_CANDIDATE ) { + if ( candidates[ i ].sr_tag == META_CANDIDATE ) { cnd[ i ] = '*'; } else { cnd[ i ] = ' '; @@ -335,7 +325,7 @@ meta_back_search( Operation *op, SlapReply *rs ) int gotit = 0; for ( i = 0, msc = &lc->mc_conns[ 0 ]; !META_LAST( msc ); msc++, i++ ) { - if ( msgid[ i ] == -1 ) { + if ( candidates[ i ].sr_msgid == -1 ) { continue; } @@ -363,7 +353,7 @@ meta_back_search( Operation *op, SlapReply *rs ) * get a LDAP_TIMELIMIT_EXCEEDED from * one of them ... */ - rc = ldap_result( msc->msc_ld, msgid[ i ], + rc = ldap_result( msc->msc_ld, candidates[ i ].sr_msgid, 0, &tv, &res ); if ( rc == 0 ) { @@ -377,8 +367,7 @@ meta_back_search( Operation *op, SlapReply *rs ) } else if ( rc == -1 ) { really_bad:; /* something REALLY bad happened! */ - ( void )meta_clear_unused_candidates( op, - lc, -1 ); + ( void )meta_clear_unused_candidates( op, lc, -1 ); rs->sr_err = LDAP_OTHER; rs->sr_v2ref = v2refs; savepriv = op->o_private; @@ -540,7 +529,7 @@ really_bad:; * When no candidates are left, * the outer cycle finishes */ - msgid[ i ] = -1; + candidates[ i ].sr_msgid = -1; --ncandidates; } else { @@ -552,7 +541,7 @@ really_bad:; /* check for abandon */ if ( op->o_abandon ) { for ( i = 0, msc = lc->mc_conns; !META_LAST( msc ); msc++, i++ ) { - ldap_abandon_ext( msc->msc_ld, msgid[ i ], NULL, NULL ); + ldap_abandon_ext( msc->msc_ld, candidates[ i ].sr_msgid, NULL, NULL ); } rc = SLAPD_ABANDON; @@ -609,7 +598,7 @@ really_bad:; int i; for ( i = 0; i < mi->mi_ntargets; i++ ) { - if ( candidates[ i ] == META_CANDIDATE ) { + if ( candidates[ i ].sr_tag == META_CANDIDATE ) { cnd[ i ] = '*'; } else { cnd[ i ] = ' '; @@ -651,10 +640,6 @@ finish:; free( err ); } - if ( msgid ) { - ch_free( msgid ); - } - return rc; }