mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-24 13:42:16 +00:00
CLEANUP: stream/cli: remove the now unneeded dump state from "show sess"
The state was a constant, let's remove what remains of the switch/case. The code from the "case" statement was only reindented as can be checked with "git show -b".
This commit is contained in:
parent
bb4e289fa9
commit
6177cfc3b5
361
src/stream.c
361
src/stream.c
@ -3154,9 +3154,6 @@ struct show_sess_ctx {
|
||||
unsigned int uid; /* if non-null, the uniq_id of the session being dumped */
|
||||
int section; /* section of the session being dumped */
|
||||
int pos; /* last position of the current session's buffer */
|
||||
enum {
|
||||
STATE_LIST = 0,
|
||||
} state; /* dump state */
|
||||
};
|
||||
|
||||
/* This function dumps a complete stream state onto the conn-stream's
|
||||
@ -3562,193 +3559,191 @@ static int cli_io_handler_dump_sess(struct appctx *appctx)
|
||||
|
||||
chunk_reset(&trash);
|
||||
|
||||
switch (ctx->state) {
|
||||
default:
|
||||
/* first, let's detach the back-ref from a possible previous stream */
|
||||
if (!LIST_ISEMPTY(&ctx->bref.users)) {
|
||||
/* first, let's detach the back-ref from a possible previous stream */
|
||||
if (!LIST_ISEMPTY(&ctx->bref.users)) {
|
||||
LIST_DELETE(&ctx->bref.users);
|
||||
LIST_INIT(&ctx->bref.users);
|
||||
} else if (!ctx->bref.ref) {
|
||||
/* first call, start with first stream */
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].streams.n;
|
||||
}
|
||||
|
||||
/* and start from where we stopped */
|
||||
while (1) {
|
||||
char pn[INET6_ADDRSTRLEN];
|
||||
struct stream *curr_strm;
|
||||
int done= 0;
|
||||
|
||||
if (ctx->bref.ref == &ha_thread_ctx[ctx->thr].streams)
|
||||
done = 1;
|
||||
else {
|
||||
/* check if we've found a stream created after issuing the "show sess" */
|
||||
curr_strm = LIST_ELEM(ctx->bref.ref, struct stream *, list);
|
||||
if ((int)(curr_strm->stream_epoch - __cs_strm(appctx->owner)->stream_epoch) > 0)
|
||||
done = 1;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
ctx->thr++;
|
||||
if (ctx->thr >= global.nbthread)
|
||||
break;
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].streams.n;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->target) {
|
||||
if (ctx->target != (void *)-1 && ctx->target != curr_strm)
|
||||
goto next_sess;
|
||||
|
||||
LIST_APPEND(&curr_strm->back_refs, &ctx->bref.users);
|
||||
/* call the proper dump() function and return if we're missing space */
|
||||
if (!stats_dump_full_strm_to_buffer(cs, curr_strm))
|
||||
goto full;
|
||||
|
||||
/* stream dump complete */
|
||||
LIST_DELETE(&ctx->bref.users);
|
||||
LIST_INIT(&ctx->bref.users);
|
||||
} else if (!ctx->bref.ref) {
|
||||
/* first call, start with first stream */
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].streams.n;
|
||||
}
|
||||
|
||||
/* and start from where we stopped */
|
||||
while (1) {
|
||||
char pn[INET6_ADDRSTRLEN];
|
||||
struct stream *curr_strm;
|
||||
int done= 0;
|
||||
|
||||
if (ctx->bref.ref == &ha_thread_ctx[ctx->thr].streams)
|
||||
done = 1;
|
||||
else {
|
||||
/* check if we've found a stream created after issuing the "show sess" */
|
||||
curr_strm = LIST_ELEM(ctx->bref.ref, struct stream *, list);
|
||||
if ((int)(curr_strm->stream_epoch - __cs_strm(appctx->owner)->stream_epoch) > 0)
|
||||
done = 1;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
ctx->thr++;
|
||||
if (ctx->thr >= global.nbthread)
|
||||
break;
|
||||
ctx->bref.ref = ha_thread_ctx[ctx->thr].streams.n;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->target) {
|
||||
if (ctx->target != (void *)-1 && ctx->target != curr_strm)
|
||||
goto next_sess;
|
||||
|
||||
LIST_APPEND(&curr_strm->back_refs, &ctx->bref.users);
|
||||
/* call the proper dump() function and return if we're missing space */
|
||||
if (!stats_dump_full_strm_to_buffer(cs, curr_strm))
|
||||
goto full;
|
||||
|
||||
/* stream dump complete */
|
||||
LIST_DELETE(&ctx->bref.users);
|
||||
LIST_INIT(&ctx->bref.users);
|
||||
if (ctx->target != (void *)-1) {
|
||||
ctx->target = NULL;
|
||||
break;
|
||||
}
|
||||
else
|
||||
goto next_sess;
|
||||
}
|
||||
|
||||
chunk_appendf(&trash,
|
||||
"%p: proto=%s",
|
||||
curr_strm,
|
||||
strm_li(curr_strm) ? strm_li(curr_strm)->rx.proto->name : "?");
|
||||
|
||||
conn = objt_conn(strm_orig(curr_strm));
|
||||
switch (conn && conn_get_src(conn) ? addr_to_str(conn->src, pn, sizeof(pn)) : AF_UNSPEC) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
chunk_appendf(&trash,
|
||||
" src=%s:%d fe=%s be=%s srv=%s",
|
||||
pn,
|
||||
get_host_port(conn->src),
|
||||
strm_fe(curr_strm)->id,
|
||||
(curr_strm->be->cap & PR_CAP_BE) ? curr_strm->be->id : "<NONE>",
|
||||
objt_server(curr_strm->target) ? __objt_server(curr_strm->target)->id : "<none>"
|
||||
);
|
||||
break;
|
||||
case AF_UNIX:
|
||||
chunk_appendf(&trash,
|
||||
" src=unix:%d fe=%s be=%s srv=%s",
|
||||
strm_li(curr_strm)->luid,
|
||||
strm_fe(curr_strm)->id,
|
||||
(curr_strm->be->cap & PR_CAP_BE) ? curr_strm->be->id : "<NONE>",
|
||||
objt_server(curr_strm->target) ? __objt_server(curr_strm->target)->id : "<none>"
|
||||
);
|
||||
if (ctx->target != (void *)-1) {
|
||||
ctx->target = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" ts=%02x epoch=%#x age=%s calls=%u rate=%u cpu=%llu lat=%llu",
|
||||
curr_strm->task->state, curr_strm->stream_epoch,
|
||||
human_time(now.tv_sec - curr_strm->logs.tv_accept.tv_sec, 1),
|
||||
curr_strm->task->calls, read_freq_ctr(&curr_strm->call_rate),
|
||||
(unsigned long long)curr_strm->task->cpu_time, (unsigned long long)curr_strm->task->lat_time);
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" rq[f=%06xh,i=%u,an=%02xh,rx=%s",
|
||||
curr_strm->req.flags,
|
||||
(unsigned int)ci_data(&curr_strm->req),
|
||||
curr_strm->req.analysers,
|
||||
curr_strm->req.rex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->req.rex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",wx=%s",
|
||||
curr_strm->req.wex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->req.wex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",ax=%s]",
|
||||
curr_strm->req.analyse_exp ?
|
||||
human_time(TICKS_TO_MS(curr_strm->req.analyse_exp - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" rp[f=%06xh,i=%u,an=%02xh,rx=%s",
|
||||
curr_strm->res.flags,
|
||||
(unsigned int)ci_data(&curr_strm->res),
|
||||
curr_strm->res.analysers,
|
||||
curr_strm->res.rex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->res.rex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",wx=%s",
|
||||
curr_strm->res.wex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->res.wex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",ax=%s]",
|
||||
curr_strm->res.analyse_exp ?
|
||||
human_time(TICKS_TO_MS(curr_strm->res.analyse_exp - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
conn = cs_conn(curr_strm->csf);
|
||||
chunk_appendf(&trash,
|
||||
" csf=[%d,%1xh,fd=%d]",
|
||||
curr_strm->csf->state,
|
||||
curr_strm->csf->flags,
|
||||
conn_fd(conn));
|
||||
|
||||
conn = cs_conn(curr_strm->csb);
|
||||
chunk_appendf(&trash,
|
||||
" csb=[%d,%1xh,fd=%d]",
|
||||
curr_strm->csb->state,
|
||||
curr_strm->csb->flags,
|
||||
conn_fd(conn));
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" exp=%s rc=%d c_exp=%s",
|
||||
curr_strm->task->expire ?
|
||||
human_time(TICKS_TO_MS(curr_strm->task->expire - now_ms),
|
||||
TICKS_TO_MS(1000)) : "",
|
||||
curr_strm->conn_retries,
|
||||
curr_strm->conn_exp ?
|
||||
human_time(TICKS_TO_MS(curr_strm->conn_exp - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
if (task_in_rq(curr_strm->task))
|
||||
chunk_appendf(&trash, " run(nice=%d)", curr_strm->task->nice);
|
||||
|
||||
chunk_appendf(&trash, "\n");
|
||||
|
||||
if (ci_putchk(cs_ic(cs), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
LIST_APPEND(&curr_strm->back_refs, &ctx->bref.users);
|
||||
goto full;
|
||||
}
|
||||
|
||||
next_sess:
|
||||
ctx->bref.ref = curr_strm->list.n;
|
||||
}
|
||||
|
||||
if (ctx->target && ctx->target != (void *)-1) {
|
||||
/* specified stream not found */
|
||||
if (ctx->section > 0)
|
||||
chunk_appendf(&trash, " *** session terminated while we were watching it ***\n");
|
||||
else
|
||||
chunk_appendf(&trash, "Session not found.\n");
|
||||
|
||||
if (ci_putchk(cs_ic(cs), &trash) == -1)
|
||||
goto full;
|
||||
|
||||
ctx->target = NULL;
|
||||
ctx->uid = 0;
|
||||
goto done;
|
||||
goto next_sess;
|
||||
}
|
||||
|
||||
chunk_appendf(&trash,
|
||||
"%p: proto=%s",
|
||||
curr_strm,
|
||||
strm_li(curr_strm) ? strm_li(curr_strm)->rx.proto->name : "?");
|
||||
|
||||
conn = objt_conn(strm_orig(curr_strm));
|
||||
switch (conn && conn_get_src(conn) ? addr_to_str(conn->src, pn, sizeof(pn)) : AF_UNSPEC) {
|
||||
case AF_INET:
|
||||
case AF_INET6:
|
||||
chunk_appendf(&trash,
|
||||
" src=%s:%d fe=%s be=%s srv=%s",
|
||||
pn,
|
||||
get_host_port(conn->src),
|
||||
strm_fe(curr_strm)->id,
|
||||
(curr_strm->be->cap & PR_CAP_BE) ? curr_strm->be->id : "<NONE>",
|
||||
objt_server(curr_strm->target) ? __objt_server(curr_strm->target)->id : "<none>"
|
||||
);
|
||||
break;
|
||||
case AF_UNIX:
|
||||
chunk_appendf(&trash,
|
||||
" src=unix:%d fe=%s be=%s srv=%s",
|
||||
strm_li(curr_strm)->luid,
|
||||
strm_fe(curr_strm)->id,
|
||||
(curr_strm->be->cap & PR_CAP_BE) ? curr_strm->be->id : "<NONE>",
|
||||
objt_server(curr_strm->target) ? __objt_server(curr_strm->target)->id : "<none>"
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" ts=%02x epoch=%#x age=%s calls=%u rate=%u cpu=%llu lat=%llu",
|
||||
curr_strm->task->state, curr_strm->stream_epoch,
|
||||
human_time(now.tv_sec - curr_strm->logs.tv_accept.tv_sec, 1),
|
||||
curr_strm->task->calls, read_freq_ctr(&curr_strm->call_rate),
|
||||
(unsigned long long)curr_strm->task->cpu_time, (unsigned long long)curr_strm->task->lat_time);
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" rq[f=%06xh,i=%u,an=%02xh,rx=%s",
|
||||
curr_strm->req.flags,
|
||||
(unsigned int)ci_data(&curr_strm->req),
|
||||
curr_strm->req.analysers,
|
||||
curr_strm->req.rex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->req.rex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",wx=%s",
|
||||
curr_strm->req.wex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->req.wex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",ax=%s]",
|
||||
curr_strm->req.analyse_exp ?
|
||||
human_time(TICKS_TO_MS(curr_strm->req.analyse_exp - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" rp[f=%06xh,i=%u,an=%02xh,rx=%s",
|
||||
curr_strm->res.flags,
|
||||
(unsigned int)ci_data(&curr_strm->res),
|
||||
curr_strm->res.analysers,
|
||||
curr_strm->res.rex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->res.rex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",wx=%s",
|
||||
curr_strm->res.wex ?
|
||||
human_time(TICKS_TO_MS(curr_strm->res.wex - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
chunk_appendf(&trash,
|
||||
",ax=%s]",
|
||||
curr_strm->res.analyse_exp ?
|
||||
human_time(TICKS_TO_MS(curr_strm->res.analyse_exp - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
|
||||
conn = cs_conn(curr_strm->csf);
|
||||
chunk_appendf(&trash,
|
||||
" csf=[%d,%1xh,fd=%d]",
|
||||
curr_strm->csf->state,
|
||||
curr_strm->csf->flags,
|
||||
conn_fd(conn));
|
||||
|
||||
conn = cs_conn(curr_strm->csb);
|
||||
chunk_appendf(&trash,
|
||||
" csb=[%d,%1xh,fd=%d]",
|
||||
curr_strm->csb->state,
|
||||
curr_strm->csb->flags,
|
||||
conn_fd(conn));
|
||||
|
||||
chunk_appendf(&trash,
|
||||
" exp=%s rc=%d c_exp=%s",
|
||||
curr_strm->task->expire ?
|
||||
human_time(TICKS_TO_MS(curr_strm->task->expire - now_ms),
|
||||
TICKS_TO_MS(1000)) : "",
|
||||
curr_strm->conn_retries,
|
||||
curr_strm->conn_exp ?
|
||||
human_time(TICKS_TO_MS(curr_strm->conn_exp - now_ms),
|
||||
TICKS_TO_MS(1000)) : "");
|
||||
if (task_in_rq(curr_strm->task))
|
||||
chunk_appendf(&trash, " run(nice=%d)", curr_strm->task->nice);
|
||||
|
||||
chunk_appendf(&trash, "\n");
|
||||
|
||||
if (ci_putchk(cs_ic(cs), &trash) == -1) {
|
||||
/* let's try again later from this stream. We add ourselves into
|
||||
* this stream's users so that it can remove us upon termination.
|
||||
*/
|
||||
LIST_APPEND(&curr_strm->back_refs, &ctx->bref.users);
|
||||
goto full;
|
||||
}
|
||||
|
||||
next_sess:
|
||||
ctx->bref.ref = curr_strm->list.n;
|
||||
}
|
||||
|
||||
if (ctx->target && ctx->target != (void *)-1) {
|
||||
/* specified stream not found */
|
||||
if (ctx->section > 0)
|
||||
chunk_appendf(&trash, " *** session terminated while we were watching it ***\n");
|
||||
else
|
||||
chunk_appendf(&trash, "Session not found.\n");
|
||||
|
||||
if (ci_putchk(cs_ic(cs), &trash) == -1)
|
||||
goto full;
|
||||
|
||||
ctx->target = NULL;
|
||||
ctx->uid = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
thread_release();
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user