mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-25 04:17:42 +00:00
BUG/MINOR: Handle interactive mode in cli handler
A previous commit broke the interactive stats cli prompt. Specifically, it was not clear that we could be in STAT_CLI_PROMPT when we get to the output functions for the cli handler, and the switch statement did not handle this case. We would then fall through to the default statement, which was recently changed to set error flags on the socket. This in turn causes the socket to be closed, which is not what we wanted in this specific case. To fix, we add a case for STAT_CLI_PROMPT, and simply break out of the switch statement. Testing: - Connected to unix stats socket, issued 'prompt', observed that I could issue multiple consecutive commands. - Connected to unix stats socket, issued 'prompt', observed that socket timed out after inactivity expired. - Connected to unix stats socket, issued 'prompt' then 'set timeout cli 5', observed that socket timed out after 5 seconds expired. - Connected to unix stats socket, issued invalid commands, received usage output. - Connected to unix stats socket, issued 'show info', received info output and socket disconnected. - Connected to unix stats socket, issued 'show stat', received stats output and socket disconnected. - Repeated above tests with TCP stats socket. [wt: no backport needed, this was introduced during the applet rework in 1.6]
This commit is contained in:
parent
a72db18243
commit
e32d1867f6
@ -2480,6 +2480,8 @@ static void cli_io_handler(struct appctx *appctx)
|
||||
}
|
||||
else { /* output functions */
|
||||
switch (appctx->st0) {
|
||||
case STAT_CLI_PROMPT:
|
||||
break;
|
||||
case STAT_CLI_PRINT:
|
||||
if (bi_putstr(si_ic(si), appctx->ctx.cli.msg) != -1)
|
||||
appctx->st0 = STAT_CLI_PROMPT;
|
||||
|
Loading…
Reference in New Issue
Block a user