]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet: Prepare appctx to own the session on frontend side
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 9 May 2022 06:08:26 +0000 (08:08 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 May 2022 14:13:21 +0000 (16:13 +0200)
Applets were moved at the same level than multiplexers. Thus, gradually,
applets code is changed to be less dependent from the stream. With this
commit, the frontend appctx are ready to own the session. It means a
frontend appctx will be responsible to release the session.

include/haproxy/applet-t.h
include/haproxy/applet.h
src/applet.c

index e7823e1367dacea40bd47b8010b74cf4337e4cdf..2784650d9b8ee178ccafa8d969d9288aea9d81e1 100644 (file)
@@ -39,6 +39,7 @@ struct appctx;
 struct proxy;
 struct conn_stream;
 struct cs_endpoint;
+struct session;
 
 /* Applet descriptor */
 struct applet {
@@ -61,6 +62,7 @@ struct appctx {
        unsigned int st1;          /* prompt/payload (bitwise OR of APPCTX_CLI_ST1_*) for stats, session error for peers */
        struct buffer *chunk;       /* used to store unfinished commands */
        struct applet *applet;     /* applet this context refers to */
+       struct session *sess;      /* session for frontend applets (NULL for backend applets) */
        struct cs_endpoint *endp;
        struct act_rule *rule;     /* rule associated with the applet. */
        int (*io_handler)(struct appctx *appctx);  /* used within the cli_io_handler when st0 = CLI_ST_CALLBACK */
index 185c1c19ccea6f1be73ba78a417a2301266b8dc8..2ee368b83114108509e66eae4880b540d31857b7 100644 (file)
@@ -29,6 +29,7 @@
 #include <haproxy/conn_stream.h>
 #include <haproxy/list.h>
 #include <haproxy/pool.h>
+#include <haproxy/session.h>
 #include <haproxy/task.h>
 
 extern unsigned int nb_applets;
@@ -47,7 +48,8 @@ static inline void __appctx_free(struct appctx *appctx)
        task_destroy(appctx->t);
        if (LIST_INLIST(&appctx->buffer_wait.list))
                LIST_DEL_INIT(&appctx->buffer_wait.list);
-
+       if (appctx->sess)
+               session_free(appctx->sess);
        BUG_ON(appctx->endp && !(appctx->endp->flags & CS_EP_ORPHAN));
        cs_endpoint_free(appctx->endp);
        pool_free(pool_head_appctx, appctx);
index 9e15c7eb77b6fd157f482c28ec5247460841a493..b7711b1bdda5459e15bed7df893c446c7b966433 100644 (file)
@@ -42,7 +42,7 @@ struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp)
        LIST_INIT(&appctx->wait_entry);
        appctx->obj_type = OBJ_TYPE_APPCTX;
        appctx->applet = applet;
-
+       appctx->sess = NULL;
        if (!endp) {
                endp = cs_endpoint_new();
                if (!endp)