]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: always reset the applet task's timeout
authorWilly Tarreau <w@1wt.eu>
Thu, 8 Feb 2024 19:53:31 +0000 (20:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 8 Feb 2024 19:53:31 +0000 (20:53 +0100)
The CLI applet doesn't make use of its timeout at all, only the stream
does. That's a wonder because it allows any command's I/O handler to
trivially set a wakeup timer by simply touching the task's ->expire
field, and the I/O handler will automatically be woken up again. The
only condition for this is that we properly take care of clearing that
timeout whenever we finish processing a command and switch back to the
PROMPT state. That's what this patch does.

src/cli.c

index cbfec88dfe1e6c2ffe6d82c2db9c1559564e26fb..1546c0d7cd3bc010948776ba766a300d7f9d3979 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1027,6 +1027,7 @@ static void cli_io_handler(struct appctx *appctx)
                                appctx->chunk->data++;
                        }
 
+                       appctx->t->expire = TICK_ETERNITY;
                        appctx->st0 = CLI_ST_PROMPT;
 
                        if (appctx->st1 & APPCTX_CLI_ST1_PAYLOAD) {
@@ -1139,6 +1140,7 @@ static void cli_io_handler(struct appctx *appctx)
                                                 appctx->st0 == CLI_ST_PRINT_UMSGERR) {
                                                usermsgs_clr(NULL);
                                        }
+                                       appctx->t->expire = TICK_ETERNITY;
                                        appctx->st0 = CLI_ST_PROMPT;
                                }
                                break;
@@ -1146,6 +1148,7 @@ static void cli_io_handler(struct appctx *appctx)
                        case CLI_ST_CALLBACK: /* use custom pointer */
                                if (appctx->io_handler)
                                        if (appctx->io_handler(appctx)) {
+                                               appctx->t->expire = TICK_ETERNITY;
                                                appctx->st0 = CLI_ST_PROMPT;
                                                if (appctx->io_release) {
                                                        appctx->io_release(appctx);