]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: poller: disable thread-groups for poll() and select()
authorWilly Tarreau <w@1wt.eu>
Sat, 9 Jul 2022 21:38:46 +0000 (23:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 17:43:10 +0000 (19:43 +0200)
These old legacy pollers are not designed for this. They're still
using a shared list of events for all threads, this will not scale at
all, so there's no point in enabling thread-groups there. Modern
systems have epoll, kqueue or event ports and do not need these ones.

We arrange for failing at boot time, only when thread-groups > 1 so
that existing setups will remain unaffected.

If there's a compelling reason for supporting thread groups with these
pollers in the future, the rework should not be too hard, it would just
consume a lot of memory to have an fd_evts[] array per thread, but that
is doable.

src/ev_poll.c
src/ev_select.c
src/haproxy.c

index 3cc41dc687078c48a8370b8553eee424c2974d0a..b25d1dc328b266427aefddd73bc4286afdb8e165 100644 (file)
@@ -264,6 +264,13 @@ static int _do_init(struct poller *p)
        int fd_evts_bytes;
 
        p->private = NULL;
+
+       /* this old poller uses a process-wide FD list that cannot work with
+        * groups.
+        */
+       if (global.nbtgroups > 1)
+               goto fail_srevt;
+
        fd_evts_bytes = (global.maxsock + sizeof(**fd_evts) * 8 - 1) / (sizeof(**fd_evts) * 8) * sizeof(**fd_evts);
 
        if ((fd_evts[DIR_RD] = calloc(1, fd_evts_bytes)) == NULL)
index b3e1b40e6e2c989de544e3dff4a111c7dedfd4ab..af14b2e9e70b7dcbf22e5f642fe6fc3e9c71ba4a 100644 (file)
@@ -247,6 +247,12 @@ static int _do_init(struct poller *p)
 
        p->private = NULL;
 
+       /* this old poller uses a process-wide FD list that cannot work with
+        * groups.
+        */
+       if (global.nbtgroups > 1)
+               goto fail_srevt;
+
        if (global.maxsock > FD_SETSIZE)
                goto fail_srevt;
 
index 513a967f20e7e632722262e6cab86f700b7dd6ea..3f03826a6dedaaa9bd128fdd3841fc7066391e6b 100644 (file)
@@ -2533,7 +2533,8 @@ static void init(int argc, char **argv)
 
        if (!init_pollers()) {
                ha_alert("No polling mechanism available.\n"
-                        "  It is likely that haproxy was built with TARGET=generic and that FD_SETSIZE\n"
+                        "  This may happen when using thread-groups with old pollers (poll/select), or\n"
+                        "  it is possible that haproxy was built with TARGET=generic and that FD_SETSIZE\n"
                         "  is too low on this platform to support maxconn and the number of listeners\n"
                         "  and servers. You should rebuild haproxy specifying your system using TARGET=\n"
                         "  in order to support other polling systems (poll, epoll, kqueue) or reduce the\n"