From 976832fb765a4f47441ec9c4295c095b276efe2b Mon Sep 17 00:00:00 2001 From: FlatTV Date: Thu, 3 Jun 2021 18:59:48 +0200 Subject: [PATCH] Add Timeout for emergency start of pollthread and some more debug output --- common/ca_ci.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/common/ca_ci.cpp b/common/ca_ci.cpp index 929fc33..ade0f03 100644 --- a/common/ca_ci.cpp +++ b/common/ca_ci.cpp @@ -1534,12 +1534,21 @@ void cCA::slot_pollthread(void *c) if (!zapitReady) { printf("[CA] Slot%d: Waiting for zapit\n", slot->slot); + const int waiting = 3 * 1000000; // wait for 3 seconds + const int maxwait = waiting * 6; + int timeout = 0; + while (!zapitReady) { - usleep( 3 * 1000000); //wait for 3 seconds + usleep(waiting); + if (timeout >= maxwait) + zapitReady = true; + else + timeout += waiting; } - printf("[CA] Slot%d: zapit is ready\n", slot->slot); + printf("[CA] Slot%d: %s\n", slot->slot, timeout >= maxwait ? "waiting timeout!" : "zapit is ready"); } + printf("[CA] Slot%d: start pollthread\n", slot->slot); #endif while (1) {