MINOR: server: Make 'default-server' support 'non-stick' keyword.
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 10 Mar 2017 14:50:49 +0000 (15:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 27 Mar 2017 12:36:11 +0000 (14:36 +0200)
This patch makes 'default-server' directive support 'non-stick' setting.
A new keyword 'stick' has been added so that to disable
'non-stick' setting both in 'server' and 'default-server' directives.

src/server.c

index 09f196b..c5a4d31 100644 (file)
@@ -277,6 +277,22 @@ static int srv_parse_no_check_send_proxy(char **args, int *cur_arg,
        return 0;
 }
 
+/* Parse the "non-stick" server keyword */
+static int srv_parse_non_stick(char **args, int *cur_arg,
+                               struct proxy *curproxy, struct server *newsrv, char **err)
+{
+       newsrv->flags |= SRV_F_NON_STICK;
+       return 0;
+}
+
+/* Parse the "stick" server keyword */
+static int srv_parse_stick(char **args, int *cur_arg,
+                           struct proxy *curproxy, struct server *newsrv, char **err)
+{
+       newsrv->flags &= ~SRV_F_NON_STICK;
+       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.
@@ -891,6 +907,8 @@ static struct srv_kw_list srv_kws = { "ALL", { }, {
        { "id",                  srv_parse_id,                  1,  0 }, /* set id# of server */
        { "no-backup",           srv_parse_no_backup,           0,  1 }, /* Flag as non-backup server */
        { "no-check-send-proxy", srv_parse_no_check_send_proxy, 0,  1 }, /* disable PROXY protol for health checks */
+       { "non-stick",           srv_parse_non_stick,           0,  1 }, /* Disable stick-table persistence */
+       { "stick",               srv_parse_stick,               0,  1 }, /* Enable stick-table persistence */
        { NULL, NULL, 0 },
 }};
 
@@ -1542,10 +1560,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], "non-stick")) {
-                               newsrv->flags |= SRV_F_NON_STICK;
-                               cur_arg ++;
-                       }
                        else if (!defsrv && !strcmp(args[cur_arg], "send-proxy")) {
                                newsrv->pp_opts |= SRV_PP_V1;
                                cur_arg ++;