]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move tmpl free to the atexit handlers
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 15 May 2024 01:45:58 +0000 (19:45 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 15 May 2024 01:45:58 +0000 (19:45 -0600)
src/lib/server/base.c
src/lib/server/tmpl.h
src/lib/server/tmpl_eval.c

index 43f663337f7ef62f418340f77871341cf0f3e464..7420fe26d8cb5245dd3abb8b241f2f915afec15e 100644 (file)
@@ -130,9 +130,4 @@ void server_free(void)
         *      trigger tree.
         */
        trigger_exec_free();
-
-       /*
-        *      Free the internal dictionaries the tmpl code uses
-        */
-       tmpl_global_free();
 }
index 5104a0071413c011e1d4bda01d057536b1e69dc7..7c4dc72848dcdc4e543d9e9eacbfb4b68eeb0039 100644 (file)
@@ -1335,7 +1335,6 @@ void                      tmpl_rules_child_init(TALLOC_CTX *ctx, tmpl_rules_t *out, tmpl_rules_t co
 void                   tmpl_rules_debug(tmpl_rules_t const *rules) CC_HINT(nonnull);
 
 int                    tmpl_global_init(void);
-void                   tmpl_global_free(void);
 
 #undef _CONST
 
index c34ce3a43289c510402048a04e4453367cf5b014..b4ffe37cb1e3ba5161d132ca0a0620d3ea241c59 100644 (file)
@@ -34,6 +34,8 @@ RCSID("$Id$")
 #include <freeradius-devel/server/tmpl_dcursor.h>
 #include <freeradius-devel/server/client.h>
 #include <freeradius-devel/unlang/call.h>
+
+#include <freeradius-devel/util/atexit.h>
 #include <freeradius-devel/util/dlist.h>
 #include <freeradius-devel/util/proto.h>
 #include <freeradius-devel/util/value.h>
@@ -1450,7 +1452,16 @@ int tmpl_eval_cast_in_place(fr_value_box_list_t *list, request_t *request, tmpl_
        goto success;
 }
 
-int tmpl_global_init(void)
+static int _tmpl_global_free(UNUSED void *uctx)
+{
+       fr_dict_autofree(tmpl_dict);
+
+       fr_dict_unknown_free(&tmpl_attr_unspec);
+
+       return 0;
+}
+
+static int _tmpl_global_init(UNUSED void *uctx)
 {
        fr_dict_attr_t *da;
 
@@ -1468,9 +1479,11 @@ int tmpl_global_init(void)
        return 0;
 }
 
-void tmpl_global_free(void)
+int tmpl_global_init(void)
 {
-       fr_dict_autofree(tmpl_dict);
+       int ret;
 
-       fr_dict_unknown_free(&tmpl_attr_unspec);
+       fr_atexit_global_once_ret(&ret, _tmpl_global_init, _tmpl_global_free, NULL);
+
+       return 0;
 }