]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: applet: remove the obsolete command context from the appctx
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 14:26:44 +0000 (16:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 17:41:26 +0000 (19:41 +0200)
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
src/cli.c
src/stream.c

index 6c0659183cbc99f6ac001cadf4246bb4dca5f072..b89494eac81ed75edd07a48c731e30266e06d64a 100644 (file)
@@ -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. <storage> 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. <storage> 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 */
index 419466524b196d3e293b03a61eaa2e4368dea664..9630d5a1cd58397e472a3e7595b68fc36506b079 100644 (file)
--- 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;
index 5187eb9eec16b3c0c4f5af3ec55a049e6aacadaa..66529d4d77acd45bc447cb7b4e6ded00b11adbb5 100644 (file)
@@ -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),