/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2001-2009 The OpenLDAP Foundation.
+ * Copyright 2001-2014 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
{
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
BackendDB *b0 = op->o_bd;
- BackendInfo *bi0 = op->o_bd->bd_info;
- BI_op_modify **func;
+ BackendInfo *bi0 = op->o_bd->bd_info, *bi1;
slap_operation_t which = op_bind;
int rc;
default: assert( 0 ); break;
}
- func = &op->o_bd->bd_info->bi_op_bind;
- if ( func[which] )
- rc = func[which]( op, rs );
- else
- rc = SLAP_CB_BYPASS;
+ bi1 = op->o_bd->bd_info;
+ rc = (&bi1->bi_op_bind)[ which ] ?
+ (&bi1->bi_op_bind)[ which ]( op, rs ) : SLAP_CB_BYPASS;
op->o_bd = b0;
op->o_bd->bd_info = bi0;
return rc;
}
+static int
+glue_op_abandon( Operation *op, SlapReply *rs )
+{
+ slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
+ glueinfo *gi = (glueinfo *)on->on_bi.bi_private;
+ BackendDB *b0 = op->o_bd;
+ BackendInfo *bi0 = op->o_bd->bd_info;
+ int i;
+
+ b0->bd_info = on->on_info->oi_orig;
+
+ for (i = gi->gi_nodes-1; i >= 0; i--) {
+ assert( gi->gi_n[i].gn_be->be_nsuffix != NULL );
+ op->o_bd = gi->gi_n[i].gn_be;
+ if ( op->o_bd == b0 )
+ continue;
+ if ( op->o_bd->bd_info->bi_op_abandon )
+ op->o_bd->bd_info->bi_op_abandon( op, rs );
+ }
+ op->o_bd = b0;
+ op->o_bd->bd_info = bi0;
+ return SLAP_CB_CONTINUE;
+}
+
static int
glue_response ( Operation *op, SlapReply *rs )
{
if ( op->o_bd == b0 )
return SLAP_CB_CONTINUE;
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
if (op->o_bd && op->o_bd->be_search) {
rs->sr_err = op->o_bd->be_search( op, rs );
+ } else {
+ rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
}
return rs->sr_err;
* from here on a subsequent request.
*/
if ( rs->sr_nentries >= ps->ps_size ) {
+ PagedResultsState *cps = &op->o_conn->c_pagedresults_state;
+
/* Don't bother to remember the first backend.
* Only remember the last one if there's more state left.
*/
if ( op->o_bd != b0 &&
- ( !BER_BVISNULL( &op->o_conn->c_pagedresults_state.ps_cookieval ) ||
- op->o_bd != gi->gi_n[0].gn_be ))
+ ( cps->ps_cookie != NOID
+ || !BER_BVISNULL( &cps->ps_cookieval )
+ || op->o_bd != gi->gi_n[0].gn_be ) )
{
op->o_conn->c_pagedresults_state.ps_be = op->o_bd;
}
/* Check whether the cookie is empty,
* and give remaining databases a chance
*/
- if ( op->o_bd != gi->gi_n[0].gn_be ||
- BER_BVISNULL( &op->o_conn->c_pagedresults_state.ps_cookieval ) )
- {
+ if ( op->o_bd != gi->gi_n[0].gn_be || cps->ps_cookie == NOID ) {
int c;
for ( c = 0; gs.ctrls[c] != NULL; c++ ) {
tag = ber_scanf( ber, "{im}", &size, &cookie );
assert( tag != LBER_ERROR );
- if ( BER_BVISEMPTY( &cookie ) ) {
+ if ( BER_BVISEMPTY( &cookie ) && op->o_bd != gi->gi_n[0].gn_be ) {
/* delete old, create new cookie with NOID */
PagedResultsCookie respcookie = (PagedResultsCookie)NOID;
ber_len_t oidlen = strlen( gs.ctrls[c]->ldctl_oid );
LDAPControl *newctrl;
+ /* it's next database's turn */
if ( btmp == b0 ) {
op->o_conn->c_pagedresults_state.ps_be = gi->gi_n[gi->gi_nodes - 1].gn_be;
ber_free_buf( ber );
- } else {
+ } else if ( !BER_BVISEMPTY( &cookie ) && op->o_bd != b0 ) {
+ /* if cookie not empty, it's again this database's turn */
op->o_conn->c_pagedresults_state.ps_be = op->o_bd;
}
}
* next backend will start up properly. Only back-[bh]db
* and back-sql look at this state info.
*/
- if ( ps->ps_cookieval.bv_len == sizeof( PagedResultsCookie )) {
- ps->ps_cookie = (PagedResultsCookie)0;
-#if 0
- memset( ps->ps_cookieval.bv_val, 0,
- sizeof( PagedResultsCookie ));
-#endif
- BER_BVZERO( &ps->ps_cookieval );
- }
+ ps->ps_cookie = (PagedResultsCookie)0;
+ BER_BVZERO( &ps->ps_cookieval );
{
/* change the size of the page in the request
glue.on_bi.bi_op_modrdn = glue_op_func;
glue.on_bi.bi_op_add = glue_op_func;
glue.on_bi.bi_op_delete = glue_op_func;
+ glue.on_bi.bi_op_abandon = glue_op_abandon;
glue.on_bi.bi_extended = glue_op_func;
glue.on_bi.bi_chk_referrals = glue_chk_referrals;