Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6776e645 authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge changes I16bd2d5e,I04e9bf73

* changes:
  DO NOT MERGE: Revert "init: Add more diagnostics for signalfd hangs."
  DO NOT MERGE: Revert "init: Add diagnostics for signalfd epoll failures."
parents b18826fc e966e6e7
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@
#include <functional>
#include <map>

#include <android-base/logging.h>

namespace android {
namespace init {

@@ -44,11 +42,8 @@ Result<void> 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<decltype(handler)>(std::move(handler));
    auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(info));
    auto sp = std::make_shared<decltype(handler)>(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<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& 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);
        auto sp = *reinterpret_cast<std::shared_ptr<Handler>*>(ev[i].data.ptr);
        pending_functions.emplace_back(std::move(sp));
    }

    return pending_functions;
+1 −6
Original line number Diff line number Diff line
@@ -46,13 +46,8 @@ 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, Info> epoll_handlers_;
    std::map<int, std::shared_ptr<Handler>> epoll_handlers_;
};

}  // namespace init
+1 −2
Original line number Diff line number Diff line
@@ -661,8 +661,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();
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -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);