X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbackglue.c;h=cce5905ee1b827595b6ea2bd2a8037e8765a0804;hb=fb2d3926ce4714b83f76c059a18a0d67d12b8019;hp=d60542d12fcaa95ead9178824c1978842ed30827;hpb=0ad714d61e1828c90e9f0fa7e3233111fdb79b5c;p=openldap diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index d60542d12f..cce5905ee1 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -65,7 +65,7 @@ glue_back_select ( glueinfo *gi = (glueinfo *)on->on_bi.bi_private; int i; - for (i = 0; igi_nodes; i++) { + for (i = gi->gi_nodes-1; i >= 0; i--) { assert( gi->gi_n[i].gn_be->be_nsuffix != NULL ); if (dnIsSuffix(dn, &gi->gi_n[i].gn_be->be_nsuffix[0])) { @@ -262,6 +262,13 @@ glue_chk_controls ( Operation *op, SlapReply *rs ) return rc; } +/* ITS#4615 - overlays configured above the glue overlay should be + * invoked for the entire glued tree. Overlays configured below the + * glue overlay should only be invoked on the master backend. + * So, if we're searching on any subordinates, we need to force the + * current overlay chain to stop processing, without stopping the + * overall callback flow. + */ static int glue_sub_search( Operation *op, SlapReply *rs, BackendDB *b0, slap_overinst *on ) @@ -269,12 +276,14 @@ glue_sub_search( Operation *op, SlapReply *rs, BackendDB *b0, /* Process any overlays on the master backend */ if ( op->o_bd == b0 && on->on_next ) { BackendInfo *bi = op->o_bd->bd_info; - int rc; + int rc = SLAP_CB_CONTINUE; for ( on=on->on_next; on; on=on->on_next ) { op->o_bd->bd_info = (BackendInfo *)on; - rc = on->on_bi.bi_op_search( op, rs ); - if ( rc != SLAP_CB_CONTINUE ) - break; + if ( on->on_bi.bi_op_search ) { + rc = on->on_bi.bi_op_search( op, rs ); + if ( rc != SLAP_CB_CONTINUE ) + break; + } } op->o_bd->bd_info = bi; if ( rc != SLAP_CB_CONTINUE ) @@ -292,7 +301,7 @@ glue_op_search ( Operation *op, SlapReply *rs ) BackendDB *b1 = NULL, *btmp; BackendInfo *bi0 = op->o_bd->bd_info; int i; - long stoptime = 0; + long stoptime = 0, starttime; glue_state gs = {NULL, NULL, NULL, 0, 0, 0, 0}; slap_callback cb = { NULL, glue_op_response, NULL, NULL }; int scope0, tlimit0; @@ -302,6 +311,7 @@ glue_op_search ( Operation *op, SlapReply *rs ) cb.sc_next = op->o_callback; + starttime = op->o_time; stoptime = slap_get_time () + op->ors_tlimit; op->o_bd = glue_back_select (b0, &op->o_req_ndn); @@ -330,7 +340,7 @@ glue_op_search ( Operation *op, SlapReply *rs ) b1 = op->o_bd; /* - * Execute in reverse order, most general first + * Execute in reverse order, most specific first */ for (i = gi->gi_nodes; i >= 0; i--) { if ( i == gi->gi_nodes ) { @@ -344,8 +354,12 @@ glue_op_search ( Operation *op, SlapReply *rs ) continue; if (!dnIsSuffix(&btmp->be_nsuffix[0], &b1->be_nsuffix[0])) continue; + if (get_no_subordinate_glue(op) && btmp != b1) + continue; + if (tlimit0 != SLAP_NO_LIMIT) { - op->ors_tlimit = stoptime - slap_get_time (); + op->o_time = slap_get_time(); + op->ors_tlimit = stoptime - op->o_time; if (op->ors_tlimit <= 0) { rs->sr_err = gs.err = LDAP_TIMELIMIT_EXCEEDED; break; @@ -373,6 +387,9 @@ glue_op_search ( Operation *op, SlapReply *rs ) if ( rs->sr_err == LDAP_NO_SUCH_OBJECT ) { gs.err = LDAP_SUCCESS; } + op->ors_scope = LDAP_SCOPE_ONELEVEL; + op->o_req_dn = dn; + op->o_req_ndn = ndn; } else if (scope0 == LDAP_SCOPE_SUBTREE && dn_match(&op->o_bd->be_nsuffix[0], &ndn)) @@ -417,6 +434,7 @@ glue_op_search ( Operation *op, SlapReply *rs ) end_of_loop:; op->ors_scope = scope0; op->ors_tlimit = tlimit0; + op->o_time = starttime; op->o_req_dn = dn; op->o_req_ndn = ndn; @@ -441,7 +459,7 @@ end_of_loop:; if (gs.refs) ber_bvarray_free(gs.refs); if (gs.ctrls) { - for (gs.nctrls-1; i>=0; i--) { + for (i = gs.nctrls; --i >= 0; ) { if (!BER_BVISNULL( &gs.ctrls[i]->ldctl_value )) free(gs.ctrls[i]->ldctl_value.bv_val); free(gs.ctrls[i]); @@ -764,6 +782,13 @@ glue_db_init( BackendInfo *bi = oi->oi_orig; glueinfo *gi; + if ( SLAP_GLUE_SUBORDINATE( be )) { + Debug( LDAP_DEBUG_ANY, "glue: backend %s is already subordinate, " + "cannot have glue overlay!\n", + be->be_suffix[0].bv_val, 0, 0 ); + return LDAP_OTHER; + } + gi = ch_calloc( 1, sizeof(glueinfo)); on->on_bi.bi_private = gi; dnParent( be->be_nsuffix, &gi->gi_pdn ); @@ -949,6 +974,12 @@ glue_sub_add( BackendDB *be, int advert, int online ) glue_Addrec *ga; int rc = 0; + if ( overlay_is_inst( be, "glue" )) { + Debug( LDAP_DEBUG_ANY, "glue: backend %s already has glue overlay, " + "cannot be a subordinate!\n", + be->be_suffix[0].bv_val, 0, 0 ); + return LDAP_OTHER; + } SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_SUBORDINATE; if ( advert ) SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLUE_ADVERTISE;