MINOR: http/conf: store the use_backend configuration file and line for logs

The error log of the directive use_backend doesn't provide the
file and line containing the declaration. This patch stores
theses informations.
This commit is contained in:
Thierry FOURNIER / OZON.IO 2016-11-24 23:57:54 +01:00 committed by Willy Tarreau
parent 5948b01149
commit 4ed1c9585d
5 changed files with 15 additions and 0 deletions

View File

@ -77,6 +77,7 @@ enum {
ARGC_CAP, /* capture rule */ ARGC_CAP, /* capture rule */
ARGC_SRV, /* server line */ ARGC_SRV, /* server line */
ARGC_SPOE, /* spoe message args */ ARGC_SPOE, /* spoe message args */
ARGC_UBK, /* use_backend message */
}; };
/* flags used when compiling and executing regex */ /* flags used when compiling and executing regex */

View File

@ -446,6 +446,8 @@ struct switching_rule {
char *name; /* target backend name during config parsing */ char *name; /* target backend name during config parsing */
struct list expr; /* logformat expression to use for dynamic rules */ struct list expr; /* logformat expression to use for dynamic rules */
} be; } be;
char *file;
int line;
}; };
struct server_rule { struct server_rule {

View File

@ -4018,6 +4018,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
rule->cond = cond; rule->cond = cond;
rule->be.name = strdup(args[1]); rule->be.name = strdup(args[1]);
rule->line = linenum;
rule->file = strdup(file);
if (!rule->file) {
Alert("Out of memory error.\n");
goto out;
}
LIST_INIT(&rule->list); LIST_INIT(&rule->list);
LIST_ADDQ(&curproxy->switching_rules, &rule->list); LIST_ADDQ(&curproxy->switching_rules, &rule->list);
} }
@ -7792,6 +7798,9 @@ int check_config_validity()
*/ */
pxname = rule->be.name; pxname = rule->be.name;
LIST_INIT(&rule->be.expr); LIST_INIT(&rule->be.expr);
curproxy->conf.args.ctx = ARGC_UBK;
curproxy->conf.args.file = rule->file;
curproxy->conf.args.line = rule->line;
if (!parse_logformat_string(pxname, curproxy, &rule->be.expr, 0, SMP_VAL_FE_HRQ_HDR)) { if (!parse_logformat_string(pxname, curproxy, &rule->be.expr, 0, SMP_VAL_FE_HRQ_HDR)) {
cfgerr++; cfgerr++;
continue; continue;

View File

@ -1482,6 +1482,7 @@ void deinit(void)
if (rule->cond) { if (rule->cond) {
prune_acl_cond(rule->cond); prune_acl_cond(rule->cond);
free(rule->cond); free(rule->cond);
free(rule->file);
} }
free(rule); free(rule);
} }

View File

@ -269,6 +269,8 @@ static inline const char *fmt_directive(const struct proxy *curproxy)
return "server"; return "server";
case ARGC_SPOE: case ARGC_SPOE:
return "spoe-message"; return "spoe-message";
case ARGC_UBK:
return "use_backend";
default: default:
return "undefined(please report this bug)"; /* must never happen */ return "undefined(please report this bug)"; /* must never happen */
} }