/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2003-2014 The OpenLDAP Foundation.
+ * Copyright 2003-2017 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
}
if ( rc == SLAP_CB_BYPASS )
rc = SLAP_CB_CONTINUE;
+ /* if an overlay halted processing, make sure
+ * any previously set cleanup handlers are run
+ */
+ if ( rc != SLAP_CB_CONTINUE )
+ goto cleanup;
bi = oi->oi_orig;
- if ( (&bi->bi_op_bind)[ which ] && rc == SLAP_CB_CONTINUE ) {
+ if ( (&bi->bi_op_bind)[ which ] ) {
op->o_bd->bd_info = bi;
rc = (&bi->bi_op_bind)[ which ]( op, rs );
}
*/
if ( rc == LDAP_UNWILLING_TO_PERFORM ) {
slap_callback *sc_next;
+cleanup:
for ( ; op->o_callback && op->o_callback->sc_response !=
over_back_response; op->o_callback = sc_next ) {
sc_next = op->o_callback->sc_next;
slap_overinfo *oi;
slap_overinst *on;
BackendDB *be = op->o_bd, db;
- slap_callback cb = {NULL, over_back_response, NULL, NULL}, **sc;
+ slap_callback **sc;
+ slap_callback *cb = (slap_callback *) ch_malloc( sizeof( slap_callback ));
int rc = SLAP_CB_CONTINUE;
/* FIXME: used to happen for instance during abandon
db.be_flags |= SLAP_DBFLAG_OVERLAY;
op->o_bd = &db;
}
- cb.sc_next = op->o_callback;
- cb.sc_private = oi;
- op->o_callback = &cb;
+ cb->sc_cleanup = NULL;
+ cb->sc_response = over_back_response;
+ cb->sc_writewait = NULL;
+ cb->sc_next = op->o_callback;
+ cb->sc_private = oi;
+ op->o_callback = cb;
rc = overlay_op_walk( op, rs, which, oi, on );
for ( sc = &op->o_callback; *sc; sc = &(*sc)->sc_next ) {
- if ( *sc == &cb ) {
- *sc = cb.sc_next;
+ if ( *sc == cb ) {
+ *sc = cb->sc_next;
+ ch_free( cb );
break;
}
}
rm_cb->sc_cleanup = overlay_remove_cb;
rm_cb->sc_response = NULL;
rm_cb->sc_private = (void*) rm_ctx;
+ rm_cb->sc_writewait = NULL;
/* Append callback to the end of the list */
if ( !op->o_callback ) {