MINOR: cli/wait: also support an unrecoverable failure status

Since we'll support waiting for an action to succeed or permanently
fail, we need the ability to return an unrecoverable failure. Let's
add CLI_WAIT_ERR_FAIL for this. A static error message may be placed
into ctx->msg to report to the user why the failure is unrecoverable.
This commit is contained in:
Willy Tarreau 2024-02-09 20:05:14 +01:00
parent d8731c6680
commit 2673f8be82
2 changed files with 3 additions and 0 deletions

View File

@ -90,6 +90,7 @@ enum cli_wait_err {
CLI_WAIT_ERR_DONE, // condition satisfied CLI_WAIT_ERR_DONE, // condition satisfied
CLI_WAIT_ERR_INTR, // interrupted CLI_WAIT_ERR_INTR, // interrupted
CLI_WAIT_ERR_EXP, // finished on wait expiration CLI_WAIT_ERR_EXP, // finished on wait expiration
CLI_WAIT_ERR_FAIL, // finished early (unrecoverable)
}; };
enum cli_wait_cond { enum cli_wait_cond {
@ -100,6 +101,7 @@ struct cli_wait_ctx {
uint start, deadline; // both are in ticks. uint start, deadline; // both are in ticks.
enum cli_wait_cond cond; // CLI_WAIT_COND_* enum cli_wait_cond cond; // CLI_WAIT_COND_*
enum cli_wait_err error; // CLI_WAIT_ERR_* enum cli_wait_err error; // CLI_WAIT_ERR_*
const char *msg; // static error message for failures if not NULL
}; };
struct cli_kw { struct cli_kw {

View File

@ -2120,6 +2120,7 @@ static void cli_release_wait(struct appctx *appctx)
switch (ctx->error) { switch (ctx->error) {
case CLI_WAIT_ERR_EXP: msg = "Wait delay expired.\n"; break; case CLI_WAIT_ERR_EXP: msg = "Wait delay expired.\n"; break;
case CLI_WAIT_ERR_INTR: msg = "Interrupted.\n"; break; case CLI_WAIT_ERR_INTR: msg = "Interrupted.\n"; break;
case CLI_WAIT_ERR_FAIL: msg = ctx->msg ? ctx->msg : "Failed.\n"; break;
default: msg = "Done.\n"; break; default: msg = "Done.\n"; break;
} }