]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 667: fix a potential stalled run queue due to the earlier throttle change
authorLee Howard <faxguy@howardsilvan.com>
Thu, 21 Jul 2005 21:50:25 +0000 (21:50 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Thu, 21 Jul 2005 21:50:25 +0000 (21:50 +0000)
CHANGES
faxd/faxQueueApp.c++

diff --git a/CHANGES b/CHANGES
index 0b48416d967d7b803e27e6ba2e3c92138f7e074c..8ee0421b76dd6295c5fda7307501832cea625a3e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -8,7 +8,7 @@ Changelog for HylaFAX 4.2.2
   as dealing with batches (13 Jul 2003)
 * fix job modifications on batched, running jobs (13 Jul 2005)
 * throttle faxq from running the scheduler more than once per
-  second in order to keep faxq from eating up CPU (11 Jul 2005)
+  second in order to keep faxq from eating up CPU (11, 21 Jul 2005)
 * fix job preparation failures in batches from causing faxq list
   corruption which would trigger faxq failure and worse (11 Jul 2005)
 * fix the abortion of the lead job in a batch from causing
index eae55a376969082648d25f0560ae05bf0e4621b3..4b57ba553fd83e08e3543faa7f75fa421dd27811 100644 (file)
@@ -62,22 +62,49 @@ fxStr strTime(time_t t)     { return fxStr(fmtTime(t)); }
 
 #define        JOBHASH(pri)    (((pri) >> 4) & (NQHASH-1))
 
-faxQueueApp::SchedTimeout::SchedTimeout() { started = false; }
+faxQueueApp::SchedTimeout::SchedTimeout()
+{
+    started = false;
+    pending = false;
+    lastRun = Sys::now() - 1;
+}
+
 faxQueueApp::SchedTimeout::~SchedTimeout() {}
 
 void
 faxQueueApp::SchedTimeout::timerExpired(long, long)
 {
-    started = false;
     faxQueueApp::instance().runScheduler();
+    started = false;
 }
 
 void
 faxQueueApp::SchedTimeout::start()
 {
-    if (!started) {
+    /*
+     * If we don't throttle the scheduler then large
+     * queues can halt the system with CPU consumption.
+     * So we keep the scheduler from running more than
+     * once per second.
+     */
+    if (!started && Sys::now() > lastRun) {
        Dispatcher::instance().startTimer(0,1, this);
+       lastRun = Sys::now();
        started = true;
+       pending = false;
+    } else {
+       if (!pending) {
+           /*
+            * The scheduler is either running now or has been run
+            * within the last second and there are no timers set
+            * to trigger another scheduler run.  So we set a
+            * timer to go off in one second to avoid a stalled
+            * run queue.
+            */
+           Dispatcher::instance().startTimer(1,0, this);
+           lastRun = Sys::now() + 1;
+           pending = true;
+       }
     }
 }
 
@@ -88,7 +115,6 @@ faxQueueApp::faxQueueApp()
 {
     fifo = -1;
     quit = false;
-    lastRun = Sys::now() - 1;
     dialRules = NULL;
     setupConfig();
 
@@ -2437,16 +2463,7 @@ faxQueueApp::pollForModemLock(Modem& modem)
 void
 faxQueueApp::pokeScheduler()
 {
-    /*
-     * If we don't throttle the scheduler then large
-     * queues can halt the system with CPU consumption.
-     * So we keep the scheduler from running more than
-     * once per second.
-     */
-    if (Sys::now() != lastRun) {
-       schedTimeout.start();
-       lastRun = Sys::now();
-    }
+    schedTimeout.start();
 }
 
 /*