Skip to content

Commit

Permalink
Use new thread-local list for client connections
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed May 10, 2024
1 parent 7384aac commit 298e6c5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
29 changes: 22 additions & 7 deletions src/lib/io/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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?!
*/
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/io/master.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 298e6c5

Please sign in to comment.