#include <sys/ioctl.h>
#include <sys/epoll.h>
#include <time.h>
+#include <signal.h>
#include <errno.h>
#include <vector>
#include <string>
should_stop = true;
}
+ pthread_kill(worker_thread, SIGHUP);
if (pthread_join(worker_thread, NULL) == -1) {
perror("pthread_join");
exit(1);
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) {
MutexLock lock(&mutex); // We release the mutex between iterations.
- if (should_stop) {
- return;
- }
-
process_queued_data();
for (int i = 0; i < nfds; ++i) {
process_client(to_process[i]);
}
}
+
+ if (should_stop) {
+ return;
+ }
}
}