Add poller_post_fork() for *BSD kqueue
This commit is contained in:
parent
1051ad555a
commit
365aed456e
18
liberty.c
18
liberty.c
@ -1612,6 +1612,8 @@ poller_set (struct poller *self, struct poller_fd *fd)
|
|||||||
modifying ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd->fd, &event) != -1);
|
modifying ? EPOLL_CTL_MOD : EPOLL_CTL_ADD, fd->fd, &event) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define poller_post_fork(self)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
poller_compare_fds (const void *ax, const void *bx)
|
poller_compare_fds (const void *ax, const void *bx)
|
||||||
{
|
{
|
||||||
@ -1763,12 +1765,10 @@ static void
|
|||||||
poller_set (struct poller *self, struct poller_fd *fd)
|
poller_set (struct poller *self, struct poller_fd *fd)
|
||||||
{
|
{
|
||||||
hard_assert (fd->poller == self);
|
hard_assert (fd->poller == self);
|
||||||
bool modifying = true;
|
|
||||||
if (fd->index == -1)
|
if (fd->index == -1)
|
||||||
{
|
{
|
||||||
poller_ensure_space (self);
|
poller_ensure_space (self);
|
||||||
self->fds[fd->index = self->len++] = fd;
|
self->fds[fd->index = self->len++] = fd;
|
||||||
modifying = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to watch for readability and writeability separately;
|
// We have to watch for readability and writeability separately;
|
||||||
@ -1784,6 +1784,18 @@ poller_set (struct poller *self, struct poller_fd *fd)
|
|||||||
exit_fatal ("%s: %s", "kevent", strerror (errno));
|
exit_fatal ("%s: %s", "kevent", strerror (errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
poller_post_fork (struct poller *self)
|
||||||
|
{
|
||||||
|
// The kqueue FD isn't preserved across forks, need to recreate it
|
||||||
|
self->kqueue_fd = kqueue ();
|
||||||
|
hard_assert (self->kqueue_fd != -1);
|
||||||
|
set_cloexec (self->kqueue_fd);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < self->len; i++)
|
||||||
|
poller_set (self, self->fds[i]);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
poller_compare_fds (const void *ax, const void *bx)
|
poller_compare_fds (const void *ax, const void *bx)
|
||||||
{
|
{
|
||||||
@ -1987,6 +1999,8 @@ poller_set (struct poller *self, struct poller_fd *fd)
|
|||||||
new_entry->events = fd->events;
|
new_entry->events = fd->events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define poller_post_fork(self)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
poller_remove_at_index (struct poller *self, size_t index)
|
poller_remove_at_index (struct poller *self, size_t index)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user