Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python epoll1 Fork Support #32196

Merged
merged 23 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ void Epoll1Poller::Shutdown() {
}

void Epoll1Poller::Close() {
if (closed_) return;
{
grpc_core::MutexLock lock(&mu_);
if (closed_) return;
}

if (g_epoll_set_.epfd >= 0) {
close(g_epoll_set_.epfd);
gnossen marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -389,8 +392,8 @@ void Epoll1Poller::Close() {
free_epoll1_handles_list_.pop_front();
delete handle;
}
closed_ = true;
}
closed_ = true;
}

Epoll1Poller::~Epoll1Poller() { Close(); }
Expand Down Expand Up @@ -577,8 +580,10 @@ Epoll1Poller* MakeEpoll1Poller(Scheduler* scheduler) {

void Epoll1Poller::PrepareFork() { Kick(); }

// TODO(vigneshbabu): implement
void Epoll1Poller::PostforkParent() {}
gnossen marked this conversation as resolved.
Show resolved Hide resolved

// TODO(vigneshbabu): implement
void Epoll1Poller::PostforkChild() {}

} // namespace experimental
Expand Down
3 changes: 1 addition & 2 deletions src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ namespace experimental {
class Epoll1EventHandle;

// Definition of epoll1 based poller.
class Epoll1Poller : public PosixEventPoller,
public grpc_event_engine::experimental::Forkable {
class Epoll1Poller : public PosixEventPoller, public Forkable {
public:
explicit Epoll1Poller(Scheduler* scheduler);
EventHandle* CreateHandle(int fd, absl::string_view name,
Expand Down
4 changes: 3 additions & 1 deletion src/core/lib/gprpp/fork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ void Fork::SetResetChildPollingEngineFunc(
reset_child_polling_engine_->emplace_back(reset_child_polling_engine);
}
}
std::vector<Fork::child_postfork_func> Fork::GetResetChildPollingEngineFunc() {

const std::vector<Fork::child_postfork_func>&
Fork::GetResetChildPollingEngineFunc() {
return *reset_child_polling_engine_;
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/lib/gprpp/fork.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class Fork {
// reset the polling engine's internal state.
static void SetResetChildPollingEngineFunc(
child_postfork_func reset_child_polling_engine);
static std::vector<child_postfork_func> GetResetChildPollingEngineFunc();
static const std::vector<child_postfork_func>&
GetResetChildPollingEngineFunc();

// Check if there is a single active ExecCtx
// (the one used to invoke this function). If there are more,
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/iomgr/fork_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void grpc_postfork_child() {
if (!skipped_handler) {
grpc_core::Fork::AllowExecCtx();
grpc_core::ExecCtx exec_ctx;
for (auto reset_polling_engine :
for (auto* reset_polling_engine :
grpc_core::Fork::GetResetChildPollingEngineFunc()) {
if (reset_polling_engine != nullptr) {
reset_polling_engine();
Expand Down