From: Christopher Faulet Date: Thu, 4 Jul 2024 08:57:29 +0000 (+0200) Subject: MINOR: spoe: Dynamically alloc the message list per event of an agent X-Git-Tag: v3.1-dev4~81 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6145a0ea1d161d2f5c1b3d0950a5cbb3a8dc060;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/spoe-t.h b/include/haproxy/spoe-t.h index 40ba373d65..9b10c920fd 100644 --- a/include/haproxy/spoe-t.h +++ b/include/haproxy/spoe-t.h @@ -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 */ diff --git a/src/flt_spoe.c b/src/flt_spoe.c index df85cabd57..1615305d35 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -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);