From 91f7a1af340719d3150bb1f46543e8c42d541af4 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 15 Jul 2022 16:26:44 +0200 Subject: [PATCH] CLEANUP: applet: remove the obsolete command context from the appctx The "ctx" and "st2" parts in the appctx were marked for removal in 2.7 and were emulated using memcpy/memset etc for possible external code. Let's remove this now. --- include/haproxy/applet-t.h | 57 +++++++------------------------------- src/cli.c | 12 -------- src/stream.c | 6 ++-- 3 files changed, 12 insertions(+), 63 deletions(-) diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index 6c0659183..b89494eac 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -75,55 +75,18 @@ struct appctx { struct freq_ctr call_rate; /* appctx call rate */ struct list wait_entry; /* entry in a list of waiters for an event (e.g. ring events) */ - /* WARNING: the entries below are only kept for compatibility with - * possible external code but will disappear in 2.7, you must use the - * cleaner svcctx now (look at "show fd" for an example). + /* The pointer seen by application code is appctx->svcctx. In 2.7 the + * anonymous union and the "ctx" struct disappeared, and the struct + * "svc" became svc_storage, which is never accessed directly by + * application code. Look at "show fd" for an example. */ - union { - __attribute__((deprecated)) unsigned int st2; - unsigned int _st2; - }; - /* This anonymous union is temporary for 2.6 to avoid a new API change - * after 2.6 while keeping the compatibility with pre-2.7 code. - * The pointer seen by application code is appctx->svcctx. In 2.7 the - * anonymous union will disappear and the struct "svc" will become - * svc_storage, which is never accessed directly by application code. - * The compatibility with the old appctx->ctx.* is preserved for now - * and this union will disappear in 2.7 - */ - union { - /* here we have the service's context (CLI command, applet, etc) */ - void *svcctx; /* pointer to a context used by the command, e.g. below */ - struct { - void *shadow; /* shadow of svcctx above, do not use! */ - char storage[APPLET_MAX_SVCCTX]; /* storage of svcctx above */ - } svc; /* generic storage for most commands */ - - /* The "ctx" part below is kept only to help smooth transition - * of legacy code and will disappear after 2.6. It ensures that - * ctx.cli may safely map to a clean representation of the - * "cli_print_ctx" struct mapped in "svc.storage" above. - */ - struct { - void *shadow; /* shadow of svcctx above for alignment, do not use! */ - struct { - /* these 3 first fields must match EXACTLY "struct cli_print_ctx" */ - const char *msg; /* pointer to a persistent message to be returned in CLI_ST_PRINT state */ - char *err; /* pointer to a 'must free' message to be returned in CLI_ST_PRINT_FREE state */ - int severity; /* severity of the message to be returned according to (syslog) rfc5424 */ - - /* WARNING: the entries below are only kept for compatibility - * with possible external code but will disappear in 2.7, you - * must use the cleaner svcctx now (look at "show fd" for an - * example). - */ - void *p0, *p1, *p2; - size_t o0, o1; - int i0, i1; - } cli __attribute__((deprecated)); /* context used by the CLI */ - } ctx; /* context-specific variables used by any applet */ - }; /* end of anon union */ + /* here we have the service's context (CLI command, applet, etc) */ + void *svcctx; /* pointer to a context used by the command, e.g. below */ + struct { + void *shadow; /* shadow of svcctx above, do not use! */ + char storage[APPLET_MAX_SVCCTX]; /* storage of svcctx above */ + } svc; /* generic storage for most commands */ }; #endif /* _HAPROXY_APPLET_T_H */ diff --git a/src/cli.c b/src/cli.c index 419466524..9630d5a1c 100644 --- a/src/cli.c +++ b/src/cli.c @@ -747,16 +747,6 @@ static int cli_parse_request(struct appctx *appctx) int i = 0; struct cli_kw *kw; - appctx->_st2 = 0; - - /* temporary for 2.6: let's make sure we clean the whole shared - * context. - */ - if (sizeof(appctx->ctx) > sizeof(appctx->svc)) - memset(&appctx->ctx, 0, sizeof(appctx->ctx)); - else - memset(&appctx->svc, 0, sizeof(appctx->svc)); - p = appctx->chunk->area; end = p + appctx->chunk->data; @@ -922,8 +912,6 @@ static void cli_io_handler(struct appctx *appctx) while (1) { if (appctx->st0 == CLI_ST_INIT) { - /* CLI/stats not initialized yet */ - memset(&appctx->ctx, 0, sizeof(appctx->ctx)); /* reset severity to default at init */ appctx->cli_severity_output = bind_conf->severity_output; appctx->st0 = CLI_ST_GETREQ; diff --git a/src/stream.c b/src/stream.c index 5187eb9ee..66529d4d7 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3336,11 +3336,10 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm } else if ((tmpctx = sc_appctx(scf)) != NULL) { chunk_appendf(&trash, - " app0=%p st0=%d st1=%d st2=%d applet=%s tid=%d nice=%d calls=%u rate=%u cpu=%llu lat=%llu\n", + " app0=%p st0=%d st1=%d applet=%s tid=%d nice=%d calls=%u rate=%u cpu=%llu lat=%llu\n", tmpctx, tmpctx->st0, tmpctx->st1, - tmpctx->_st2, tmpctx->applet->name, tmpctx->t->tid, tmpctx->t->nice, tmpctx->t->calls, read_freq_ctr(&tmpctx->call_rate), @@ -3375,11 +3374,10 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm } else if ((tmpctx = sc_appctx(scb)) != NULL) { chunk_appendf(&trash, - " app1=%p st0=%d st1=%d st2=%d applet=%s tid=%d nice=%d calls=%u rate=%u cpu=%llu lat=%llu\n", + " app1=%p st0=%d st1=%d applet=%s tid=%d nice=%d calls=%u rate=%u cpu=%llu lat=%llu\n", tmpctx, tmpctx->st0, tmpctx->st1, - tmpctx->_st2, tmpctx->applet->name, tmpctx->t->tid, tmpctx->t->nice, tmpctx->t->calls, read_freq_ctr(&tmpctx->call_rate),