unsigned int display_flags;
unsigned int curr_gen; /* current/latest generation, for show/clear */
unsigned int prev_gen; /* prev generation, for clear */
+ enum {
+ STATE_INIT = 0, /* initialize list and backrefs */
+ STATE_LIST, /* list entries */
+ STATE_DONE, /* finished */
+ } state; /* state of the dump */
};
/* expects the current generation ID in ctx->curr_gen */
/* If we're forced to shut down, we might have to remove our
* reference to the last ref_elt being dumped.
*/
- if (appctx->st2 == STAT_ST_LIST) {
+ if (ctx->state == STATE_LIST) {
HA_SPIN_LOCK(PATREF_LOCK, &ctx->ref->lock);
if (!LIST_ISEMPTY(&ctx->bref.users)) {
LIST_DELETE(&ctx->bref.users);
return 1;
}
- switch (appctx->st2) {
-
- case STAT_ST_INIT:
- appctx->st2 = STAT_ST_LIST;
+ switch (ctx->state) {
+ case STATE_INIT:
+ ctx->state = STATE_LIST;
/* fall through */
- case STAT_ST_LIST:
+ case STATE_LIST:
HA_SPIN_LOCK(PATREF_LOCK, &ctx->ref->lock);
if (!LIST_ISEMPTY(&ctx->bref.users)) {
/* fall through */
default:
- appctx->st2 = STAT_ST_FIN;
+ ctx->state = STATE_DONE;
return 1;
}
}
struct show_map_ctx *ctx = appctx->svcctx;
struct conn_stream *cs = appctx->owner;
- switch (appctx->st2) {
- case STAT_ST_INIT:
+ switch (ctx->state) {
+ case STATE_INIT:
/* Display the column headers. If the message cannot be sent,
* quit the function with returning 0. The function is called
- * later and restarted at the state "STAT_ST_INIT".
+ * later and restarted at the state "STATE_INIT".
*/
chunk_reset(&trash);
chunk_appendf(&trash, "# id (file) description\n");
ctx->ref = LIST_ELEM(&pattern_reference, struct pat_ref *, list);
ctx->ref = pat_list_get_next(ctx->ref, &pattern_reference,
ctx->display_flags);
- appctx->st2 = STAT_ST_LIST;
+ ctx->state = STATE_LIST;
/* fall through */
- case STAT_ST_LIST:
+ case STATE_LIST:
while (ctx->ref) {
chunk_reset(&trash);
/* fall through */
default:
- appctx->st2 = STAT_ST_FIN;
+ ctx->state = STATE_DONE;
return 1;
}
return 0;
struct pattern *pat;
int match_method;
- switch (appctx->st2) {
- case STAT_ST_INIT:
+ switch (ctx->state) {
+ case STATE_INIT:
/* Init to the first entry. The list cannot be change */
ctx->expr = LIST_ELEM(&ctx->ref->pat, struct pattern_expr *, list);
ctx->expr = pat_expr_get_next(ctx->expr, &ctx->ref->pat);
- appctx->st2 = STAT_ST_LIST;
+ ctx->state = STATE_LIST;
/* fall through */
- case STAT_ST_LIST:
+ case STATE_LIST:
HA_SPIN_LOCK(PATREF_LOCK, &ctx->ref->lock);
/* for each lookup type */
while (ctx->expr) {
/* fall through */
default:
- appctx->st2 = STAT_ST_FIN;
+ ctx->state = STATE_DONE;
return 1;
}
}
{
struct show_map_ctx *ctx = appctx->svcctx;
- if (appctx->st2 == STAT_ST_LIST) {
+ if (ctx->state == STATE_LIST) {
HA_SPIN_LOCK(PATREF_LOCK, &ctx->ref->lock);
if (!LIST_ISEMPTY(&ctx->bref.users))
LIST_DELETE(&ctx->bref.users);