Merge "init/epoll: Switch to aggregate initialization"
This commit is contained in:
commit
44d7397b98
1 changed files with 9 additions and 7 deletions
|
|
@ -45,16 +45,18 @@ Result<void> Epoll::RegisterHandler(int fd, Handler handler, uint32_t events) {
|
||||||
return Error() << "Must specify events";
|
return Error() << "Must specify events";
|
||||||
}
|
}
|
||||||
|
|
||||||
Info info;
|
auto [it, inserted] = epoll_handlers_.emplace(
|
||||||
info.events = events;
|
fd, Info{
|
||||||
info.handler = std::make_shared<decltype(handler)>(std::move(handler));
|
.events = events,
|
||||||
auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(info));
|
.handler = std::make_shared<Handler>(std::move(handler)),
|
||||||
|
});
|
||||||
if (!inserted) {
|
if (!inserted) {
|
||||||
return Error() << "Cannot specify two epoll handlers for a given FD";
|
return Error() << "Cannot specify two epoll handlers for a given FD";
|
||||||
}
|
}
|
||||||
epoll_event ev;
|
epoll_event ev = {
|
||||||
ev.events = events;
|
.events = events,
|
||||||
ev.data.fd = fd;
|
.data.fd = fd,
|
||||||
|
};
|
||||||
if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ev) == -1) {
|
if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ev) == -1) {
|
||||||
Result<void> result = ErrnoError() << "epoll_ctl failed to add fd";
|
Result<void> result = ErrnoError() << "epoll_ctl failed to add fd";
|
||||||
epoll_handlers_.erase(fd);
|
epoll_handlers_.erase(fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue