Poll error is not longer breaking everything

This commit is contained in:
Андреев Григорий 2024-08-25 21:37:04 +03:00
parent 785cbff2a7
commit 2ad4f5b52d

View File

@ -212,7 +212,7 @@ namespace een9 {
pthread_create(&workers[i], NULL, worker_func, wtes[i].get());
}
// todo: move this try block inside the loop
// todo: right now this try block protects threads. So I need to put pthreads in some kind of guarding object
try {
int ret;
struct Ear {
@ -251,18 +251,16 @@ namespace een9 {
}
ASSERT(params.mainloop_recheck_interval_us > 0, "Incorrect poll timeout");
while (true) {
// MutexLockGuard lg1(wtec.corvee_bed, "poller termination check");
if (wtec.termination)
break;
// lg1.unlock();
for (size_t i = 0; i < Nip; i++) {
pollfds[i].revents = 0;
}
errno = 0;
ret = poll(pollfds.data(), Nip, params.mainloop_recheck_interval_us);
if (errno == EINTR)
break;
// todo: do not end program here (in the loop. Nothing in the loop should be able to end program)
if (ret != 0) {
printf("poll() error :> %d\n", errno);
}
ASSERT_on_iret(ret, "poll()");
for (size_t i = 0; i < Nip; i++) {
if ((pollfds[i].revents & POLLRDNORM)) {
@ -294,7 +292,7 @@ namespace een9 {
} catch (const std::exception& e) {
printf("System failure 2\n");
printf("%s\n", e.what());
/* There is no need to tiptoe around this multi-access field. It is write-onle-and-for-good-kind */
/* There is no need to tiptoe around this multi-access field. It is write-once-and-for-good-kind */
wtec.termination = true;
wtec.corvee_bed.wake_them_all();
}