return rc;
}
+/*
+ * slap_response_play()
+ *
+ * plays the callback list; rationale: a callback can
+ * - remove itself from the list, by setting op->o_callback = NULL;
+ * malloc()'ed callbacks should free themselves from inside the
+ * sc_response() function.
+ * - replace itself with another (list of) callback(s), by setting
+ * op->o_callback = a new (list of) callback(s); in this case, it
+ * is the callback's responsibility to to append existing subsequent
+ * callbacks to the end of the list that is passed to the sc_response()
+ * function.
+ * - modify the list of subsequent callbacks by modifying the value
+ * of the sc_next field from inside the sc_response() function; this
+ * case does not require any handling from inside slap_response_play()
+ *
+ * To stop execution of the playlist, the sc_response() function must return
+ * a value different from SLAP_SC_CONTINUE.
+ *
+ * The same applies to slap_cleanup_play(); only, there is no means to stop
+ * execution of the playlist, since all cleanup functions must be called.
+ */
static int
-slap_response_loop(
+slap_response_play(
Operation *op,
SlapReply *rs )
{
} else if ( op->o_callback != *scp ) {
/* a new callback has been inserted
- * after the existing one; repair the list */
- *sc_nextp = op->o_callback;
- sc_nextp = &op->o_callback;
+ * in place of the existing one; repair the list */
+ *scp = op->o_callback;
+ sc_nextp = scp;
}
if ( rc != SLAP_CB_CONTINUE ) break;
}
}
static int
-slap_cleanup_loop(
+slap_cleanup_play(
Operation *op,
SlapReply *rs )
{
} else if ( op->o_callback != *scp ) {
/* a new callback has been inserted
* after the existing one; repair the list */
- *sc_nextp = op->o_callback;
- sc_nextp = &op->o_callback;
+ /* a new callback has been inserted
+ * in place of the existing one; repair the list */
+ *scp = op->o_callback;
+ sc_nextp = scp;
}
/* don't care about the result; do all cleanup */
}
}
if ( op->o_callback ) {
- rc = slap_response_loop( op, rs );
+ rc = slap_response_play( op, rs );
if ( rc != SLAP_CB_CONTINUE ) {
goto clean2;
}
clean2:;
if ( op->o_callback ) {
- (void)slap_cleanup_loop( op, rs );
+ (void)slap_cleanup_play( op, rs );
}
if ( rs->sr_matched && rs->sr_flags & REP_MATCHED_MUSTBEFREED ) {
}
if ( op->o_callback ) {
- rc = slap_response_loop( op, rs );
+ rc = slap_response_play( op, rs );
if ( rc != SLAP_CB_CONTINUE ) {
goto error_return;
}
error_return:;
if ( op->o_callback ) {
- (void)slap_cleanup_loop( op, rs );
+ (void)slap_cleanup_play( op, rs );
}
if ( e_flags ) {
rs->sr_type = REP_SEARCHREF;
if ( op->o_callback ) {
- rc = slap_response_loop( op, rs );
+ rc = slap_response_play( op, rs );
if ( rc != SLAP_CB_CONTINUE ) {
goto rel;
}
rel:
if ( op->o_callback ) {
- (void)slap_cleanup_loop( op, rs );
+ (void)slap_cleanup_play( op, rs );
}
return rc;