Skip to content

Commit

Permalink
Don't try to re-register regular file descriptors.
Browse files Browse the repository at this point in the history
File descriptors which have been rejected with EPERM by epoll_ctl() in
register_descriptor() must also no be re-registered after fork.
  • Loading branch information
ceggers-arri committed Sep 20, 2024
1 parent efdc25a commit 2bc01a2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions asio/include/asio/detail/impl/epoll_reactor.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,17 @@ void epoll_reactor::notify_fork(
for (descriptor_state* state = registered_descriptors_.first();
state != 0; state = state->next_)
{
ev.events = state->registered_events_;
ev.data.ptr = state;
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, state->descriptor_, &ev);
if (result != 0)
if (state->registered_events_ != 0)
{
asio::error_code ec(errno,
asio::error::get_system_category());
asio::detail::throw_error(ec, "epoll re-registration");
ev.events = state->registered_events_;
ev.data.ptr = state;
int result = epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, state->descriptor_, &ev);
if (result != 0)
{
asio::error_code ec(errno,
asio::error::get_system_category());
asio::detail::throw_error(ec, "epoll re-registration");
}
}
}
}
Expand Down

0 comments on commit 2bc01a2

Please sign in to comment.