]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move instantiation to proper function
authorAlan T. DeKok <aland@freeradius.org>
Thu, 26 Apr 2018 13:05:49 +0000 (09:05 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 26 Apr 2018 13:05:49 +0000 (09:05 -0400)
src/lib/io/master.c
src/lib/io/master.h
src/modules/proto_radius/proto_radius.c

index e380c3d628f56795493c9a4bf2c23bde23992844..fed8ab820d925e516b03151635d26be66419bb1c 100644 (file)
@@ -2061,7 +2061,7 @@ static ssize_t mod_write(void *instance, void *packet_ctx,
         *
         */
        if (!inst->pending_clients) {
-               MEM(inst->pending_clients = fr_heap_create(client, pending_client_cmp,
+               MEM(inst->pending_clients = fr_heap_create(inst->ctx, pending_client_cmp,
                                                           fr_io_client_t, heap_id));
        }
 
@@ -2164,7 +2164,7 @@ static int mod_bootstrap(void *instance, UNUSED CONF_SECTION *cs)
 
        if (inst->app_io->bootstrap && (inst->app_io->bootstrap(inst->app_io_instance,
                                                                inst->app_io_conf) < 0)) {
-               cf_log_err(inst->app_io_conf, "Bootstrap failed for \"%s\"", inst->app_io->name);
+               cf_log_err(inst->app_io_conf, "Bootstrap failed for \"proto_%s\"", inst->app_io->name);
                return -1;
        }
 
@@ -2185,10 +2185,19 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
 
        rad_assert(inst->app_io != NULL);
 
+       /*
+        *      Create the trie of clients for this socket.
+        */
+       inst->trie = fr_trie_alloc(inst->ctx);
+       if (!inst->trie) {
+               cf_log_err(conf, "Instantiation failed for \"proto_%s\"", inst->app_io->name);
+               return -1;
+       }
+
        if (inst->app_io->instantiate &&
            (inst->app_io->instantiate(inst->app_io_instance,
                                          inst->app_io_conf) < 0)) {
-               cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->name);
+               cf_log_err(conf, "Instantiation failed for \"proto_%s\"", inst->app_io->name);
                return -1;
        }
 
index 914a8a533af07f0e5e18e3911ed2b1ac5d7c1cf7..9d7384d8db9df6c4548e42e8c69318e2c7fbf208 100644 (file)
@@ -60,7 +60,8 @@ typedef struct {
 typedef struct fr_io_instance_t {
        int                             magic;                          //!< sparkles and unicorns
 
-       dl_instance_t const             *dl_inst;                       //!< our parent dl_inst
+       TALLOC_CTX                      *ctx;                           //!< this struct might not be talloc'd
+       dl_instance_t const             *dl_inst;                       //!< our parent dl_inst
 
        uint32_t                        max_connections;                //!< maximum number of connections to allow
        uint32_t                        max_clients;                    //!< maximum number of dynamic clients to allow
index 0e741bff4b8a31d8f781cc6e95f01f834c70b363..c576c67493479181d97f989892dd9d0f99ec51a3 100644 (file)
@@ -773,13 +773,9 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
 
        /*
-        *      Create the trie of clients for this socket.
+        *      Set talloc ctx for master IO.
         */
-       inst->io.trie = fr_trie_alloc(inst);
-       if (!inst->io.trie) {
-               cf_log_err(conf, "Instantiation failed for \"%s\"", inst->io.app_io->name);
-               return -1;
-       }
+       inst->io.ctx = inst;
 
        /*
         *      Instantiate the master io submodule