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:
parent
752c5cba5d
commit
c36aae2af1
@ -242,6 +242,7 @@ struct poller {
|
|||||||
void (*term)(struct poller *p); /* termination of this poller */
|
void (*term)(struct poller *p); /* termination of this poller */
|
||||||
int (*test)(struct poller *p); /* pre-init check of the poller */
|
int (*test)(struct poller *p); /* pre-init check of the poller */
|
||||||
int (*fork)(struct poller *p); /* post-fork re-opening */
|
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 */
|
const char *name; /* poller name */
|
||||||
unsigned int flags; /* HAP_POLL_F_* */
|
unsigned int flags; /* HAP_POLL_F_* */
|
||||||
int pref; /* try pollers with higher preference first */
|
int pref; /* try pollers with higher preference first */
|
||||||
|
@ -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)
|
static void _update_fd(int fd)
|
||||||
{
|
{
|
||||||
int en, opcode;
|
int en, opcode;
|
||||||
@ -463,6 +471,7 @@ static void _do_register(void)
|
|||||||
p->term = _do_term;
|
p->term = _do_term;
|
||||||
p->poll = _do_poll;
|
p->poll = _do_poll;
|
||||||
p->fork = _do_fork;
|
p->fork = _do_fork;
|
||||||
|
p->fixup_tgid_takeover = _do_fixup_tgid_takeover;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* config parser for global "tune.epoll.mask-events", accepts "err", "hup", "rdhup" */
|
/* config parser for global "tune.epoll.mask-events", accepts "err", "hup", "rdhup" */
|
||||||
|
@ -105,6 +105,14 @@ static void _update_fd(int fd)
|
|||||||
evports_resync_fd(fd, events);
|
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
|
* Event Ports poller. This routine interacts with the file descriptor
|
||||||
* management data structures and routines; see the large block comment in
|
* 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->term = _do_term;
|
||||||
p->poll = _do_poll;
|
p->poll = _do_poll;
|
||||||
p->fork = _do_fork;
|
p->fork = _do_fork;
|
||||||
|
p->fixup_tgid_takeover = _do_fixup_tgid_takeover;
|
||||||
}
|
}
|
||||||
|
|
||||||
INITCALL0(STG_REGISTER, _do_register);
|
INITCALL0(STG_REGISTER, _do_register);
|
||||||
|
@ -84,6 +84,14 @@ static int _update_fd(int fd, int start)
|
|||||||
return changes;
|
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
|
* kqueue() poller
|
||||||
*/
|
*/
|
||||||
@ -368,6 +376,7 @@ static void _do_register(void)
|
|||||||
p->term = _do_term;
|
p->term = _do_term;
|
||||||
p->poll = _do_poll;
|
p->poll = _do_poll;
|
||||||
p->fork = _do_fork;
|
p->fork = _do_fork;
|
||||||
|
p->fixup_tgid_takeover = _do_fixup_tgid_takeover;
|
||||||
}
|
}
|
||||||
|
|
||||||
INITCALL0(STG_REGISTER, _do_register);
|
INITCALL0(STG_REGISTER, _do_register);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user