LIST_NEXT(&px->servers, struct server *, el_px) : NULL;
}
+static inline struct server *proxy_last_server(const struct proxy *px)
+{
+ return !LIST_ISEMPTY(&px->servers) ?
+ LIST_PREV(&px->servers, struct server *, el_px) : NULL;
+}
+
static inline struct server *proxy_next_server(const struct server *srv)
{
if (srv->el_px.n == &srv->proxy->servers)
* or if we are parsing a "server" line and the current peer is not the local one.
*/
parse_addr = (peer || !local_peer) ? SRV_PARSE_PARSE_ADDR : 0;
- prev_srv = proxy_first_server(curpeers->peers_fe);
+ prev_srv = proxy_last_server(curpeers->peers_fe);
err_code |= parse_server(file, linenum, args, curpeers->peers_fe, NULL,
SRV_PARSE_IN_PEER_SECTION|parse_addr|SRV_PARSE_INITIAL_RESOLVE);
- if (prev_srv == proxy_first_server(curpeers->peers_fe)) {
+ if (prev_srv == proxy_last_server(curpeers->peers_fe)) {
/* parse_server didn't add a server:
* Remove the newly allocated peer.
*/
goto out;
}
- srv = proxy_first_server(curpeers->peers_fe);
+ srv = proxy_last_server(curpeers->peers_fe);
if (!parse_addr && bind_addr) {
/* local peer declared using "server": has name but no
{
struct list tmp_list = LIST_HEAD_INIT(tmp_list);
struct bind_conf *bind_conf;
- struct server *newsrv, *newsrv_back;
+ struct server *newsrv;
struct switching_rule *rule;
struct server_rule *srule;
struct sticking_rule *mrule;
break;
}
- /* first, we will invert the servers list order */
- list_for_each_entry_safe(newsrv, newsrv_back, &px->servers, el_px) {
- LIST_DEL_INIT(&newsrv->el_px);
- LIST_INSERT(&tmp_list, &newsrv->el_px);
- }
- LIST_SPLICE(&px->servers, &tmp_list);
-
/* Check that no server name conflicts. This causes trouble in the stats.
* We only emit an error for the first conflict affecting each server,
* in order to avoid combinatory explosion if all servers have the same
srv->obj_type = OBJ_TYPE_SERVER;
srv->proxy = proxy;
+ LIST_APPEND(&proxy->servers, &srv->el_px);
MT_LIST_APPEND(&all_servers, &srv->global_list);
LIST_INIT(&srv->srv_rec_item);
LIST_INIT(&srv->ip_rec_item);
HA_RWLOCK_INIT(&srv->ssl_ctx.lock);
#endif
- // add server to proxy list:
- if (!(proxy->flags & PR_FL_CHECKED)) {
- /* they are linked backwards first during parsing
- * This will be restablished after parsing.
- */
- LIST_INSERT(&proxy->servers, &srv->el_px);
- }
- else {
- // runtime, add the server at the end of the list
- LIST_APPEND(&proxy->servers, &srv->el_px);
- }
-
HA_RWLOCK_INIT(&srv->path_params.param_lock);
return srv;