]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use local radmin_ctx && free it on stop
authorAlan T. DeKok <aland@freeradius.org>
Sun, 5 Aug 2018 14:29:33 +0000 (10:29 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 5 Aug 2018 14:29:48 +0000 (10:29 -0400)
src/bin/radmin.c

index e5fd55340c905690cedaa0f65a5e1e62bb5193b5..c427bd0dbd9e4183bb7340bfd58458c0eab06848 100644 (file)
@@ -61,6 +61,7 @@ static pthread_t pthread_id;
 static bool stop = false;
 static int context = 0;
 static fr_cmd_info_t radmin_info;
+static TALLOC_CTX *radmin_ctx;
 
 #ifndef USE_READLINE
 /*
@@ -920,6 +921,9 @@ static fr_cmd_table_t cmd_table[] = {
 
 int fr_radmin_start(main_config_t *config, bool cli)
 {
+       radmin_ctx = talloc_init("radmin");
+       if (!radmin_ctx) return -1;
+
        gettimeofday(&start_time, NULL);
 
 #ifdef USE_READLINE
@@ -929,7 +933,7 @@ int fr_radmin_start(main_config_t *config, bool cli)
        fr_command_register_hook = fr_radmin_register;
        radmin_main_config = config;
 
-       if (fr_radmin_register(NULL, NULL, cmd_table) < 0) {
+       if (fr_radmin_register(radmin_ctx, NULL, cmd_table) < 0) {
                PERROR("Failed initializing radmin");
                return -1;
        }
@@ -956,6 +960,8 @@ void fr_radmin_stop(void)
        stop = true;
 
        (void) pthread_join(pthread_id, NULL);
+
+       TALLOC_FREE(radmin_ctx);
 }
 
 /*