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.
diff --git a/include/types/arg.h b/include/types/arg.h
index 7576f8a..651164b 100644
--- a/include/types/arg.h
+++ b/include/types/arg.h
@@ -77,6 +77,7 @@
ARGC_CAP, /* capture rule */
ARGC_SRV, /* server line */
ARGC_SPOE, /* spoe message args */
+ ARGC_UBK, /* use_backend message */
};
/* flags used when compiling and executing regex */
diff --git a/include/types/proxy.h b/include/types/proxy.h
index 27aa157..0b194cb 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -446,6 +446,8 @@
char *name; /* target backend name during config parsing */
struct list expr; /* logformat expression to use for dynamic rules */
} be;
+ char *file;
+ int line;
};
struct server_rule {
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 40fd7da..db1641e 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -4018,6 +4018,12 @@
}
rule->cond = cond;
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_ADDQ(&curproxy->switching_rules, &rule->list);
}
@@ -7792,6 +7798,9 @@
*/
pxname = rule->be.name;
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)) {
cfgerr++;
continue;
diff --git a/src/haproxy.c b/src/haproxy.c
index 728c8e5..5d7d410 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1482,6 +1482,7 @@
if (rule->cond) {
prune_acl_cond(rule->cond);
free(rule->cond);
+ free(rule->file);
}
free(rule);
}
diff --git a/src/log.c b/src/log.c
index 5fc68ce..9ec89b2 100644
--- a/src/log.c
+++ b/src/log.c
@@ -269,6 +269,8 @@
return "server";
case ARGC_SPOE:
return "spoe-message";
+ case ARGC_UBK:
+ return "use_backend";
default:
return "undefined(please report this bug)"; /* must never happen */
}