#ifndef NDEBUG
uint32_t magic; //!< Magic number used to detect memory corruption,
//!< or request structs that have not been properly initialised.
+
+ uint64_t ins_count; //!< count of instructions we've ran
+ uint64_t ins_max; //!< max instruction to bail out at
+
#endif
void *stack; //!< unlang interpreter stack.
yielded_clear(frame);
}
+#ifndef NDEBUG
+ /*
+ * Failure testing!
+ */
+ if (request->ins_max && (request->master_state != REQUEST_STOP_PROCESSING)) {
+ request->ins_count++;
+
+ if (request->ins_count >= request->ins_max) {
+ request->master_state = REQUEST_STOP_PROCESSING;
+ RERROR("Failing request due to maximum instruction count %" PRIu64, request->ins_max);
+ }
+ }
+#endif
+
/*
* unlang_interpret_signal() takes care of
* marking the requests as STOP on a CANCEL
*/
static void _request_done_external(request_t *request, UNUSED rlm_rcode_t rcode, UNUSED void *uctx)
{
- /*
- * If we're running a real request, then the final
- * indentation MUST be zero. Otherwise we skipped
- * something!
- *
- * Also check that the request is NOT marked as
- * "yielded", but is in fact done.
- *
- * @todo - check that the stack is at frame 0, otherwise
- * more things have gone wrong.
- */
- fr_assert_msg(request->parent || (request->log.unlang_indent == 0),
- "Request %s bad log indentation - expected 0 got %u", request->name, request->log.unlang_indent);
- fr_assert_msg(!unlang_interpret_is_resumable(request),
- "Request %s is marked as yielded at end of processing", request->name);
+ if (request->master_state != REQUEST_STOP_PROCESSING) {
+ /*
+ * If we're running a real request, then the final
+ * indentation MUST be zero. Otherwise we skipped
+ * something!
+ *
+ * Also check that the request is NOT marked as
+ * "yielded", but is in fact done.
+ *
+ * @todo - check that the stack is at frame 0, otherwise
+ * more things have gone wrong.
+ */
+ fr_assert_msg(request->parent || (request->log.unlang_indent == 0),
+ "Request %s bad log indentation - expected 0 got %u", request->name, request->log.unlang_indent);
+ fr_assert_msg(!unlang_interpret_is_resumable(request),
+ "Request %s is marked as yielded at end of processing", request->name);
+ }
RDEBUG3("Synchronous done external request");
}