]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: peers: call bind_complete_thread_setup() to finish the config
authorWilly Tarreau <w@1wt.eu>
Sat, 22 Apr 2023 21:52:17 +0000 (23:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 23 Apr 2023 07:46:15 +0000 (09:46 +0200)
The listeners in peers sections were still not handing the thread
groups fine. Shards were silently ignored and if a listener was bound
to more than one group, it would simply fail. Now we can call the
dedicated function to resolve all this and possibly create the missing
extra listeners.

bind_complete_thread_setup() was adjusted to use the proxy_type_str()
instead of writing "proxy" at the only place where this word was still
hard-coded so that we continue to speak about peers sections when
relevant.

src/cfgparse.c
src/listener.c

index 6a9d42d6514c4e2b9f288d2dffeaa557d89dae21..2472a215982b597df1dbf118c4cede73565aff58 100644 (file)
@@ -4385,7 +4385,7 @@ init_proxies_list_stage2:
                                if (!LIST_ISEMPTY(&curpeers->peers_fe->conf.bind)) {
                                        struct list *l;
                                        struct bind_conf *bind_conf;
-                                       struct listener *li;
+                                       int ret;
 
                                        l = &curpeers->peers_fe->conf.bind;
                                        bind_conf = LIST_ELEM(l->n, typeof(bind_conf), by_fe);
@@ -4401,23 +4401,12 @@ init_proxies_list_stage2:
                                                }
                                        }
 
-                                       err = NULL;
-                                       if (thread_resolve_group_mask(&bind_conf->thread_set, 1, &err) < 0) {
-                                               ha_alert("Peers section '%s': %s in 'bind %s' at [%s:%d].\n",
-                                                        curpeers->peers_fe->id, err, bind_conf->arg, bind_conf->file, bind_conf->line);
-                                               free(err);
-                                               cfgerr++;
-                                       }
-                                       else if (atleast2(bind_conf->thread_set.grps)) {
-                                               ha_alert("Peers section '%s': 'thread' spans more than one group in 'bind %s' at [%s:%d].\n",
-                                                        curpeers->peers_fe->id, bind_conf->arg, bind_conf->file, bind_conf->line);
-                                               cfgerr++;
-                                       }
-
-                                       /* apply thread masks and groups to all receivers */
-                                       list_for_each_entry(li, &bind_conf->listeners, by_bind) {
-                                               li->rx.bind_thread = thread_set_nth_tmask(&bind_conf->thread_set, 0);
-                                               li->rx.bind_tgroup = thread_set_nth_group(&bind_conf->thread_set, 0);
+                                       /* finish the bind setup */
+                                       ret = bind_complete_thread_setup(bind_conf, &err_code);
+                                       if (ret != 0) {
+                                               cfgerr += ret;
+                                               if (err_code & ERR_FATAL)
+                                                       goto out;
                                        }
 
                                        if (bind_conf->xprt->prepare_bind_conf &&
index 67b64f69b2f944aaf59b5087f1fad1e902fc0df1..8a3aa7caf89dca8c14b988ecba499100c4ef38b0 100644 (file)
@@ -1654,7 +1654,8 @@ int bind_complete_thread_setup(struct bind_conf *bind_conf, int *err_code)
 
        err = NULL;
        if (thread_resolve_group_mask(&bind_conf->thread_set, (fe == global.cli_fe) ? 1 : 0, &err) < 0) {
-               ha_alert("Proxy '%s': %s in 'bind %s' at [%s:%d].\n",
+               ha_alert("%s '%s': %s in 'bind %s' at [%s:%d].\n",
+                        proxy_type_str(fe),
                         fe->id, err, bind_conf->arg, bind_conf->file, bind_conf->line);
                free(err);
                cfgerr++;