MINOR: pollers: Add a fixup_tgid_takeover() method.

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.
This commit is contained in:
Olivier Houchard 2025-02-25 18:26:49 +01:00 committed by Olivier Houchard
parent 752c5cba5d
commit c36aae2af1
4 changed files with 28 additions and 0 deletions

View 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 */

View 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" */

View 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);

View 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);