mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-10 03:38:01 +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. */
|
struct peer *peer; /* "peer" being currently dumped. */
|
||||||
int flags; /* non-zero if "dict" dump requested */
|
int flags; /* non-zero if "dict" dump requested */
|
||||||
enum {
|
enum {
|
||||||
STATE_INIT = 0, /* initialization */
|
STATE_HEAD = 0, /* dump the section's header */
|
||||||
STATE_HEAD, /* dump the section's header */
|
|
||||||
STATE_PEER, /* dump the whole peer */
|
STATE_PEER, /* dump the whole peer */
|
||||||
STATE_DONE, /* finished */
|
STATE_DONE, /* finished */
|
||||||
} state; /* parser's state */
|
} 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");
|
return cli_err(appctx, "No such peers\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* where to start from */
|
||||||
|
ctx->peers = ctx->target ? ctx->target : cfg_peers;
|
||||||
return 0;
|
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)
|
static int cli_io_handler_show_peers(struct appctx *appctx)
|
||||||
{
|
{
|
||||||
struct show_peers_ctx *ctx = appctx->svcctx;
|
struct show_peers_ctx *ctx = appctx->svcctx;
|
||||||
int show_all;
|
|
||||||
int ret = 0, first_peers = 1;
|
int ret = 0, first_peers = 1;
|
||||||
|
|
||||||
thread_isolate();
|
thread_isolate();
|
||||||
|
|
||||||
show_all = !ctx->target;
|
|
||||||
|
|
||||||
chunk_reset(&trash);
|
chunk_reset(&trash);
|
||||||
|
|
||||||
while (ctx->state != STATE_DONE) {
|
while (ctx->state != STATE_DONE) {
|
||||||
switch (ctx->state) {
|
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:
|
case STATE_HEAD:
|
||||||
if (!ctx->peers) {
|
if (!ctx->peers) {
|
||||||
/* No more peers list. */
|
/* No more peers list. */
|
||||||
@ -3985,8 +3974,8 @@ static int cli_io_handler_show_peers(struct appctx *appctx)
|
|||||||
case STATE_PEER:
|
case STATE_PEER:
|
||||||
if (!ctx->peer) {
|
if (!ctx->peer) {
|
||||||
/* End of peer list */
|
/* End of peer list */
|
||||||
if (show_all)
|
if (!ctx->target)
|
||||||
ctx->state = STATE_HEAD;
|
ctx->state = STATE_HEAD; // next one
|
||||||
else
|
else
|
||||||
ctx->state = STATE_DONE;
|
ctx->state = STATE_DONE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user