]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add API to allow signals to run retries
authorAlan T. DeKok <aland@freeradius.org>
Tue, 15 Oct 2024 14:40:09 +0000 (10:40 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 15 Oct 2024 15:31:15 +0000 (11:31 -0400)
i.e. on DUP signal.  We don't want to have a separate code path,
we just want to run the normal retry mechanism.

src/lib/unlang/module.c
src/lib/unlang/module.h

index 9331ff429eb6a7f0f4f050aa0b2bca2e889e9a8b..69373d5937f9df9a7ed920976d73df02fa387edb 100644 (file)
@@ -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
  *
  */
index 2156606217b332b7d96240fb393b4d3f25c476d3..68b2eee6bf0a6d57a1aa753797553b03fdf389dc 100644 (file)
@@ -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);