]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: server: attach servers in parse_server
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 8 Mar 2021 15:35:54 +0000 (16:35 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 18 Mar 2021 14:37:05 +0000 (15:37 +0100)
Move server linked into proxy backend list outside of _srv_parse_init to
parse_server.

This is groundwork for dynamic servers support. There will be two
differences in case of a dynamic server :
- the server will be attached to the proxy list only at the very end of the
  operations when everything is ok
- the server will be directly attached to the end of the server proxy
  list

src/server.c

index 3fa384584f2e4f25ff8e67322298edcdbfa7494f..cbeae85d1a3e01b0ef50a10d2a3d316ac9203634 100644 (file)
@@ -2405,9 +2405,6 @@ static int _srv_parse_init(struct server **srv, char **args, int *cur_arg, struc
                                newsrv->tmpl_info.nb_high = tmpl_range_high;
                        }
 
-                       /* the servers are linked backwards first */
-                       newsrv->next = curproxy->srv;
-                       curproxy->srv = newsrv;
                        /* Note: for a server template, its id is its prefix.
                         * This is a temporary id which will be used for server allocations to come
                         * after parsing.
@@ -2648,6 +2645,12 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
                        free(errmsg);
                }
 
+               /* the servers are linked backwards first */
+               if (newsrv && !defsrv) {
+                       newsrv->next = curproxy->srv;
+                       curproxy->srv = newsrv;
+               }
+
                if (err_code & ERR_CODE)
                        goto out;
 
@@ -2683,6 +2686,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
                if (srv_tmpl)
                        _srv_parse_tmpl_init(newsrv, curproxy);
        }
+
        return 0;
 
  out: