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

Commit 44d7397b authored by Bart Van Assche's avatar Bart Van Assche Committed by Gerrit Code Review
Browse files

Merge "init/epoll: Switch to aggregate initialization"

parents 5c7dc409 a1c8a622
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -45,16 +45,18 @@ Result<void> Epoll::RegisterHandler(int fd, Handler handler, uint32_t 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 [it, inserted] = epoll_handlers_.emplace(
            fd, Info{
                        .events = events,
                        .handler = std::make_shared<Handler>(std::move(handler)),
                });
    if (!inserted) {
        return Error() << "Cannot specify two epoll handlers for a given FD";
    }
    epoll_event ev;
    ev.events = events;
    ev.data.fd = fd;
    epoll_event ev = {
            .events = events,
            .data.fd = fd,
    };
    if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ev) == -1) {
        Result<void> result = ErrnoError() << "epoll_ctl failed to add fd";
        epoll_handlers_.erase(fd);