MINOR: server: Make 'default-server' support 'backup' keyword.

At this time, only 'server' supported 'backup' keyword.
This patch makes also 'default-server' directive support this keyword.
A new keyword 'no-backup' has been added so that to disable 'backup' setting
both in 'server' and 'default-server' directives.

For instance, provided the following sequence of directives:

default-server backup
server srv1
server srv2 no-backup

default-server no-backup
server srv3
server srv4 backup

srv1 and srv4 are declared as backup servers,
srv2 and srv3 are declared as non-backup servers.
This commit is contained in:
Frdric Lcaille 2017-03-10 11:51:05 +01:00 committed by Willy Tarreau
parent 8065b6d4f2
commit f5bf903be6

View File

@ -213,6 +213,14 @@ void srv_dump_kws(char **out)
}
}
/* Parse the "backup" server keyword */
static int srv_parse_backup(char **args, int *cur_arg,
struct proxy *curproxy, struct server *newsrv, char **err)
{
newsrv->flags |= SRV_F_BACKUP;
return 0;
}
/* parse the "id" server keyword */
static int srv_parse_id(char **args, int *cur_arg, struct proxy *curproxy, struct server *newsrv, char **err)
{
@ -245,6 +253,14 @@ static int srv_parse_id(char **args, int *cur_arg, struct proxy *curproxy, struc
return 0;
}
/* Parse the "no-backup" server keyword */
static int srv_parse_no_backup(char **args, int *cur_arg,
struct proxy *curproxy, struct server *newsrv, char **err)
{
newsrv->flags &= ~SRV_F_BACKUP;
return 0;
}
/* Shutdown all connections of a server. The caller must pass a termination
* code in <why>, which must be one of SF_ERR_* indicating the reason for the
* shutdown.
@ -854,7 +870,9 @@ void srv_compute_all_admin_states(struct proxy *px)
* not enabled.
*/
static struct srv_kw_list srv_kws = { "ALL", { }, {
{ "backup", srv_parse_backup, 0, 1 }, /* Flag as backup server */
{ "id", srv_parse_id, 1, 0 }, /* set id# of server */
{ "no-backup", srv_parse_no_backup, 0, 1 }, /* Flag as non-backup server */
{ NULL, NULL, 0 },
}};
@ -1145,6 +1163,8 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
newsrv->use_ssl = curproxy->defsrv.use_ssl;
newsrv->check.use_ssl = curproxy->defsrv.check.use_ssl;
newsrv->check.port = curproxy->defsrv.check.port;
/* Note: 'flags' field has potentially been already initialized. */
newsrv->flags |= curproxy->defsrv.flags;
if (newsrv->check.port)
newsrv->flags |= SRV_F_CHECKPORT;
newsrv->check.inter = curproxy->defsrv.check.inter;
@ -1503,10 +1523,6 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
newsrv->flags |= SRV_F_CHECKPORT;
cur_arg += 2;
}
else if (!defsrv && !strcmp(args[cur_arg], "backup")) {
newsrv->flags |= SRV_F_BACKUP;
cur_arg ++;
}
else if (!defsrv && !strcmp(args[cur_arg], "non-stick")) {
newsrv->flags |= SRV_F_NON_STICK;
cur_arg ++;