]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add IO signal handler, and call it if it exists
authorAlan T. DeKok <aland@freeradius.org>
Thu, 24 Aug 2017 19:32:21 +0000 (15:32 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 24 Aug 2017 20:25:25 +0000 (16:25 -0400)
src/modules/rlm_radius/rlm_radius.c
src/modules/rlm_radius/rlm_radius.h

index e22f93c01414d1a20c048ccfe28589bb7d3ed31e..a6b8df09db93dcb03aa9bf6294acb2fe1472667e 100644 (file)
@@ -315,6 +315,33 @@ static int mod_link_free(rlm_radius_link_t *link)
        return 0;
 }
 
+static void mod_radius_signal(REQUEST *request, void *instance, void *thread, void *ctx,
+                             fr_state_action_t action)
+{
+       rlm_radius_t const *inst = talloc_get_type_abort(instance, rlm_radius_t);
+       rlm_radius_thread_t *t = talloc_get_type_abort(thread, rlm_radius_thread_t);
+       rlm_radius_link_t *link = talloc_get_type_abort(ctx, rlm_radius_link_t);
+
+       /*
+        *      We've been told we're done.  Clean up.
+        *
+        *      Note that the caller doesn't necessarily need to send
+        *      us the signal, as he can just talloc_free(request).
+        *      But it is more polite to send a signal, and it allows
+        *      the IO modules to do additional debugging if
+        *      necessary.
+        */
+       if (action == FR_ACTION_DONE) {
+               talloc_free(link);
+               return;
+       }
+
+       if (!inst->io->signal) return;
+
+       inst->io->signal(request, inst->io_instance, t->thread_io_ctx, link, action);
+}
+
+
 /** Continue after unlang_resumable()
  *
  */
@@ -455,8 +482,7 @@ static rlm_rcode_t CC_HINT(nonnull) mod_process(void *instance, void *thread, RE
 
        talloc_set_destructor(link, mod_link_free);
 
-       // @todo - add signal / cancellation handler
-       return unlang_module_yield(request, mod_radius_resume, NULL, link);
+       return unlang_module_yield(request, mod_radius_resume, mod_radius_signal, link);
 }
 
 
index 7e2a4b1a8ae4446b5994371e5eab3172161fe8a0..bba41e70844a19e9c80ba5ddbc0622cb243c9b93 100644 (file)
@@ -36,6 +36,7 @@ typedef struct rlm_radius_link_t rlm_radius_link_t;
  *
  */
 typedef rlm_rcode_t (*fr_radius_io_push_t)(void *instance, REQUEST *request, rlm_radius_link_t *link, void *thread);
+typedef void (*fr_radius_io_signal_t)(REQUEST *request, void *instance, void *thread, rlm_radius_link_t *link, fr_state_action_t action);
 typedef int (*fr_radius_io_instantiate_t)(rlm_radius_t *inst, void *io_instance, CONF_SECTION *cs);
 
 
@@ -57,6 +58,7 @@ typedef struct fr_radius_client_io_t {
        size_t                          request_inst_size;      //!< size of the data per request
 
        fr_radius_io_push_t             push;                   //!< push a REQUEST to an IO submodule
+       fr_radius_io_signal_t           signal;                 //!< send a signal to an IO module
 } fr_radius_client_io_t;
 
 typedef struct rlm_radius_retry_t {