MINOR: spoe: Dynamically alloc the message list per event of an agent

The inline array used to store, the configured messages per event in the
SPOE agent structure, is replaced by a dynamic array, allocated during the
configuration parsing. The main purpose of this change is to be able to move
all stuff regarding the SPOE filter and applet in the C file.

The related issue is #2502.
This commit is contained in:
Christopher Faulet 2024-07-04 10:57:29 +02:00
parent ce53bb6284
commit e6145a0ea1
2 changed files with 8 additions and 1 deletions

View File

@ -296,7 +296,7 @@ struct spoe_agent {
unsigned int flags; /* SPOE_FL_* */
unsigned int max_frame_size; /* Maximum frame size for this agent, before any negotiation */
struct list events[SPOE_EV_EVENTS]; /* List of SPOE messages that will be sent
struct list *events; /* List of SPOE messages that will be sent
* for each supported events */
struct list groups; /* List of available SPOE groups */

View File

@ -151,6 +151,7 @@ spoe_release_agent(struct spoe_agent *agent)
LIST_DELETE(&grp->list);
spoe_release_group(grp);
}
free(agent->events);
free(agent->engine_id);
free(agent);
}
@ -2451,6 +2452,12 @@ cfg_parse_spoe_agent(const char *file, int linenum, char **args, int kwm)
curagent->flags = SPOE_FL_PIPELINING;
curagent->max_frame_size = SPOP_MAX_FRAME_SIZE;
if ((curagent->events = calloc(SPOE_EV_EVENTS, sizeof(*curagent->events))) == NULL) {
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
for (i = 0; i < SPOE_EV_EVENTS; ++i)
LIST_INIT(&curagent->events[i]);
LIST_INIT(&curagent->groups);