From 67e0e61316e5a7cd2ff53f6806a5203f3f4f0a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Tue, 14 Mar 2017 15:21:31 +0100 Subject: [PATCH] MINOR: server: Make 'default-server' support 'track' setting. Before this patch only 'server' directives could support 'track' setting. This patch makes 'default-server' directives also support this setting. Should not break anything. --- src/server.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/server.c b/src/server.c index e3a5b256e..78b1dc7a9 100644 --- a/src/server.c +++ b/src/server.c @@ -353,6 +353,24 @@ static int srv_parse_stick(char **args, int *cur_arg, return 0; } +/* Parse the "track" server keyword */ +static int srv_parse_track(char **args, int *cur_arg, + struct proxy *curproxy, struct server *newsrv, char **err) +{ + char *arg; + + arg = args[*cur_arg + 1]; + if (!*arg) { + memprintf(err, "'track' expects [/] as argument.\n"); + return ERR_ALERT | ERR_FATAL; + } + + free(newsrv->trackit); + newsrv->trackit = strdup(arg); + + return 0; +} + /* Shutdown all connections of a server. The caller must pass a termination * code in , which must be one of SF_ERR_* indicating the reason for the * shutdown. @@ -975,6 +993,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, { { "send-proxy", srv_parse_send_proxy, 0, 1 }, /* Enforce use of PROXY V1 protocol */ { "send-proxy-v2", srv_parse_send_proxy_v2, 0, 1 }, /* Enforce use of PROXY V2 protocol */ { "stick", srv_parse_stick, 0, 1 }, /* Enable stick-table persistence */ + { "track", srv_parse_track, 1, 1 }, /* Set the current state of the server, tracking another one */ { NULL, NULL, 0 }, }}; @@ -1288,6 +1307,8 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr newsrv->onerror = curproxy->defsrv.onerror; newsrv->onmarkeddown = curproxy->defsrv.onmarkeddown; newsrv->onmarkedup = curproxy->defsrv.onmarkedup; + if (curproxy->defsrv.trackit != NULL) + newsrv->trackit = strdup(curproxy->defsrv.trackit); newsrv->consecutive_errors_limit = curproxy->defsrv.consecutive_errors_limit; newsrv->uweight = newsrv->iweight @@ -1669,19 +1690,6 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr newsrv->slowstart = (val + 999) / 1000; cur_arg += 2; } - else if (!defsrv && !strcmp(args[cur_arg], "track")) { - - if (!*args[cur_arg + 1]) { - Alert("parsing [%s:%d]: 'track' expects [/] as argument.\n", - file, linenum); - err_code |= ERR_ALERT | ERR_FATAL; - goto out; - } - - newsrv->trackit = strdup(args[cur_arg + 1]); - - cur_arg += 2; - } else if (!defsrv && !strcmp(args[cur_arg], "disabled")) { newsrv->admin |= SRV_ADMF_CMAINT; newsrv->admin |= SRV_ADMF_FMAINT;