77 epoll_fd= epoll_create1(EPOLL_CLOEXEC);
80 sql_perror(
"epoll_create1()");
87 if (it->getFileDescriptors(fds))
89 errmsg_printf(error::ERROR, _(
"Error getting file descriptors"));
97 ev.data.u32= listen_fd_list.size();
98 if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev) == -1)
100 sql_perror(
"epoll_ctl(EPOLL_CTL_ADD)");
103 listen_fd_list.push_back(it);
104 listen_fds.push_back(fd);
108 if (listen_fds.empty())
110 errmsg_printf(error::ERROR, _(
"No sockets could be bound for listening"));
118 if (pipe(wakeup_pipe) == -1)
120 sql_perror(
"pipe()");
126 ev.data.u32= WAKEUP_EVENT;
127 if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, wakeup_pipe[0], &ev) == -1)
129 sql_perror(
"epoll_ctl(EPOLL_CTL_ADD)");
138 epoll_event events[MAX_EPOLL_EVENTS];
142 int ready= epoll_wait(epoll_fd, events, MAX_EPOLL_EVENTS, -1);
147 sql_perror(
"epoll_wait()");
154 for (
int x= 0; x < ready; x++)
156 if (not (events[x].events & EPOLLIN))
160 if (events[x].data.u32 == WAKEUP_EVENT)
163 for (
int fd : listen_fds)
169 (void) close(wakeup_pipe[0]);
170 (void) close(wakeup_pipe[1]);
171 (void) close(epoll_fd);
177 uint32_t index= events[x].data.u32;