From: Alan T. DeKok Date: Tue, 15 Oct 2024 14:40:09 +0000 (-0400) Subject: add API to allow signals to run retries X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0f13d2e24cc489f15edbb820a5a5a3c93235367;p=thirdparty%2Ffreeradius-server.git add API to allow signals to run retries i.e. on DUP signal. We don't want to have a separate code path, we just want to run the normal retry mechanism. --- diff --git a/src/lib/unlang/module.c b/src/lib/unlang/module.c index 9331ff429eb..69373d5937f 100644 --- a/src/lib/unlang/module.c +++ b/src/lib/unlang/module.c @@ -286,6 +286,37 @@ unlang_action_t unlang_module_yield_to_section(rlm_rcode_t *p_result, return UNLANG_ACTION_PUSHED_CHILD; } +/** Run the retry handler. Called from an async signal handler. + * + */ +void unlang_module_retry_now(module_ctx_t const *mctx, request_t *request) +{ + unlang_stack_t *stack = request->stack; + unlang_stack_frame_t *frame = &stack->frame[stack->depth]; + unlang_frame_state_module_t *state = talloc_get_type_abort(frame->state, unlang_frame_state_module_t); + + if (!state->retry_cb) return; + + /* + * Assert that we have the right things. Note that this function should only be called when the + * retry is being used as an expiry time, i.e. mrc==1. If the module has its own retry handlers, + * then this function must not be called. + */ + fr_assert(state->retry.config != NULL); + fr_assert(state->retry.config->mrc == 1); + fr_assert(state->rctx == mctx->rctx); + fr_assert(state->request == request); + + /* + * Update the time as to when the retry is being called. This is the main purpose of the + * function. + */ + state->retry.updated = fr_time(); + + state->retry_cb(mctx, request, &state->retry); + +} + /** Cancel the retry timer on resume * */ diff --git a/src/lib/unlang/module.h b/src/lib/unlang/module.h index 2156606217b..68b2eee6bf0 100644 --- a/src/lib/unlang/module.h +++ b/src/lib/unlang/module.h @@ -102,6 +102,8 @@ unlang_action_t unlang_module_yield_to_tmpl(TALLOC_CTX *ctx, fr_value_box_list_t module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx); +void unlang_module_retry_now(module_ctx_t const *mctx, request_t *request) CC_HINT(nonnull); + unlang_action_t unlang_module_yield_to_retry(request_t *request, module_method_t resume, unlang_module_retry_t retry_cb, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx, fr_retry_config_t const *retry_cfg);