]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use new thread-local list for client connections
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 10 May 2024 05:21:10 +0000 (23:21 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 10 May 2024 05:47:05 +0000 (23:47 -0600)
src/lib/io/master.c
src/lib/io/master.h

index c52e99b004cdfc6bda8fb96b21f60209774c2863..8f69b0d8e14376325ac9794c9fdfb6a67b626b86 100644 (file)
@@ -143,7 +143,7 @@ struct fr_io_connection_s {
        fr_listen_t                     *child;         //!< child listener (app_io) for this socket
        fr_io_client_t                  *client;        //!< our local client (pending or connected).
        fr_io_client_t                  *parent;        //!< points to the parent client.
-       module_instance_t               *mi;    //!< for submodule
+       module_instance_t               *mi;            //!< for submodule
 
        bool                            dead;           //!< roundabout way to get the network side to close a socket
        bool                            paused;         //!< event filter doesn't like resuming something that isn't paused
@@ -493,7 +493,6 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
         */
        if (!nak) {
                char *inst_name;
-               char const *transport_name = inst->submodule->module->exported->name;
 
                if (inst->max_connections || client->radclient->limit.max_connections) {
                        uint32_t max_connections = inst->max_connections ? inst->max_connections : client->radclient->limit.max_connections;
@@ -518,17 +517,27 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst,
                }
 
                /*
-                *      FIXME - This should a 'sub' module list
+                *      Add a client module into a sublist
                 */
-               inst_name = talloc_asprintf(NULL, "%s%"PRIu64, transport_name, thread->client_id++);
-               mi = module_instance_alloc(inst->submodule->ml, inst->submodule, DL_MODULE_TYPE_SUBMODULE,
-                                          inst->submodule->module->exported->name, inst_name);
+               inst_name = talloc_asprintf(NULL, "%"PRIu64, thread->client_id++);
+               mi = module_instance_copy(inst->clients, inst->submodule, inst_name);
 
-               if (module_instance_conf_parse(mi, inst->server_cs) < 0) {
+               if (module_instance_conf_parse(mi, inst->submodule->conf) < 0) {
                        cf_log_perr(inst->server_cs, "Failed parsing module config");
                        goto cleanup;
                }
 
+               /* Thread local module lists never run bootstrap */
+               if (module_instantiate(mi) < 0) {
+                       cf_log_perr(inst->server_cs, "Failed instantiating module");
+                       goto cleanup;
+               }
+
+               if (module_thread_instantiate(mi, mi, thread->el) < 0) {
+                       cf_log_perr(inst->server_cs, "Failed instantiating module");
+                       goto cleanup;
+               }
+
                /*
                 *      FIXME - Instantiate the new module?!
                 */
@@ -2695,6 +2704,12 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
                }
        }
 
+       /*
+        *      Create a list of client modules.
+        *
+        *      FIXME - Probably only want to do this for connected sockets?
+        */
+       inst->clients = module_list_alloc(inst, &module_list_type_thread_local, "clients");
 
        return 0;
 }
index 6ea7ae0b52d0b0612c73bf84e1be6e06de0152f1..fef64cb3c91e947e03bf0249fc4a50ed0d0c0866 100644 (file)
@@ -70,7 +70,10 @@ typedef struct fr_io_track_s {
  *  creates the listener, and adds it to the scheduler.
  */
 typedef struct {
-       module_instance_t const         *mi;                    //!< our parent mi
+       module_instance_t const         *mi;                            //!< our parent mi
+       module_list_t                   *clients;                       //!< Holds client modules created to represent
+                                                                       ///< sockets created as clients connect to the
+                                                                       ///< listener.
 
        uint32_t                        max_connections;                //!< maximum number of connections to allow
        uint32_t                        max_clients;                    //!< maximum number of dynamic clients to allow