MINOR: applet: Remove appctx state field to only used the flags

The appctx state was never really used as a state. It is only used to know
when an applet should be freed on the next wakeup. This can be converted to
a flag and the state can be removed. This is what this patch does.
This commit is contained in:
Christopher Faulet 2024-01-15 18:42:39 +01:00
parent 4434b03358
commit 14bd091fd7
2 changed files with 7 additions and 7 deletions

View File

@ -31,7 +31,6 @@
#include <haproxy/xref-t.h>
/* flags for appctx->state */
#define APPLET_WANT_DIE 0x01 /* applet was running and requested to die */
/* Room for per-command context (mostly CLI commands but not only) */
#define APPLET_MAX_SVCCTX 88
@ -45,6 +44,7 @@
#define APPCTX_FL_EOS 0x00000020
#define APPCTX_FL_ERR_PENDING 0x00000040
#define APPCTX_FL_ERROR 0x00000080
#define APPCTX_FL_WANT_DIE 0x00000100 /* applet was running and requested to die */
struct appctx;
struct proxy;
@ -71,7 +71,6 @@ struct applet {
struct appctx {
enum obj_type obj_type; /* OBJ_TYPE_APPCTX */
/* 3 unused bytes here */
unsigned short state; /* Internal appctx state */
unsigned int st0; /* CLI state for stats, session state for peers */
unsigned int st1; /* prompt/payload (bitwise OR of APPCTX_CLI_ST1_*) for stats, session error for peers */

View File

@ -138,9 +138,9 @@ static void applet_trace(enum trace_level level, uint64_t mask, const struct tra
if (src->verbosity == STRM_VERB_CLEAN)
return;
chunk_appendf(&trace_buf, " appctx=%p .t=%p .t.exp=%d .state=%d .st0=%d .st1=%d",
chunk_appendf(&trace_buf, " appctx=%p .t=%p .t.exp=%d .flags=0x%x .st0=%d .st1=%d",
appctx, appctx->t, tick_isset(appctx->t->expire) ? TICKS_TO_MS(appctx->t->expire - now_ms) : TICK_ETERNITY,
appctx->state, appctx->st0, appctx->st1);
appctx->flags, appctx->st0, appctx->st1);
if (!sc || src->verbosity == STRM_VERB_MINIMAL)
return;
@ -350,7 +350,7 @@ void appctx_free(struct appctx *appctx)
/* if it's running, or about to run, defer the freeing
* until the callback is called.
*/
appctx->state |= APPLET_WANT_DIE;
applet_fl_set(appctx, APPCTX_FL_WANT_DIE);
task_wakeup(appctx->t, TASK_WOKEN_OTHER);
TRACE_DEVEL("Cannot release APPCTX now, wake it up", APPLET_EV_FREE, appctx);
}
@ -589,7 +589,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
TRACE_ENTER(APPLET_EV_PROCESS, app);
if (app->state & APPLET_WANT_DIE) {
if (applet_fl_test(app, APPCTX_FL_WANT_DIE)) {
TRACE_DEVEL("APPCTX want die, release it", APPLET_EV_FREE, app);
__appctx_free(app);
return NULL;
@ -660,6 +660,7 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
sc_ep_report_read_activity(sc);
}
/* TODO: May be move in appctx_rcv_buf or sc_applet_process ? */
if (sc_waiting_room(sc) && (sc->flags & SC_FL_ABRT_DONE)) {
sc_ep_set(sc, SE_FL_EOS|SE_FL_ERROR);
}
@ -698,7 +699,7 @@ struct task *task_process_applet(struct task *t, void *context, unsigned int sta
TRACE_ENTER(APPLET_EV_PROCESS, app);
if (app->state & APPLET_WANT_DIE) {
if (applet_fl_test(app, APPCTX_FL_WANT_DIE)) {
TRACE_DEVEL("APPCTX want die, release it", APPLET_EV_FREE, app);
__appctx_free(app);
return NULL;