]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add cancellation point for rlm_delay
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 21 Nov 2017 19:12:46 +0000 (19:12 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 21 Nov 2017 19:19:03 +0000 (19:19 +0000)
src/include/modules.h
src/modules/rlm_delay/rlm_delay.c

index fa8f844758bc05d522aa5933080699e8664dc069..fabf6863ca3c7ee2fc627e5682d15060a3a0debb 100644 (file)
@@ -305,8 +305,8 @@ void                unlang_signal(REQUEST *request, fr_state_action_t action);
 
 int            unlang_stack_depth(REQUEST *request);
 
-rlm_rcode_t    unlang_module_yield(REQUEST *request, fr_unlang_resume_callback_t callback, fr_unlang_action_t signal_callback,
-                            void *ctx);
+rlm_rcode_t    unlang_module_yield(REQUEST *request, fr_unlang_resume_callback_t callback,
+                                   fr_unlang_action_t signal_callback, void *ctx);
 
 int            unlang_initialize(void);
 
index c2c96f00d744252adf503ceb26f6fd2d5eb43e62..10a009d9ca9892877f19c07e1ce10b66027ad81d 100644 (file)
@@ -143,6 +143,16 @@ static rlm_rcode_t delay_add(rlm_delay_t const *inst, REQUEST *request)
        return RLM_MODULE_YIELD;
 }
 
+static void delay_cancel(REQUEST *request, UNUSED void *instance, UNUSED void *thread, void *ctx,
+                        fr_state_action_t action)
+{
+       if (action != FR_ACTION_DONE) return;
+
+       RDEBUG2("Cancelling delay");
+
+       if (!fr_cond_assert(unlang_event_timeout_delete(request, ctx) < 0)) return;
+}
+
 static rlm_rcode_t CC_HINT(nonnull) mod_delay(void *instance, UNUSED void *thread, REQUEST *request)
 {
        rlm_delay_t const       *inst = instance;
@@ -157,7 +167,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_delay(void *instance, UNUSED void *threa
        /*
         *      Yield, setting delay_return as the next state
         */
-       return unlang_module_yield(request, delay_return, NULL, NULL);
+       return unlang_module_yield(request, delay_return, delay_cancel, NULL);
 }
 
 extern rad_module_t rlm_delay;