]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 118: change sleep(1) to pokeScheduler(1)
authorLee Howard <faxguy@howardsilvan.com>
Thu, 11 Aug 2005 00:06:40 +0000 (00:06 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Thu, 11 Aug 2005 00:06:40 +0000 (00:06 +0000)
CHANGES
faxd/faxQueueApp.c++
faxd/faxQueueApp.h

diff --git a/CHANGES b/CHANGES
index a0fae147c7ed66a17e6dee21d90b0511e43399d9..7c3f04cec4de7b076f8e048fe9bfc852b5a9d4ef 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -12,7 +12,7 @@ Changelog for HylaFAX 4.2.2
 * fix build error with Mac OS X 10.4 (26 Jul 2005)
 * fix sendfax crash with verbose output (25, 29 Jul 2005)
 * fix a race with scheduled jobs to allow for coordinated
-  batch sending (25 Jul 2005)
+  batch sending (25 Jul, 10 Aug 2005)
 * fix some error conditions with JBIG and JPEG reception (25 Jul 2005)
 * improve probemodem results for some modems (16 Jul 2005)
 * correct cover sheet page count for some PDFs (14 Jul 2005)
index 826c655fbf3c4c9eb406cc0870a638a705c14d54..cdca0c1068bca5d50c54e7266e46970a0001fbe0 100644 (file)
@@ -79,7 +79,7 @@ faxQueueApp::SchedTimeout::timerExpired(long, long)
 }
 
 void
-faxQueueApp::SchedTimeout::start()
+faxQueueApp::SchedTimeout::start(u_short s)
 {
     /*
      * If we don't throttle the scheduler then large
@@ -88,12 +88,12 @@ faxQueueApp::SchedTimeout::start()
      * once per second.
      */
     if (!started && Sys::now() > lastRun) {
-       Dispatcher::instance().startTimer(0,1, this);
-       lastRun = Sys::now();
+       Dispatcher::instance().startTimer(s, 1, this);
+       lastRun = Sys::now() + s;
        started = true;
        pending = false;
     } else {
-       if (!pending) {
+       if (!pending && lastRun <= Sys::now()) {
            /*
             * The scheduler is either running now or has been run
             * within the last second and there are no timers set
@@ -101,8 +101,8 @@ faxQueueApp::SchedTimeout::start()
             * timer to go off in one second to avoid a stalled
             * run queue.
             */
-           Dispatcher::instance().startTimer(1,0, this);
-           lastRun = Sys::now() + 1;
+           Dispatcher::instance().startTimer(s + 1, 0, this);
+           lastRun = Sys::now() + 1 + s;
            pending = true;
        }
     }
@@ -2106,10 +2106,10 @@ faxQueueApp::runJob(Job& job)
      * In order to deliberately batch jobs by using a common
      * time-to-send we need to give time for the other jobs'
      * timers to expire and to enter the run queue before
-     * running the scheduler.
+     * running the scheduler.  Thus the scheduler is poked
+     * with a delay.
      */
-    sleep(1);                  // is this long enough?
-    pokeScheduler();
+    pokeScheduler(1);
 }
 
 /*
@@ -2474,9 +2474,9 @@ faxQueueApp::pollForModemLock(Modem& modem)
  * next time the dispatcher is invoked.
  */
 void
-faxQueueApp::pokeScheduler()
+faxQueueApp::pokeScheduler(u_short s)
 {
-    schedTimeout.start();
+    schedTimeout.start(s);
 }
 
 /*
index e89cc6359850a96c0c2aa4838db9dec1d26f841e..72b1b337204dae0ed5797a80e521beb974ab02c5 100644 (file)
@@ -76,7 +76,7 @@ private:
        ~SchedTimeout();
        void timerExpired(long, long);
 
-       void start();
+       void start(u_short s = 0);
     };
 // configuration stuff
     fxStr      configFile;             // configuration filename
@@ -225,7 +225,7 @@ private:
     void        unblockDestJobs(Job& job, DestInfo& di);
 
     void       runScheduler();
-    void       pokeScheduler();
+    void       pokeScheduler(u_short s = 0);
 // job preparation stuff
     bool       prepareJobNeeded(Job&, FaxRequest&, JobStatus&);
     static void prepareCleanup(int s);