From: Alan T. DeKok Date: Mon, 30 Aug 2021 18:24:22 +0000 (-0400) Subject: add RETRY_CAPABLE flag, and check it in module compilation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1a39aa44f948fb1bfd318d1ab825304e3b28edb;p=thirdparty%2Ffreeradius-server.git add RETRY_CAPABLE flag, and check it in module compilation so that we don't erroneously resume modules on timers, when the modules don't expect to be resumed. --- diff --git a/src/lib/server/module.c b/src/lib/server/module.c index c26544a7348..dfe31a86564 100644 --- a/src/lib/server/module.c +++ b/src/lib/server/module.c @@ -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; } diff --git a/src/lib/server/module.h b/src/lib/server/module.h index 16289f67fc6..ee6639ae208 100644 --- a/src/lib/server/module.h +++ b/src/lib/server/module.h @@ -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 diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index cc719640c68..9c35fc705bc 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -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; }