]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pollers: Add a fixup_tgid_takeover() method.
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 25 Feb 2025 17:26:49 +0000 (18:26 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 26 Feb 2025 12:00:18 +0000 (13:00 +0100)
Add a fixup_tgid_takeover() method to pollers for which it makes sense
(epoll, kqueue and evport). That method can be called after a takeover
of a fd from a different thread group, to make sure the poller's
internal structure reflects the new state.

include/haproxy/fd-t.h
src/ev_epoll.c
src/ev_evports.c
src/ev_kqueue.c

index 5fa3689b4404a6ca0777e5a8370378be1ee6cb70..38e5339f44f25e59da65bab327b21d44147f52ac 100644 (file)
@@ -242,6 +242,7 @@ struct poller {
        void   (*term)(struct poller *p);            /* termination of this poller */
        int    (*test)(struct poller *p);            /* pre-init check of the poller */
        int    (*fork)(struct poller *p);            /* post-fork re-opening */
+       void   (*fixup_tgid_takeover)(struct poller *p, const int fd, const int old_tid, const int old_tgid); /* Fixup anything necessary after a FD takeover across tgids */
        const char   *name;                                  /* poller name */
        unsigned int flags;                                  /* HAP_POLL_F_* */
        int    pref;                                         /* try pollers with higher preference first */
index e0dd52158e2d510cbf5798f783d5801ccbf46954..694b538a5cfc15218682f75b80e6d30a983f4680 100644 (file)
@@ -69,6 +69,14 @@ static void __fd_clo(int fd)
        }
 }
 
+static void _do_fixup_tgid_takeover(struct poller *poller, const int fd, const int old_ltid, const int old_tgid)
+{
+
+       polled_mask[fd].poll_recv = 0;
+       polled_mask[fd].poll_send = 0;
+       fdtab[fd].update_mask = 0;
+}
+
 static void _update_fd(int fd)
 {
        int en, opcode;
@@ -463,6 +471,7 @@ static void _do_register(void)
        p->term = _do_term;
        p->poll = _do_poll;
        p->fork = _do_fork;
+       p->fixup_tgid_takeover = _do_fixup_tgid_takeover;
 }
 
 /* config parser for global "tune.epoll.mask-events", accepts "err", "hup", "rdhup" */
index da2c11060d397a7c30cadd432f97795b5b5d0dd6..645f3edb1213e577fa45a916aa574092dd5835da 100644 (file)
@@ -105,6 +105,14 @@ static void _update_fd(int fd)
        evports_resync_fd(fd, events);
 }
 
+static void _do_fixup_tgid_takeover(struct poller *poller, const int fd, const int old_ltid, const int old_tgid)
+{
+
+       polled_mask[fd].poll_recv = 0;
+       polled_mask[fd].poll_send = 0;
+       fdtab[fd].update_mask = 0;
+}
+
 /*
  * Event Ports poller.  This routine interacts with the file descriptor
  * management data structures and routines; see the large block comment in
@@ -450,6 +458,7 @@ static void _do_register(void)
        p->term = _do_term;
        p->poll = _do_poll;
        p->fork = _do_fork;
+       p->fixup_tgid_takeover = _do_fixup_tgid_takeover;
 }
 
 INITCALL0(STG_REGISTER, _do_register);
index 271e95b672c0e2778ca4ef55ef84c2f388b2ed91..125f3cd52fe0426f672ebcb688ea4fd54772fe1b 100644 (file)
@@ -84,6 +84,14 @@ static int _update_fd(int fd, int start)
        return changes;
 }
 
+static void _do_fixup_tgid_takeover(struct poller *poller, const int fd, const int old_ltid, const int old_tgid)
+{
+
+       polled_mask[fd].poll_recv = 0;
+       polled_mask[fd].poll_send = 0;
+       fdtab[fd].update_mask = 0;
+}
+
 /*
  * kqueue() poller
  */
@@ -368,6 +376,7 @@ static void _do_register(void)
        p->term = _do_term;
        p->poll = _do_poll;
        p->fork = _do_fork;
+       p->fixup_tgid_takeover = _do_fixup_tgid_takeover;
 }
 
 INITCALL0(STG_REGISTER, _do_register);