]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add RETRY_CAPABLE flag, and check it in module compilation
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Aug 2021 18:24:22 +0000 (14:24 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Aug 2021 18:24:22 +0000 (14:24 -0400)
so that we don't erroneously resume modules on timers, when the
modules don't expect to be resumed.

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

index c26544a7348c67ecf715ef4bbb7c6032f49beeef..dfe31a86564ab8952e4cc866a0d059293e7c76b8 100644 (file)
@@ -1571,6 +1571,15 @@ module_instance_t *module_bootstrap(module_instance_t const *parent, CONF_SECTIO
                return NULL;
        }
 
+       /*
+        *      If the module isn't marked as "retry safe", then disallow retries.
+        */
+       if (mi->actions.retry.irt && ((mi->module->type & RLM_TYPE_RETRY) != 0)) {
+               cf_log_err(cs, "Cannot do retries for module \"%s\" - it does not support them", mi->name);
+               talloc_free(mi);
+               return NULL;
+       }
+
        return mi;
 }
 
index 16289f67fc607e3f9e182b44a9a2e4f45fb6944b..ee6639ae20886d567ba372a2931f4d474fc9eb10 100644 (file)
@@ -47,6 +47,8 @@ typedef struct module_ctx_s                   module_ctx_t;
                                                //!< with mutex.
 #define RLM_TYPE_RESUMABLE             (1 << 2)        //!< does yield / resume
 
+#define RLM_TYPE_RETRY         (1 << 3)        //!< can handle retries
+
 /** Module section callback
  *
  * Is called when the module is listed in a particular section of a virtual
index cc719640c68f02c3980ddca68d9f972bf619b095..9c35fc705bc5b8354feb69fddd759ea674494c17 100644 (file)
@@ -3613,6 +3613,20 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_t *unlang_ctx,
                }
        }
 
+       /*
+        *      If we're retrying this section, then all modules in
+        *      the section have to be marked as retry-safe.
+        *
+        *      src/lib/server/module.c already checks if the default
+        *      module actions are retry safe, so we don't need to
+        *      check that here.
+        */
+       if (unlang_ctx->actions->retry.irt && ((inst->module->type & RLM_TYPE_RETRY) != 0)) {
+               cf_log_err(ci, "Cannot do retries for module \"%s\" - it does not support them", inst->module->name);
+               talloc_free(c);
+               return NULL;
+       }
+
        return c;
 }