From 3770306817e0950478d25a4bea0c5ec54312fe54 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 25 Oct 2021 16:53:18 -0400 Subject: [PATCH] Add logic to skip capturing if Capturing()==Ondemand --- src/zmc.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/zmc.cpp b/src/zmc.cpp index d974d1bec..eacaa43e6 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -249,6 +249,11 @@ int main(int argc, char *argv[]) { monitor->Id()); zmDbDo(sql); + while ((monitor->Capturing() == Monitor::CAPTURING_ONDEMAND) and !monitor->hasViewers()) { + Debug(1, "ONDEMAND and no Viewers. Sleeping"); + sleep(1); + } + Seconds sleep_time = Seconds(0); while (monitor->PrimeCapture() <= 0) { if (prime_capture_log_count % 60) { @@ -286,10 +291,14 @@ int main(int argc, char *argv[]) { Microseconds sleep_time = Microseconds(0); while (!zm_terminate) { - //sigprocmask(SIG_BLOCK, &block_set, 0); for (size_t i = 0; i < monitors.size(); i++) { monitors[i]->CheckAction(); + if (monitors[i]->Capturing() == Monitor::CAPTURING_ONDEMAND and !monitors[i]->hasViewers()) { + result = 0; + continue; + } + if (monitors[i]->PreCapture() < 0) { Error("Failed to pre-capture monitor %d %s (%zu/%zu)", monitors[i]->Id(), monitors[i]->Name(), i + 1, monitors.size());