From: Hallvard Furuseth Date: Mon, 2 Nov 2009 16:14:39 +0000 (+0000) Subject: ITS#6337: replace previous commit with minimum-impact change. X-Git-Tag: ACLCHECK_0~149 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5270cedb865a34249d4c05a15c3d3b72785a5e6c;p=openldap ITS#6337: replace previous commit with minimum-impact change. Some cleanup. --- diff --git a/servers/slapd/back-relay/op.c b/servers/slapd/back-relay/op.c index 1c7ba71baa..d393e587aa 100644 --- a/servers/slapd/back-relay/op.c +++ b/servers/slapd/back-relay/op.c @@ -75,14 +75,14 @@ typedef struct relay_callback { BackendDB *rcb_bd; } relay_callback; -int +static int relay_back_cleanup_cb( Operation *op, SlapReply *rs ) { op->o_bd = ((relay_callback *) op->o_callback)->rcb_bd; return SLAP_CB_CONTINUE; } -int +static int relay_back_response_cb( Operation *op, SlapReply *rs ) { relay_callback *rcb = (relay_callback *) op->o_callback; @@ -93,35 +93,21 @@ relay_back_response_cb( Operation *op, SlapReply *rs ) return SLAP_CB_CONTINUE; } -/* quick hack for ITS#6337: use malloc'ed callback for bind */ -int -relay_back_cleanup2_cb( Operation *op, SlapReply *rs ) -{ - op->o_bd = ((relay_callback *) op->o_callback)->rcb_bd; - op->o_tmpfree( op->o_callback, op->o_tmpmemctx ); - op->o_callback = NULL; - return SLAP_CB_CONTINUE; -} - -int -relay_back_response2_cb( Operation *op, SlapReply *rs ) -{ - relay_callback *rcb = (relay_callback *) op->o_callback; - - rcb->rcb_sc.sc_cleanup = relay_back_cleanup2_cb; - rcb->rcb_bd = op->o_bd; - op->o_bd = op->o_callback->sc_private; - return SLAP_CB_CONTINUE; -} - -#define relay_back_add_cb( rcb, op, bd ) \ - { \ +#define relay_back_add_cb( rcb, op ) { \ (rcb)->rcb_sc.sc_next = (op)->o_callback; \ (rcb)->rcb_sc.sc_response = relay_back_response_cb; \ (rcb)->rcb_sc.sc_cleanup = 0; \ (rcb)->rcb_sc.sc_private = (op)->o_bd; \ (op)->o_callback = (slap_callback *) (rcb); \ - } +} + +#define relay_back_remove_cb( rcb, op ) { \ + slap_callback **sc = &(op)->o_callback; \ + for ( ;; sc = &(*sc)->sc_next ) \ + if ( *sc == (slap_callback *) (rcb) ) { \ + *sc = (*sc)->sc_next; break; \ + } else if ( *sc == NULL ) break; \ +} /* * Select the backend database with the operation's DN. On failure, @@ -220,23 +206,11 @@ relay_back_op( Operation *op, SlapReply *rs, int which ) } else if ( (func = (&bd->be_bind)[which]) != 0 ) { relay_callback rcb; - if ( which == op_bind ) { - /* quick hack for ITS#6337: use malloc'ed callback for bind */ - relay_callback *rcbp = op->o_tmpcalloc( sizeof( relay_callback ), 1, op->o_tmpmemctx ); - relay_back_add_cb( rcbp, op, bd ); - rcbp->rcb_sc.sc_response = relay_back_response2_cb; - - } else { - relay_back_add_cb( &rcb, op, bd ); - } - + relay_back_add_cb( &rcb, op ); RELAY_WRAP_OP( op, bd, which, { rc = func( op, rs ); }); - - if ( op->o_callback == (slap_callback *) &rcb ) { - op->o_callback = op->o_callback->sc_next; - } + relay_back_remove_cb( &rcb, op ); } else if ( fail_mode & RB_OPERR ) { rs->sr_err = rc;