diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index 9c70469c2..bd3bf68ca 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -31,7 +31,6 @@ #include /* 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 */ diff --git a/src/applet.c b/src/applet.c index 27c1f7f40..77f69346a 100644 --- a/src/applet.c +++ b/src/applet.c @@ -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;