mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-26 06:32:13 +00:00
CLEANUP: peers/cli: remove unneeded state STATE_INIT
All the settings in this initial state are konwn at parsing time, there's no need for an initial state to bootstrap other ones.
This commit is contained in:
parent
3a31e37518
commit
ce9123c005
21
src/peers.c
21
src/peers.c
@ -3706,8 +3706,7 @@ struct show_peers_ctx {
|
||||
struct peer *peer; /* "peer" being currently dumped. */
|
||||
int flags; /* non-zero if "dict" dump requested */
|
||||
enum {
|
||||
STATE_INIT = 0, /* initialization */
|
||||
STATE_HEAD, /* dump the section's header */
|
||||
STATE_HEAD = 0, /* dump the section's header */
|
||||
STATE_PEER, /* dump the whole peer */
|
||||
STATE_DONE, /* finished */
|
||||
} state; /* parser's state */
|
||||
@ -3743,6 +3742,8 @@ static int cli_parse_show_peers(char **args, char *payload, struct appctx *appct
|
||||
return cli_err(appctx, "No such peers\n");
|
||||
}
|
||||
|
||||
/* where to start from */
|
||||
ctx->peers = ctx->target ? ctx->target : cfg_peers;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3943,26 +3944,14 @@ static int peers_dump_peer(struct buffer *msg, struct conn_stream *cs, struct pe
|
||||
static int cli_io_handler_show_peers(struct appctx *appctx)
|
||||
{
|
||||
struct show_peers_ctx *ctx = appctx->svcctx;
|
||||
int show_all;
|
||||
int ret = 0, first_peers = 1;
|
||||
|
||||
thread_isolate();
|
||||
|
||||
show_all = !ctx->target;
|
||||
|
||||
chunk_reset(&trash);
|
||||
|
||||
while (ctx->state != STATE_DONE) {
|
||||
switch (ctx->state) {
|
||||
case STATE_INIT:
|
||||
if (show_all)
|
||||
ctx->peers = cfg_peers;
|
||||
else
|
||||
ctx->peers = ctx->target;
|
||||
|
||||
ctx->state = STATE_HEAD;
|
||||
/* fall through */
|
||||
|
||||
case STATE_HEAD:
|
||||
if (!ctx->peers) {
|
||||
/* No more peers list. */
|
||||
@ -3985,8 +3974,8 @@ static int cli_io_handler_show_peers(struct appctx *appctx)
|
||||
case STATE_PEER:
|
||||
if (!ctx->peer) {
|
||||
/* End of peer list */
|
||||
if (show_all)
|
||||
ctx->state = STATE_HEAD;
|
||||
if (!ctx->target)
|
||||
ctx->state = STATE_HEAD; // next one
|
||||
else
|
||||
ctx->state = STATE_DONE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user