From 2ff82a82c59795be091291d53fecb294c3af0d8c Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 19 Aug 2003 03:22:07 +0000 Subject: [PATCH] Tweaks to callback processing; callbacks can return SLAP_CB_CONTINUE to fall into the regular send_ldap_* functionality instead of calling into those functions explicitly. Nested callbacks still aren't handled as cleanly as they might be. --- servers/slapd/backglue.c | 6 +----- servers/slapd/backover.c | 9 +++++---- servers/slapd/result.c | 12 +++++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index e60be088ba..a22be0a1c5 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -187,11 +187,7 @@ glue_back_response ( Operation *op, SlapReply *rs ) op->o_callback = gs->prevcb; if (op->o_callback && op->o_callback->sc_response) { rs->sr_err = op->o_callback->sc_response( op, rs ); - } else if (rs->sr_type == REP_SEARCH) { - rs->sr_err = send_search_entry( op, rs ); - } else { - rs->sr_err = send_search_reference( op, rs ); - } + } else rs->sr_err = SLAP_CB_CONTINUE; op->o_callback = tmp; return rs->sr_err; diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index 875c35e722..29edb8470c 100644 --- a/servers/slapd/backover.c +++ b/servers/slapd/backover.c @@ -130,21 +130,22 @@ over_back_response ( Operation *op, SlapReply *rs ) int rc = SLAP_CB_CONTINUE; BackendDB *be = op->o_bd, db = *op->o_bd; slap_callback *sc = op->o_callback->sc_private; + slap_callback *s0 = op->o_callback; op->o_bd = &db; + op->o_callback = sc; for (; on; on=on->on_next ) { if ( on->on_response ) { db.bd_info = (BackendInfo *)on; rc = on->on_response( op, rs ); - if ( ! (rc & SLAP_CB_CONTINUE) ) break; + if ( rc != SLAP_CB_CONTINUE ) break; } } - op->o_callback = sc; - if ( sc && (rc & SLAP_CB_CONTINUE) ) { + if ( sc && (rc == SLAP_CB_CONTINUE) ) { rc = sc->sc_response( op, rs ); } op->o_bd = be; - rc &= ~SLAP_CB_CONTINUE; + op->o_callback = s0; return rc; } diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 37a6f00330..e59f4a434c 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -218,7 +218,7 @@ send_ldap_controls( BerElement *ber, LDAPControl **c ) return rc; } -static void +void send_ldap_response( Operation *op, SlapReply *rs ) @@ -229,8 +229,8 @@ send_ldap_response( long bytes; if (op->o_callback && op->o_callback->sc_response) { - op->o_callback->sc_response( op, rs ); - return; + rc = op->o_callback->sc_response( op, rs ); + if ( rc != SLAP_CB_CONTINUE ) return; } #ifdef LDAP_CONNECTIONLESS @@ -608,7 +608,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs ) rs->sr_type = REP_SEARCH; if (op->o_callback && op->o_callback->sc_response) { - return op->o_callback->sc_response( op, rs ); + rc = op->o_callback->sc_response( op, rs ); + if ( rc != SLAP_CB_CONTINUE ) return rc; } #ifdef NEW_LOGGING @@ -1225,7 +1226,8 @@ slap_send_search_reference( Operation *op, SlapReply *rs ) rs->sr_type = REP_SEARCHREF; if (op->o_callback && op->o_callback->sc_response) { - return op->o_callback->sc_response( op, rs ); + rc = op->o_callback->sc_response( op, rs ); + if ( rc != SLAP_CB_CONTINUE ) return rc; } mark = sl_mark( op->o_tmpmemctx ); -- 2.39.5