]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allocate thread_instance from NULL ctx
authorAlan T. DeKok <aland@freeradius.org>
Tue, 30 Oct 2018 15:07:21 +0000 (11:07 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 30 Oct 2018 15:46:21 +0000 (11:46 -0400)
and add a destructor

src/lib/io/master.c
src/lib/io/master.h

index cfae56a6260c1431714934b201d3ba3ec659b0f2..1dffb4fe25c19733ed0da0b97f36cbcdcf0c2a6f 100644 (file)
@@ -2657,6 +2657,14 @@ static int _client_heap_free(fr_heap_t *heap)
        return 0;
 }
 
+int fr_io_listen_free(fr_listen_t *li)
+{
+       if (!li->thread_instance) return 0;
+
+       talloc_free(li->thread_instance);
+       return 0;
+}
+
 int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *sc,
                        size_t default_message_size, size_t num_messages)
 {
@@ -2677,6 +2685,7 @@ int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *inst, fr_schedule_t *
         *      back again.
         */
        MEM(li = talloc_zero(ctx, fr_listen_t));
+       talloc_set_destructor(li, fr_io_listen_free);
 
        /*
         *      The first listener is the one for the application
index fffb8cbe78a4f0cf2dd940cbc9e2a6cf30c5984a..a31562688c8da849262da4394b226a82d445b7bd 100644 (file)
@@ -108,6 +108,7 @@ extern fr_app_io_t fr_master_app_io;
 fr_trie_t *fr_master_io_network(TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ipaddr_t *deny);
 int fr_master_io_listen(TALLOC_CTX *ctx, fr_io_instance_t *io, fr_schedule_t *sc,
                        size_t default_message_size, size_t num_messages) CC_HINT(nonnull);
+int fr_io_listen_free(fr_listen_t *li);
 int fr_app_process_bootstrap(dl_instance_t **type_submodule, CONF_SECTION *conf, CONF_SECTION *server_cs);
 int fr_app_process_instantiate(dl_instance_t **type_submodule, dl_instance_t **type_submodule_by_code, int code_max, CONF_SECTION *conf);