diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 752a1a2b2..6eb792670 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -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); diff --git a/src/applet.c b/src/applet.c index 41ad2fc3d..c9d0c55bf 100644 --- a/src/applet.c +++ b/src/applet.c @@ -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(). */