diff --git a/init/epoll.cpp b/init/epoll.cpp index 0580f8608..74d8aac96 100644 --- a/init/epoll.cpp +++ b/init/epoll.cpp @@ -23,8 +23,6 @@ #include #include -#include - namespace android { namespace init { @@ -44,11 +42,8 @@ Result Epoll::RegisterHandler(int fd, Handler handler, uint32_t events) { if (!events) { return Error() << "Must specify events"; } - - Info info; - info.events = events; - info.handler = std::make_shared(std::move(handler)); - auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(info)); + auto sp = std::make_shared(std::move(handler)); + auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(sp)); if (!inserted) { return Error() << "Cannot specify two epoll handlers for a given FD"; } @@ -89,14 +84,8 @@ Result>> Epoll::Wait( } std::vector> pending_functions; for (int i = 0; i < num_events; ++i) { - auto& info = *reinterpret_cast(ev[i].data.ptr); - if ((info.events & (EPOLLIN | EPOLLPRI)) == (EPOLLIN | EPOLLPRI) && - (ev[i].events & EPOLLIN) != ev[i].events) { - // This handler wants to know about exception events, and just got one. - // Log something informational. - LOG(ERROR) << "Received unexpected epoll event set: " << ev[i].events; - } - pending_functions.emplace_back(info.handler); + auto sp = *reinterpret_cast*>(ev[i].data.ptr); + pending_functions.emplace_back(std::move(sp)); } return pending_functions; diff --git a/init/epoll.h b/init/epoll.h index f58ae8df3..0df528935 100644 --- a/init/epoll.h +++ b/init/epoll.h @@ -46,13 +46,8 @@ class Epoll { std::optional timeout); private: - struct Info { - std::shared_ptr handler; - uint32_t events; - }; - android::base::unique_fd epoll_fd_; - std::map epoll_handlers_; + std::map> epoll_handlers_; }; } // namespace init diff --git a/init/init.cpp b/init/init.cpp index 96168050e..1df4c4489 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -646,8 +646,7 @@ static void InstallSignalFdHandler(Epoll* epoll) { PLOG(FATAL) << "failed to create signalfd"; } - constexpr int flags = EPOLLIN | EPOLLPRI; - if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd, flags); !result.ok()) { + if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd); !result.ok()) { LOG(FATAL) << result.error(); } } diff --git a/init/sigchld_handler.cpp b/init/sigchld_handler.cpp index 6fc64df33..9b2c7d939 100644 --- a/init/sigchld_handler.cpp +++ b/init/sigchld_handler.cpp @@ -95,10 +95,7 @@ static pid_t ReapOneProcess() { LOG(INFO) << name << " received signal " << siginfo.si_status << wait_string; } - if (!service) { - LOG(INFO) << name << " did not have an associated service entry and will not be reaped"; - return pid; - } + if (!service) return pid; service->Reap(siginfo);