]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http/conf: store the use_backend configuration file and line for logs
authorThierry FOURNIER / OZON.IO <thierry.fournier@ozon.io>
Thu, 24 Nov 2016 22:57:54 +0000 (23:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Nov 2016 06:15:09 +0000 (07:15 +0100)
The error log of the directive use_backend doesn't provide the
file and line containing the declaration. This patch stores
theses informations.

include/types/arg.h
include/types/proxy.h
src/cfgparse.c
src/haproxy.c
src/log.c

index 7576f8ac3f1d8b1e34398ca9d8ee1fcb69767dc2..651164b2db5d571dc5f949d2ee2d859401a313d7 100644 (file)
@@ -77,6 +77,7 @@ enum {
        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 */
index 27aa157406babefda8c721bf2e22eacad87bd055..0b194cb731b9e79607a119dd808919ef2de51989 100644 (file)
@@ -446,6 +446,8 @@ struct switching_rule {
                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 {
index 40fd7da76f0de1b57e2e40cee895b06dc7673361..db1641e98c98e7fb88ca19d362c0b87d68d951f8 100644 (file)
@@ -4018,6 +4018,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                }
                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 @@ int check_config_validity()
                         */
                        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;
index 728c8e5b4d56cfa0a761cbf22a531b99798fc76a..5d7d410bc1b71f926dce1cadcf2ec2d9c6bf8c18 100644 (file)
@@ -1482,6 +1482,7 @@ void deinit(void)
                        if (rule->cond) {
                                prune_acl_cond(rule->cond);
                                free(rule->cond);
+                               free(rule->file);
                        }
                        free(rule);
                }
index 5fc68cef95a32d8a5cb6cdb768b185f48a4cf9a8..9ec89b2b35caf2a1eb8260cc3e6700c4eb6ce8a2 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -269,6 +269,8 @@ static inline const char *fmt_directive(const struct proxy *curproxy)
                return "server";
        case ARGC_SPOE:
                return "spoe-message";
+       case ARGC_UBK:
+               return "use_backend";
        default:
                return "undefined(please report this bug)"; /* must never happen */
        }