]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MAJOR: pollers: rely on fd_reregister_all() at boot time
authorWilly Tarreau <w@1wt.eu>
Sat, 9 Jul 2022 21:23:50 +0000 (23:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Jul 2022 18:16:30 +0000 (20:16 +0200)
The poller-specific thread init code now uses that new function to
safely register boot events. This ensures that we don't register an
event for another group and that we properly deal with parallel
thread startup.

It's only done for thread-aware pollers, there's no point in using
that in poll/select though that should work as well.

src/ev_epoll.c
src/ev_evports.c
src/ev_kqueue.c

index 77ac0c06777723cbf0ce2983306f36b90007c96e..7be659bc1f7309b9edd5b5b94c23acf9798fdfb6 100644 (file)
@@ -250,8 +250,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
 
 static int init_epoll_per_thread()
 {
-       int fd;
-
        epoll_events = calloc(1, sizeof(struct epoll_event) * global.tune.maxpollevents);
        if (epoll_events == NULL)
                goto fail_alloc;
@@ -267,8 +265,7 @@ static int init_epoll_per_thread()
         * fd for this thread. Let's just mark them as updated, the poller will
         * do the rest.
         */
-       for (fd = 0; fd < global.maxsock; fd++)
-               updt_fd_polling(fd);
+       fd_reregister_all(tgid, ti->ltid_bit);
 
        return 1;
  fail_fd:
index 06e7a01c619f62bc2b9b7ab13cd4ad50ec008a26..79854702a65acaa696c1e7610f4402d8444c8a02 100644 (file)
@@ -279,8 +279,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
 
 static int init_evports_per_thread()
 {
-       int fd;
-
        evports_evlist_max = global.tune.maxpollevents;
        evports_evlist = calloc(evports_evlist_max, sizeof(*evports_evlist));
        if (evports_evlist == NULL) {
@@ -298,8 +296,7 @@ static int init_evports_per_thread()
         * fd for this thread. Let's just mark them as updated, the poller will
         * do the rest.
         */
-       for (fd = 0; fd < global.maxsock; fd++)
-               updt_fd_polling(fd);
+       fd_reregister_all(tgid, ti->ltid_bit);
 
        return 1;
 
index c37d99b1ad0dbc3e0cb68ca52daf5743f546350b..53bda1fe2c156ca43ff3c74bc9adca627dba6ea9 100644 (file)
@@ -205,8 +205,6 @@ static void _do_poll(struct poller *p, int exp, int wake)
 
 static int init_kqueue_per_thread()
 {
-       int fd;
-
        /* we can have up to two events per fd, so allocate enough to store
         * 2*fd event, and an extra one, in case EV_RECEIPT isn't defined,
         * so that we can add an invalid entry and get an error, to avoid
@@ -227,8 +225,7 @@ static int init_kqueue_per_thread()
         * fd for this thread. Let's just mark them as updated, the poller will
         * do the rest.
         */
-       for (fd = 0; fd < global.maxsock; fd++)
-               updt_fd_polling(fd);
+       fd_reregister_all(tgid, ti->ltid_bit);
 
        return 1;
  fail_fd: