From: Alan T. DeKok Date: Tue, 30 Oct 2018 15:07:21 +0000 (-0400) Subject: allocate thread_instance from NULL ctx X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=554284084c4590f74eed2df812dbaa6ec1da2fa8;p=thirdparty%2Ffreeradius-server.git allocate thread_instance from NULL ctx and add a destructor --- diff --git a/src/lib/io/master.c b/src/lib/io/master.c index cfae56a6260..1dffb4fe25c 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -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 diff --git a/src/lib/io/master.h b/src/lib/io/master.h index fffb8cbe78a..a31562688c8 100644 --- a/src/lib/io/master.h +++ b/src/lib/io/master.h @@ -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);