From: Willy Tarreau Date: Thu, 5 May 2022 18:18:44 +0000 (+0200) Subject: CLEANUP: spoe: do not use appctx.ctx anymore X-Git-Tag: v2.6-dev9~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23a2407843f82ee067f3f9d7b93da52cbf4603b9;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index 87b25fd70f..ccedad0d60 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -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 */ diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 3f264872ad..f032e83059 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -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;