- while (!should_stop()) {
- // Wait until there's activity on at least one of the fds,
- // or we are waken up due to new queued clients or data.
- int nfds = epoll_pwait(epoll_fd, events, EPOLL_MAX_EVENTS, -1, &sigset_without_usr1_block);
- if (nfds == -1 && errno != EINTR) {
+ for ( ;; ) {
+ int nfds = epoll_wait(epoll_fd, events, EPOLL_MAX_EVENTS, EPOLL_TIMEOUT_MS);
+ if (nfds == -1 && errno == EINTR) {
+ if (should_stop) {
+ return;
+ }
+ continue;
+ }
+ if (nfds == -1) {