From 70e54d2527edbdbd6216924f63214dbc4ef9a550 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 5 Oct 2017 22:13:39 +0100 Subject: [PATCH] ITS#8752 fix syncrepl null_callback Make sure it's last in callback stack --- servers/slapd/syncrepl.c | 63 +++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 91f4d3a6b7..4025498179 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -162,7 +162,6 @@ static int syncrepl_op_modify( Operation *op, SlapReply *rs ); /* callback functions */ static int dn_callback( Operation *, SlapReply * ); static int nonpresent_callback( Operation *, SlapReply * ); -static int null_callback( Operation *, SlapReply * ); static AttributeDescription *sync_descs[4]; @@ -2280,6 +2279,34 @@ syncrepl_op_modify( Operation *op, SlapReply *rs ) return SLAP_CB_CONTINUE; } +static int +syncrepl_null_callback( + Operation *op, + SlapReply *rs ) +{ + /* If we're not the last callback in the chain, move to the end */ + if ( op->o_callback->sc_next ) { + slap_callback **sc, *s1; + s1 = op->o_callback; + op->o_callback = op->o_callback->sc_next; + for ( sc = &op->o_callback; *sc; sc = &(*sc)->sc_next ) ; + *sc = s1; + s1->sc_next = NULL; + return SLAP_CB_CONTINUE; + } + if ( rs->sr_err != LDAP_SUCCESS && + rs->sr_err != LDAP_REFERRAL && + rs->sr_err != LDAP_ALREADY_EXISTS && + rs->sr_err != LDAP_NO_SUCH_OBJECT && + rs->sr_err != LDAP_NOT_ALLOWED_ON_NONLEAF ) + { + Debug( LDAP_DEBUG_ANY, + "syncrepl_null_callback : error code 0x%x\n", + rs->sr_err, 0, 0 ); + } + return LDAP_SUCCESS; +} + static int syncrepl_message_to_op( syncinfo_t *si, @@ -2291,7 +2318,7 @@ syncrepl_message_to_op( Modifications *modlist = NULL; logschema *ls; SlapReply rs = { REP_RESULT }; - slap_callback cb = { NULL, null_callback, NULL, NULL }; + slap_callback cb = { NULL, syncrepl_null_callback, NULL, NULL }; const char *text; char txtbuf[SLAP_TEXT_BUFLEN]; @@ -3006,7 +3033,7 @@ syncrepl_entry( slap_sl_free( op->ors_filterstr.bv_val, op->o_tmpmemctx ); } - cb.sc_response = null_callback; + cb.sc_response = syncrepl_null_callback; cb.sc_private = si; if ( entry && !BER_BVISNULL( &entry->e_name ) ) { @@ -3426,7 +3453,7 @@ retry_modrdn:; op->o_delete_glue_parent = 0; if ( !be_issuffix( be, &op->o_req_ndn ) ) { slap_callback cb = { NULL }; - cb.sc_response = slap_null_cb; + cb.sc_response = syncrepl_null_callback; dnParent( &op->o_req_ndn, &pdn ); op->o_req_dn = pdn; op->o_req_ndn = pdn; @@ -3624,7 +3651,7 @@ syncrepl_del_nonpresent( np_list = LDAP_LIST_NEXT( np_list, npe_link ); op->o_tag = LDAP_REQ_DELETE; op->o_callback = &cb; - cb.sc_response = null_callback; + cb.sc_response = syncrepl_null_callback; cb.sc_private = si; op->o_req_dn = *np_prev->npe_name; op->o_req_ndn = *np_prev->npe_nname; @@ -3666,7 +3693,7 @@ syncrepl_del_nonpresent( op->o_delete_glue_parent = 0; if ( !be_issuffix( be, &op->o_req_ndn ) ) { slap_callback cb = { NULL }; - cb.sc_response = slap_null_cb; + cb.sc_response = syncrepl_null_callback; dnParent( &op->o_req_ndn, &pdn ); op->o_req_dn = pdn; op->o_req_ndn = pdn; @@ -3719,7 +3746,7 @@ syncrepl_add_glue_ancestors( op->o_tag = LDAP_REQ_ADD; op->o_callback = &cb; - cb.sc_response = null_callback; + cb.sc_response = syncrepl_null_callback; cb.sc_private = NULL; dn = e->e_name; @@ -3861,7 +3888,7 @@ syncrepl_add_glue( op->o_tag = LDAP_REQ_ADD; op->o_callback = &cb; - cb.sc_response = null_callback; + cb.sc_response = syncrepl_null_callback; cb.sc_private = NULL; op->o_req_dn = e->e_name; @@ -3973,7 +4000,7 @@ syncrepl_updateCookie( op->o_tag = LDAP_REQ_MODIFY; - cb.sc_response = null_callback; + cb.sc_response = syncrepl_null_callback; cb.sc_private = si; op->o_callback = &cb; @@ -4466,24 +4493,6 @@ nonpresent_callback( return LDAP_SUCCESS; } -static int -null_callback( - Operation* op, - SlapReply* rs ) -{ - if ( rs->sr_err != LDAP_SUCCESS && - rs->sr_err != LDAP_REFERRAL && - rs->sr_err != LDAP_ALREADY_EXISTS && - rs->sr_err != LDAP_NO_SUCH_OBJECT && - rs->sr_err != LDAP_NOT_ALLOWED_ON_NONLEAF ) - { - Debug( LDAP_DEBUG_ANY, - "null_callback : error code 0x%x\n", - rs->sr_err, 0, 0 ); - } - return LDAP_SUCCESS; -} - static struct berval * slap_uuidstr_from_normalized( struct berval* uuidstr, -- 2.39.2