From: Pierangelo Masarati Date: Wed, 16 May 2007 01:39:41 +0000 (+0000) Subject: further cleanup round in back-relay database selection; cleanup X-Git-Tag: OPENLDAP_REL_ENG_2_4_MP~475 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dd3f101ff81dfed09ec2dfaeb67a083691ab1eb9;p=openldap further cleanup round in back-relay database selection; cleanup --- diff --git a/servers/slapd/back-relay/op.c b/servers/slapd/back-relay/op.c index 2a539285dc..2a6d669a73 100644 --- a/servers/slapd/back-relay/op.c +++ b/servers/slapd/back-relay/op.c @@ -123,7 +123,7 @@ relay_back_op_bind( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_bind )( op, rs ); + rc = bd->be_bind( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -157,7 +157,7 @@ relay_back_op_unbind( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_unbind )( op, rs ); + rc = bd->be_unbind( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -187,7 +187,7 @@ relay_back_op_search( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_search )( op, rs ); + rc = bd->be_search( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -222,7 +222,7 @@ relay_back_op_compare( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_compare )( op, rs ); + rc = bd->be_compare( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -257,7 +257,7 @@ relay_back_op_modify( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_modify )( op, rs ); + rc = bd->be_modify( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -292,7 +292,7 @@ relay_back_op_modrdn( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_modrdn )( op, rs ); + rc = bd->be_modrdn( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -327,7 +327,7 @@ relay_back_op_add( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_add )( op, rs ); + rc = bd->be_add( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -362,7 +362,7 @@ relay_back_op_delete( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_delete )( op, rs ); + rc = bd->be_delete( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -392,7 +392,7 @@ relay_back_op_abandon( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_abandon )( op, rs ); + rc = bd->be_abandon( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -422,7 +422,7 @@ relay_back_op_cancel( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_cancel )( op, rs ); + rc = bd->be_cancel( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -457,7 +457,7 @@ relay_back_op_extended( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_extended )( op, rs ); + rc = bd->be_extended( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -493,7 +493,7 @@ relay_back_entry_release_rw( Operation *op, Entry *e, int rw ) BackendDB *be = op->o_bd; op->o_bd = bd; - rc = ( bd->be_release )( op, e, rw ); + rc = bd->be_release( op, e, rw ); op->o_bd = be; } @@ -521,7 +521,7 @@ relay_back_entry_get_rw( Operation *op, struct berval *ndn, BackendDB *be = op->o_bd; op->o_bd = bd; - rc = ( bd->be_fetch )( op, ndn, oc, at, rw, e ); + rc = bd->be_fetch( op, ndn, oc, at, rw, e ); op->o_bd = be; } @@ -566,7 +566,7 @@ relay_back_chk_referrals( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_chk_referrals )( op, rs ); + rc = bd->be_chk_referrals( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -581,16 +581,15 @@ relay_back_chk_referrals( Operation *op, SlapReply *rs ) int relay_back_operational( Operation *op, SlapReply *rs ) { - relay_back_info *ri = (relay_back_info *)op->o_bd->be_private; BackendDB *bd; int rc = 1; - bd = ri->ri_bd; - if ( bd == NULL) { - bd = select_backend( &op->o_req_ndn, 0, 1 ); - if ( bd == NULL ) { - return 1; - } + bd = relay_back_select_backend( op, rs, LDAP_SUCCESS, 0 ); + /* FIXME: this test only works if there are no overlays, so + * it is nearly useless; if made stricter, no nested back-relays + * can be instantiated... too bad. */ + if ( bd == NULL || bd == op->o_bd ) { + return 0; } if ( bd->be_operational ) { @@ -600,7 +599,7 @@ relay_back_operational( Operation *op, SlapReply *rs ) relay_back_add_cb( &cb, op ); op->o_bd = bd; - rc = ( bd->be_operational )( op, rs ); + rc = bd->be_operational( op, rs ); op->o_bd = be; if ( op->o_callback == &cb ) { @@ -615,23 +614,23 @@ relay_back_operational( Operation *op, SlapReply *rs ) int relay_back_has_subordinates( Operation *op, Entry *e, int *hasSubs ) { - relay_back_info *ri = (relay_back_info *)op->o_bd->be_private; + SlapReply rs = { 0 }; BackendDB *bd; int rc = 1; - bd = ri->ri_bd; - if ( bd == NULL) { - bd = select_backend( &op->o_req_ndn, 0, 1 ); - if ( bd == NULL ) { - return 1; - } + bd = relay_back_select_backend( op, &rs, LDAP_SUCCESS, 0 ); + /* FIXME: this test only works if there are no overlays, so + * it is nearly useless; if made stricter, no nested back-relays + * can be instantiated... too bad. */ + if ( bd == NULL || bd == op->o_bd ) { + return 0; } if ( bd->be_has_subordinates ) { BackendDB *be = op->o_bd; op->o_bd = bd; - rc = ( bd->be_has_subordinates )( op, e, hasSubs ); + rc = bd->be_has_subordinates( op, e, hasSubs ); op->o_bd = be; } @@ -650,7 +649,7 @@ relay_back_connection_init( BackendDB *bd, Connection *c ) } if ( bd->be_connection_init ) { - return ( bd->be_connection_init )( bd, c ); + return bd->be_connection_init( bd, c ); } return 0; @@ -662,12 +661,12 @@ relay_back_connection_destroy( BackendDB *bd, Connection *c ) relay_back_info *ri = (relay_back_info *)bd->be_private; bd = ri->ri_bd; - if ( bd == NULL) { + if ( bd == NULL ) { return 0; } if ( bd->be_connection_destroy ) { - return ( bd->be_connection_destroy )( bd, c ); + return bd->be_connection_destroy( bd, c ); } return 0;