/* epoll related fds */ #include #include #include #include #include #include #include #include "epoll.h" #include "fd.h" #include "log.h" #include "net.h" #include "params.h" #include "pids.h" #include "random.h" #include "sanitise.h" #include "shm.h" static int open_epoll_fds(void) { unsigned int i = 0; int fd = -1; while (i < MAX_EPOLL_FDS) { if (rand_bool()) fd = epoll_create(1); else fd = epoll_create1(EPOLL_CLOEXEC); if (fd != -1) { shm->epoll_fds[i] = fd; output(2, "fd[%d] = epoll\n", shm->epoll_fds[i]); i++; } else { /* not sure what happened. */ output(0, "epoll_create fail: %s\n", strerror(errno)); return FALSE; } } return TRUE; } static int get_rand_epoll_fd(void) { return shm->epoll_fds[rand() % MAX_EPOLL_FDS]; } const struct fd_provider epoll_fd_provider = { .name = "epoll", .enabled = TRUE, .open = &open_epoll_fds, .get = &get_rand_epoll_fd, }; .