typedef struct metasingleconn_t {
int msc_candidate;
-#define META_NOT_CANDIDATE ((ber_tag_t)0)
-#define META_CANDIDATE ((ber_tag_t)1)
+#define META_NOT_CANDIDATE ((ber_tag_t)0x0)
+#define META_CANDIDATE ((ber_tag_t)0x1)
+#define META_BINDING ((ber_tag_t)0x2)
+
+#define META_CND_ISSET(rs,f) ( ( (rs)->sr_tag & (f) ) == (f) )
+#define META_CND_SET(rs,f) ( (rs)->sr_tag |= (f) )
+#define META_CND_CLEAR(rs,f) ( (rs)->sr_tag &= ~(f) )
+
+#define META_CANDIDATE_RESET(rs) ( (rs)->sr_tag = 0 )
+#define META_IS_CANDIDATE(rs) META_CND_ISSET( (rs), META_CANDIDATE )
+#define META_CANDIDATE_SET(rs) META_CND_SET( (rs), META_CANDIDATE )
+#define META_CANDIDATE_CLEAR(rs) META_CND_CLEAR( (rs), META_CANDIDATE )
+#define META_IS_BINDING(rs) META_CND_ISSET( (rs), META_BINDING )
+#define META_BINDING_SET(rs) META_CND_SET( (rs), META_BINDING )
+#define META_BINDING_CLEAR(rs) META_CND_CLEAR( (rs), META_BINDING )
LDAP *msc_ld;
struct berval msc_bound_ndn;
/*
* Skip non-candidates
*/
- if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
+ if ( !META_IS_CANDIDATE( &candidates[ i ] ) ) {
continue;
}
* do not assume it's not candidate; rather
* mark this as an error to be eventually
* reported to client */
- candidates[ i ].sr_tag = META_NOT_CANDIDATE;
+ META_CANDIDATE_CLEAR( &candidates[ i ] );
break;
}
}
/*
* Not a candidate
*/
- if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
+ if ( !META_IS_CANDIDATE( &candidates[ i ] ) ) {
continue;
}
if ( i == candidate ) {
continue;
}
- candidates[ i ].sr_tag = META_NOT_CANDIDATE;
+ META_CANDIDATE_RESET( &candidates[ i ] );
}
return 0;
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 ) {
+ if ( ! META_IS_CANDIDATE( &candidates[ i ] ) ) {
msgid[ i ] = -1;
continue;
}
rs, mc, i, LDAP_BACK_CONN_ISPRIV( &mc_curr ),
sendok );
if ( candidates[ i ].sr_err == LDAP_SUCCESS ) {
- candidates[ i ].sr_tag = META_CANDIDATE;
+ META_CANDIDATE_SET( &candidates[ i ] );
ncandidates++;
} else {
* be init'd, should the other ones
* be tried?
*/
- candidates[ i ].sr_tag = META_NOT_CANDIDATE;
+ META_CANDIDATE_RESET( &candidates[ i ] );
err = candidates[ i ].sr_err;
continue;
}
int j;
for ( j = 0; j < mi->mi_ntargets; j++ ) {
- candidates[ j ].sr_tag = META_NOT_CANDIDATE;
+ META_CANDIDATE_RESET( &candidates[ j ] );
}
/*
* be init'd, should the other ones
* be tried?
*/
- candidates[ i ].sr_tag = META_NOT_CANDIDATE;
+ META_CANDIDATE_RESET( &candidates[ i ] );
if ( new_conn ) {
(void)meta_clear_one_candidate( msc );
meta_back_freeconn( op, mc );
}
candidates[ i ].sr_err = LDAP_SUCCESS;
- candidates[ i ].sr_tag = META_CANDIDATE;
+ META_CANDIDATE_SET( &candidates[ i ] );
ncandidates++;
if ( candidate ) {
int lerr = meta_back_init_one_conn( op, rs, mc, i,
LDAP_BACK_CONN_ISPRIV( &mc_curr ), LDAP_BACK_DONTSEND );
if ( lerr == LDAP_SUCCESS ) {
- candidates[ i ].sr_tag = META_CANDIDATE;
+ META_CANDIDATE_SET( &candidates[ i ] );
candidates[ i ].sr_err = LDAP_SUCCESS;
ncandidates++;
if ( new_conn ) {
( void )meta_clear_one_candidate( msc );
}
- candidates[ i ].sr_tag = META_NOT_CANDIDATE;
+ META_CANDIDATE_RESET( &candidates[ i ] );
}
}
NULL, NULL, &candidates[ candidate ].sr_msgid );
switch ( rc ) {
case LDAP_SUCCESS:
+ META_BINDING_SET( &candidates[ candidate ] );
return META_SEARCH_BINDING;
case LDAP_SERVER_DOWN:
}
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
+ META_BINDING_CLEAR( &candidates[ candidate ] );
+
return retcode;
}
for ( i = 0; i < mi->mi_ntargets; i++ ) {
candidates[ i ].sr_msgid = META_MSGID_IGNORE;
- if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
+ if ( !META_IS_CANDIDATE( &candidates[ i ] ) ) {
continue;
}
}
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ].sr_tag != META_CANDIDATE
+ if ( !META_IS_CANDIDATE( &candidates[ i ] )
|| candidates[ i ].sr_err != LDAP_SUCCESS )
{
continue;
int i;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ].sr_tag == META_CANDIDATE ) {
+ if ( META_IS_CANDIDATE( &candidates[ i ] ) ) {
cnd[ i ] = '*';
} else {
cnd[ i ] = ' ';
* maybe we should pick the worst... */
rc = LDAP_NO_SUCH_OBJECT;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ].sr_tag == META_CANDIDATE
+ if ( META_IS_CANDIDATE( &candidates[ i ] )
&& candidates[ i ].sr_err != LDAP_SUCCESS )
{
rc = candidates[ i ].sr_err;
/* we use the first one */
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ].sr_tag == META_CANDIDATE
+ if ( META_IS_CANDIDATE( &candidates[ i ] )
&& candidates[ i ].sr_matched != NULL )
{
struct berval bv, pbv;
int i;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ].sr_tag == META_CANDIDATE ) {
+ if ( META_IS_CANDIDATE( &candidates[ i ] ) ) {
cnd[ i ] = '*';
} else {
cnd[ i ] = ' ';
}
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
+ if ( !META_IS_CANDIDATE( &candidates[ i ] ) ) {
continue;
}
- if ( mc && candidates[ i ].sr_msgid >= 0 ) {
+ if ( mc && META_IS_BINDING( &candidates[ i ] ) ) {
ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
if ( LDAP_BACK_CONN_BINDING( &mc->mc_conns[ i ] ) ) {
LDAP_BACK_CONN_BINDING_CLEAR( &mc->mc_conns[ i ] );
}
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
+ META_BINDING_CLEAR( &candidates[ i ] );
}
if ( candidates[ i ].sr_matched ) {