diff --git a/include/haproxy/fd-t.h b/include/haproxy/fd-t.h index 5fa3689b4..38e5339f4 100644 --- a/include/haproxy/fd-t.h +++ b/include/haproxy/fd-t.h @@ -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 */ diff --git a/src/ev_epoll.c b/src/ev_epoll.c index e0dd52158..694b538a5 100644 --- a/src/ev_epoll.c +++ b/src/ev_epoll.c @@ -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" */ diff --git a/src/ev_evports.c b/src/ev_evports.c index da2c11060..645f3edb1 100644 --- a/src/ev_evports.c +++ b/src/ev_evports.c @@ -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); diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c index 271e95b67..125f3cd52 100644 --- a/src/ev_kqueue.c +++ b/src/ev_kqueue.c @@ -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);