]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet: add a function to reset the svcctx of an applet
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Aug 2022 16:13:34 +0000 (18:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 18 Aug 2022 16:16:36 +0000 (18:16 +0200)
The CLI needs to reset the svcctx between commands, and there was nothing
done to handle this. Let's add appctx_reset_svcctx() to do that, it's the
closing equivalent of appctx_reserve_svcctx().

This will have to be backported to 2.6 as it will be used by a subsequent
patch to fix a bug.

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

index 752a1a2b2f766d9fd4a2fdad4b85dcef0fccf786..6eb79267034e1b28abe544429005537ea7473b4d 100644 (file)
@@ -40,6 +40,7 @@ extern struct pool_head *pool_head_appctx;
 struct task *task_run_applet(struct task *t, void *context, unsigned int state);
 int appctx_buf_available(void *arg);
 void *applet_reserve_svcctx(struct appctx *appctx, size_t size);
+void applet_reset_svcctx(struct appctx *appctx);
 void appctx_shut(struct appctx *appctx);
 
 struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int thr);
index 41ad2fc3dd4a7a6e0d64812720dabf7cb6a1d30c..c9d0c55bff7290b9f3b4cf907c2e4b3f7a900278 100644 (file)
@@ -142,6 +142,15 @@ void *applet_reserve_svcctx(struct appctx *appctx, size_t size)
        return appctx->svcctx;
 }
 
+/* This is used to reset an svcctx and the svc.storage without releasing the
+ * appctx. In fact this is only used by the CLI applet between commands.
+ */
+void applet_reset_svcctx(struct appctx *appctx)
+{
+       memset(&appctx->svc.storage, 0, APPLET_MAX_SVCCTX);
+       appctx->svcctx = NULL;
+}
+
 /* call the applet's release() function if any, and marks the sedesc as shut.
  * Needs to be called upon close().
  */