From 2ad4f5b52d511c4a4d14d941393de2fbc57a3c25 Mon Sep 17 00:00:00 2001 From: Andreev Gregory Date: Sun, 25 Aug 2024 21:37:04 +0300 Subject: [PATCH] Poll error is not longer breaking everything --- .../engine_engine_number_9/running_mainloop.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/http_server/engine_engine_number_9/running_mainloop.cpp b/src/http_server/engine_engine_number_9/running_mainloop.cpp index 0cb1355..b5deb27 100644 --- a/src/http_server/engine_engine_number_9/running_mainloop.cpp +++ b/src/http_server/engine_engine_number_9/running_mainloop.cpp @@ -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(); }