in src/oomd/dropin/FsDropInService.cpp [300:342]
int FsDropInService::processEventLoop() {
std::array<struct epoll_event, kMaxEvents> events;
int n;
do {
n = ::epoll_wait(epollfd_, events.data(), kMaxEvents, -1);
} while (n < 0 && errno == EINTR);
if (n < 0) {
OLOG << "epoll_wait: " << Util::strerror_r();
return 1;
}
// This will only contend when drop in dir is recreated and some event fires,
// which is very rare. See comment above in prepDropInWatcher().
std::lock_guard<std::mutex> lock(event_loop_mutex_);
for (int i = 0; i < n; ++i) {
int fd = events[i].data.fd;
if (fd == terminatefd_) {
uint64_t val;
ssize_t len = ::read(fd, &val, sizeof(val));
if (len != sizeof(val)) {
OLOG << "read: " << Util::strerror_r();
return 1;
}
if (val != 1) {
OLOG << "Unexpected terminatefd value=" << val;
return 1;
}
// Special value for termination
return 2;
} else if (fd == inotifyfd_) {
if (processDropInWatcher(fd)) {
return 1;
}
} else {
OLOG << "Unknown fd=" << fd << " in event loop";
return 1;
}
}
return 0;
}