Commit a215fdea authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

a bit more reworking and streamline; the change to the LAST_CONN test seems to...

a bit more reworking and streamline; the change to the LAST_CONN test seems to eliminate the last LDAP_BUSY problems on the only machine that was showing it yet; please test
parent 9c6aa3b8
......@@ -162,7 +162,6 @@ typedef struct metasingleconn_t {
int msc_candidate;
#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;
......@@ -175,8 +174,6 @@ typedef struct metasingleconn_t {
struct metainfo_t *msc_info;
} metasingleconn_t;
#define META_LAST(msc) ((msc)->msc_candidate == META_LAST_CONN)
typedef struct metaconn_t {
struct slap_conn *mc_conn;
ldap_pvt_thread_mutex_t mc_mutex;
......
......@@ -431,6 +431,9 @@ retry:;
}
break;
}
} else {
rc = slap_map_api2result( rs );
}
rs->sr_err = rc;
......@@ -453,13 +456,16 @@ meta_back_dobind(
{
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metasingleconn_t *msc;
int bound = 0, i;
SlapReply *candidates = meta_back_candidates_get( op );
ldap_pvt_thread_mutex_lock( &mc->mc_mutex );
Debug( LDAP_DEBUG_TRACE,
"%s meta_back_dobind: conn=%ld\n",
op->o_log_prefix, mc->mc_conn->c_connid, 0 );
/*
* all the targets are bound as pseudoroot
*/
......@@ -468,22 +474,29 @@ meta_back_dobind(
goto done;
}
for ( i = 0, msc = &mc->mc_conns[ 0 ]; !META_LAST( msc ); ++i, ++msc ) {
metatarget_t *mt = &mi->mi_targets[ i ];
int rc;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metatarget_t *mt = &mi->mi_targets[ i ];
metasingleconn_t *msc = &mc->mc_conns[ i ];
int rc;
/*
* Not a candidate or something wrong with this target ...
* Not a candidate
*/
if ( msc->msc_ld == NULL ) {
if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
continue;
}
assert( msc->msc_ld != NULL );
/*
* If the target is already bound it is skipped
*/
if ( msc->msc_bound == META_BOUND && mc->mc_auth_target == i ) {
++bound;
Debug( LDAP_DEBUG_TRACE, "%s meta_back_dobind[%d]: "
"authcTarget\n",
op->o_log_prefix, i, 0 );
continue;
}
......@@ -504,13 +517,13 @@ meta_back_dobind(
* so better clear the handle
*/
candidates[ i ].sr_tag = META_NOT_CANDIDATE;
#if 0
( void )meta_clear_one_candidate( msc );
#endif
continue;
} /* else */
candidates[ i ].sr_tag = META_CANDIDATE;
Debug( LDAP_DEBUG_TRACE, "%s meta_back_dobind[%d]: "
"(anonymous)\n",
op->o_log_prefix, i, 0 );
msc->msc_bound = META_ANONYMOUS;
++bound;
}
......@@ -518,7 +531,11 @@ meta_back_dobind(
done:;
ldap_pvt_thread_mutex_unlock( &mc->mc_mutex );
if ( bound == 0 && sendok & LDAP_BACK_SENDERR ) {
Debug( LDAP_DEBUG_TRACE,
"%s meta_back_dobind: conn=%ld bound=%d\n",
op->o_log_prefix, mc->mc_conn->c_connid, bound );
if ( bound == 0 && ( sendok & LDAP_BACK_SENDERR ) ) {
if ( rs->sr_err == LDAP_SUCCESS ) {
rs->sr_err = LDAP_BUSY;
}
......@@ -559,16 +576,17 @@ meta_back_op_result(
SlapReply *rs,
int candidate )
{
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
int i,
rerr = LDAP_SUCCESS;
metasingleconn_t *msc;
char *rmsg = NULL;
char *rmatch = NULL;
int free_rmsg = 0,
free_rmatch = 0;
if ( candidate != META_TARGET_NONE ) {
msc = &mc->mc_conns[ candidate ];
metasingleconn_t *msc = &mc->mc_conns[ candidate ];
rs->sr_err = LDAP_SUCCESS;
......@@ -602,9 +620,10 @@ meta_back_op_result(
}
} else {
for ( i = 0, msc = &mc->mc_conns[ 0 ]; !META_LAST( msc ); ++i, ++msc ) {
char *msg = NULL;
char *match = NULL;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metasingleconn_t *msc = &mc->mc_conns[ i ];
char *msg = NULL;
char *match = NULL;
rs->sr_err = LDAP_SUCCESS;
......
......@@ -36,7 +36,6 @@ meta_back_compare( Operation *op, SlapReply *rs )
{
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metaconn_t *mc;
metasingleconn_t *msc;
char *match = NULL,
*err = NULL;
struct berval mmatch = BER_BVNULL;
......@@ -69,10 +68,11 @@ meta_back_compare( Operation *op, SlapReply *rs )
dc.rs = rs;
dc.ctx = "compareDN";
for ( i = 0, msc = &mc->mc_conns[ 0 ]; !META_LAST( msc ); ++i, ++msc ) {
struct berval mdn = BER_BVNULL;
struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname;
struct berval mapped_value = op->orc_ava->aa_value;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metasingleconn_t *msc = &mc->mc_conns[ i ];
struct berval mdn = BER_BVNULL;
struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname;
struct berval mapped_value = op->orc_ava->aa_value;
if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
msgid[ i ] = -1;
......@@ -171,10 +171,11 @@ meta_back_compare( Operation *op, SlapReply *rs )
/*
* FIXME: should we check for abandon?
*/
for ( i = 0, msc = &mc->mc_conns[ 0 ]; !META_LAST( msc ); msc++, i++ ) {
int lrc;
LDAPMessage *res = NULL;
struct timeval tv = { 0 };
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metasingleconn_t *msc = &mc->mc_conns[ i ];
int lrc;
LDAPMessage *res = NULL;
struct timeval tv = { 0 };
tv.tv_sec = 0;
tv.tv_usec = 0;
......
......@@ -125,28 +125,25 @@ metaconn_alloc(
{
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metaconn_t *mc;
int ntargets = mi->mi_ntargets;
int i, ntargets = mi->mi_ntargets;
assert( ntargets > 0 );
/* malloc once only; leave an extra one for one-past-end */
mc = ( metaconn_t * )ch_malloc( sizeof( metaconn_t )
+ sizeof( metasingleconn_t ) * ( ntargets + 1 ) );
+ sizeof( metasingleconn_t ) * ntargets );
if ( mc == NULL ) {
return NULL;
}
mc->mc_conns = ( metasingleconn_t * )&mc[ 1 ];
/* FIXME: needed by META_LAST() */
mc->mc_conns[ ntargets ].msc_candidate = META_LAST_CONN;
for ( ; ntargets-- > 0; ) {
mc->mc_conns[ ntargets ].msc_ld = NULL;
BER_BVZERO( &mc->mc_conns[ ntargets ].msc_bound_ndn );
BER_BVZERO( &mc->mc_conns[ ntargets ].msc_cred );
mc->mc_conns[ ntargets ].msc_bound = META_UNBOUND;
mc->mc_conns[ ntargets ].msc_info = mi;
for ( i = 0; i < ntargets; i++ ) {
mc->mc_conns[ i ].msc_ld = NULL;
BER_BVZERO( &mc->mc_conns[ i ].msc_bound_ndn );
BER_BVZERO( &mc->mc_conns[ i ].msc_cred );
mc->mc_conns[ i ].msc_bound = META_UNBOUND;
mc->mc_conns[ i ].msc_info = mi;
}
mc->mc_auth_target = META_BOUND_NONE;
......@@ -595,7 +592,9 @@ meta_back_getconn(
int cached = META_TARGET_NONE,
i = META_TARGET_NONE,
err = LDAP_SUCCESS,
new_conn = 0;
new_conn = 0,
ncandidates = 0;
meta_op_type op_type = META_OP_REQUIRE_SINGLE;
int parent = 0,
......@@ -674,6 +673,7 @@ meta_back_getconn(
&mc->mc_conns[ i ], sendok );
if ( lerr == LDAP_SUCCESS ) {
candidates[ i ].sr_tag = META_CANDIDATE;
ncandidates++;
} else {
......@@ -735,7 +735,7 @@ meta_back_getconn(
return NULL;
}
Debug( LDAP_DEBUG_CACHE,
Debug( LDAP_DEBUG_TRACE,
"==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n",
i, op->o_req_ndn.bv_val, 0 );
......@@ -767,6 +767,7 @@ meta_back_getconn(
&mc->mc_conns[ i ], sendok );
if ( err == LDAP_SUCCESS ) {
candidates[ i ].sr_tag = META_CANDIDATE;
ncandidates++;
} else {
......@@ -792,8 +793,6 @@ meta_back_getconn(
*/
} else {
int ncandidates = 0;
/* Looks like we didn't get a bind. Open a new session... */
if ( !mc ) {
mc = metaconn_alloc( op );
......@@ -818,6 +817,9 @@ meta_back_getconn(
candidates[ i ].sr_tag = META_CANDIDATE;
ncandidates++;
Debug( LDAP_DEBUG_TRACE, "%s: meta_back_init_one_conn(%d)\n",
op->o_log_prefix, i, 0 );
} else {
/*
......@@ -887,13 +889,13 @@ done:;
*/
if ( err == 0 ) {
Debug( LDAP_DEBUG_TRACE,
"%s meta_back_getconn: conn %ld inserted\n",
op->o_log_prefix, mc->mc_conn->c_connid, 0 );
"%s meta_back_getconn: candidates=%d conn=%ld inserted\n",
op->o_log_prefix, ncandidates, mc->mc_conn->c_connid );
} else {
Debug( LDAP_DEBUG_TRACE,
"%s meta_back_getconn: conn %ld insert failed\n",
op->o_log_prefix, mc->mc_conn->c_connid, 0 );
Debug( LDAP_DEBUG_ANY,
"%s meta_back_getconn: candidates=%d conn=%ld insert failed\n",
op->o_log_prefix, ncandidates, mc->mc_conn->c_connid );
rs->sr_err = LDAP_OTHER;
rs->sr_text = "Internal server error";
......@@ -907,8 +909,8 @@ done:;
} else {
Debug( LDAP_DEBUG_TRACE,
"%s meta_back_getconn: conn %ld fetched\n",
op->o_log_prefix, mc->mc_conn->c_connid, 0 );
"%s meta_back_getconn: candidates=%d conn=%ld fetched\n",
op->o_log_prefix, ncandidates, mc->mc_conn->c_connid );
}
return mc;
......
......@@ -128,17 +128,24 @@ conn_free(
void *v_mc )
{
metaconn_t *mc = v_mc;
metasingleconn_t *msc;
int i, ntargets;
assert( mc->mc_conns != NULL );
for ( msc = &mc->mc_conns[ 0 ]; !META_LAST( msc ); msc++ ) {
/* at least one must be present... */
ntargets = mc->mc_conns[ 0 ].msc_info->mi_ntargets;
for ( i = 0; i < ntargets; i++ ) {
metasingleconn_t *msc = &mc->mc_conns[ i ];
if ( msc->msc_ld != NULL ) {
ldap_unbind_ext_s( msc->msc_ld, NULL, NULL );
}
if ( !BER_BVISNULL( &msc->msc_bound_ndn ) ) {
ber_memfree( msc->msc_bound_ndn.bv_val );
}
if ( !BER_BVISNULL( &msc->msc_cred ) ) {
/* destroy sensitive data */
memset( msc->msc_cred.bv_val, 0, msc->msc_cred.bv_len );
......
......@@ -220,7 +220,6 @@ meta_back_search( Operation *op, SlapReply *rs )
{
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metaconn_t *mc;
metasingleconn_t *msc;
struct timeval tv = { 0, 0 };
LDAPMessage *res = NULL, *e;
int rc = 0, sres = LDAP_SUCCESS;
......@@ -249,7 +248,9 @@ meta_back_search( Operation *op, SlapReply *rs )
/*
* Inits searches
*/
for ( i = 0, msc = &mc->mc_conns[ 0 ]; !META_LAST( msc ); ++i, ++msc ) {
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metasingleconn_t *msc = &mc->mc_conns[ i ];
candidates[ i ].sr_msgid = -1;
if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
......@@ -319,7 +320,9 @@ meta_back_search( Operation *op, SlapReply *rs )
for ( rc = 0; ncandidates > 0; ) {
int gotit = 0, doabandon = 0;
for ( i = 0, msc = &mc->mc_conns[ 0 ]; !META_LAST( msc ); msc++, i++ ) {
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metasingleconn_t *msc = &mc->mc_conns[ i ];
if ( candidates[ i ].sr_msgid == -1 ) {
continue;
}
......@@ -607,7 +610,9 @@ really_bad:;
/* check for abandon */
if ( op->o_abandon || doabandon ) {
for ( i = 0, msc = mc->mc_conns; !META_LAST( msc ); msc++, i++ ) {
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metasingleconn_t *msc = &mc->mc_conns[ i ];
if ( candidates[ i ].sr_msgid != -1 ) {
ldap_abandon_ext( msc->msc_ld,
candidates[ i ].sr_msgid,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment