#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
#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;
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 */
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;
/* 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);
}
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;
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);
}
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;