CLEANUP: spoe: do not use appctx.ctx anymore

The spoe code already uses its own generic pointer, let's move it to
svcctx instead of keeping a struct spoe in the appctx union.
This commit is contained in:
Willy Tarreau 2022-05-05 20:18:44 +02:00
parent 455caef642
commit 23a2407843
2 changed files with 5 additions and 8 deletions

View File

@ -111,9 +111,6 @@ struct appctx {
const char *reason;
struct task *task;
} hlua_apphttp; /* used by the Lua HTTP services */
struct {
void *ptr; /* private pointer for SPOE filter */
} spoe; /* used by SPOE filter */
struct {
const char *msg; /* pointer to a persistent message to be returned in CLI_ST_PRINT state */
int severity; /* severity of the message to be returned according to (syslog) rfc5424 */

View File

@ -63,7 +63,7 @@
#define FRAME_HDR_SIZE 32
/* Helper to get SPOE ctx inside an appctx */
#define SPOE_APPCTX(appctx) ((struct spoe_appctx *)((appctx)->ctx.spoe.ptr))
#define SPOE_APPCTX(appctx) ((struct spoe_appctx *)((appctx)->svcctx))
/* SPOE filter id. Used to identify SPOE filters */
const char *spoe_filter_id = "SPOE filter";
@ -1073,7 +1073,7 @@ spoe_prepare_healthcheck_request(char **req, int *len)
memset(&spoe_appctx, 0, sizeof(spoe_appctx));
memset(buf, 0, sizeof(buf));
appctx.ctx.spoe.ptr = &spoe_appctx;
appctx.svcctx = &spoe_appctx;
SPOE_APPCTX(&appctx)->max_frame_size = MAX_FRAME_SIZE;
frame = buf+4; /* Reserved the 4 first bytes for the frame size */
@ -1112,7 +1112,7 @@ spoe_handle_healthcheck_response(char *frame, size_t size, char *err, int errlen
memset(&appctx, 0, sizeof(appctx));
memset(&spoe_appctx, 0, sizeof(spoe_appctx));
appctx.ctx.spoe.ptr = &spoe_appctx;
appctx.svcctx = &spoe_appctx;
SPOE_APPCTX(&appctx)->max_frame_size = MAX_FRAME_SIZE;
if (*frame == SPOE_FRM_T_AGENT_DISCON) {
@ -1227,7 +1227,7 @@ spoe_release_appctx(struct appctx *appctx)
if (spoe_appctx == NULL)
return;
appctx->ctx.spoe.ptr = NULL;
appctx->svcctx = NULL;
agent = spoe_appctx->agent;
SPOE_PRINTF(stderr, "%d.%06d [SPOE/%-15s] %s: appctx=%p\n",
@ -1996,7 +1996,7 @@ spoe_create_appctx(struct spoe_config *conf)
if ((appctx = appctx_new(&spoe_applet, NULL)) == NULL)
goto out_error;
appctx->ctx.spoe.ptr = pool_zalloc(pool_head_spoe_appctx);
appctx->svcctx = pool_zalloc(pool_head_spoe_appctx);
if (SPOE_APPCTX(appctx) == NULL)
goto out_free_appctx;