Loading init/epoll.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ #include <functional> #include <map> #include <android-base/logging.h> namespace android { namespace init { Loading @@ -42,8 +44,11 @@ Result<void> Epoll::RegisterHandler(int fd, Handler handler, uint32_t events) { if (!events) { return Error() << "Must specify events"; } auto sp = std::make_shared<decltype(handler)>(std::move(handler)); auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(sp)); Info info; info.events = events; info.handler = std::make_shared<decltype(handler)>(std::move(handler)); auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(info)); if (!inserted) { return Error() << "Cannot specify two epoll handlers for a given FD"; } Loading Loading @@ -84,8 +89,14 @@ Result<std::vector<std::shared_ptr<Epoll::Handler>>> Epoll::Wait( } std::vector<std::shared_ptr<Handler>> pending_functions; for (int i = 0; i < num_events; ++i) { auto sp = *reinterpret_cast<std::shared_ptr<Handler>*>(ev[i].data.ptr); pending_functions.emplace_back(std::move(sp)); auto& info = *reinterpret_cast<Info*>(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); } return pending_functions; Loading init/epoll.h +6 −1 Original line number Diff line number Diff line Loading @@ -46,8 +46,13 @@ class Epoll { std::optional<std::chrono::milliseconds> timeout); private: struct Info { std::shared_ptr<Handler> handler; uint32_t events; }; android::base::unique_fd epoll_fd_; std::map<int, std::shared_ptr<Handler>> epoll_handlers_; std::map<int, Info> epoll_handlers_; }; } // namespace init Loading init/init.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -646,7 +646,8 @@ static void InstallSignalFdHandler(Epoll* epoll) { PLOG(FATAL) << "failed to create signalfd"; } if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd); !result.ok()) { constexpr int flags = EPOLLIN | EPOLLPRI; if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd, flags); !result.ok()) { LOG(FATAL) << result.error(); } } Loading init/sigchld_handler.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,10 @@ static pid_t ReapOneProcess() { LOG(INFO) << name << " received signal " << siginfo.si_status << wait_string; } if (!service) return pid; if (!service) { LOG(INFO) << name << " did not have an associated service entry and will not be reaped"; return pid; } service->Reap(siginfo); Loading Loading
init/epoll.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ #include <functional> #include <map> #include <android-base/logging.h> namespace android { namespace init { Loading @@ -42,8 +44,11 @@ Result<void> Epoll::RegisterHandler(int fd, Handler handler, uint32_t events) { if (!events) { return Error() << "Must specify events"; } auto sp = std::make_shared<decltype(handler)>(std::move(handler)); auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(sp)); Info info; info.events = events; info.handler = std::make_shared<decltype(handler)>(std::move(handler)); auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(info)); if (!inserted) { return Error() << "Cannot specify two epoll handlers for a given FD"; } Loading Loading @@ -84,8 +89,14 @@ Result<std::vector<std::shared_ptr<Epoll::Handler>>> Epoll::Wait( } std::vector<std::shared_ptr<Handler>> pending_functions; for (int i = 0; i < num_events; ++i) { auto sp = *reinterpret_cast<std::shared_ptr<Handler>*>(ev[i].data.ptr); pending_functions.emplace_back(std::move(sp)); auto& info = *reinterpret_cast<Info*>(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); } return pending_functions; Loading
init/epoll.h +6 −1 Original line number Diff line number Diff line Loading @@ -46,8 +46,13 @@ class Epoll { std::optional<std::chrono::milliseconds> timeout); private: struct Info { std::shared_ptr<Handler> handler; uint32_t events; }; android::base::unique_fd epoll_fd_; std::map<int, std::shared_ptr<Handler>> epoll_handlers_; std::map<int, Info> epoll_handlers_; }; } // namespace init Loading
init/init.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -646,7 +646,8 @@ static void InstallSignalFdHandler(Epoll* epoll) { PLOG(FATAL) << "failed to create signalfd"; } if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd); !result.ok()) { constexpr int flags = EPOLLIN | EPOLLPRI; if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd, flags); !result.ok()) { LOG(FATAL) << result.error(); } } Loading
init/sigchld_handler.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -95,7 +95,10 @@ static pid_t ReapOneProcess() { LOG(INFO) << name << " received signal " << siginfo.si_status << wait_string; } if (!service) return pid; if (!service) { LOG(INFO) << name << " did not have an associated service entry and will not be reaped"; return pid; } service->Reap(siginfo); Loading