From: Amaury Denoyelle Date: Thu, 10 Nov 2022 14:16:49 +0000 (+0100) Subject: MINOR: server: clear prefix on stderr logs after add server X-Git-Tag: v2.7-dev9~110 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30fc6da148707055fcb6d1670217da6904364d1b;p=thirdparty%2Fhaproxy.git MINOR: server: clear prefix on stderr logs after add server cli_parse_add_server() is the CLI handler for 'add server' command. This functions uses usermsgs_ctx to retrieve logs messages from internal ha_alert() calls and display it at the end of the handler. At the beginning of the handler, stderr prefix is defined to "CLI" via usermsgs_clr() function. However, this is not resetted at the end. This causes inconsistency for stderr output : 1. each ha_alert() invocation will reuse "CLI" prefix if 'add server' command was executed before, even in non-CLI context 2. usermsgs_ctx is thread local, so this is only true if this runs on the same thread as 'add server' handler. To fix this, ensure that "CLI" prefix is now resetted after cli_parse_add_server(). This is done thanks to the addition to cli_umsg()/cli_umsgerr() functions. This can be backported up to 2.5 if we prefer to ensure output consistency at the risk of changing stderr behaviors in stable versions. In this case, the previous commit should be backported before : MINOR: cli: define usermsgs print context --- diff --git a/src/server.c b/src/server.c index 437f3c23ec..3381c8ecad 100644 --- a/src/server.c +++ b/src/server.c @@ -4869,7 +4869,7 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct } ha_notice("New server registered.\n"); - cli_msg(appctx, LOG_INFO, usermsgs_str()); + cli_umsg(appctx, LOG_INFO); return 0; @@ -4900,7 +4900,7 @@ out: thread_release(); if (!usermsgs_empty()) - cli_err(appctx, usermsgs_str()); + cli_umsgerr(appctx); if (srv) srv_drop(srv);