]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 118: batch jobs from sleep, also
authorLee Howard <faxguy@howardsilvan.com>
Tue, 27 Sep 2005 19:21:06 +0000 (19:21 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Tue, 27 Sep 2005 19:21:06 +0000 (19:21 +0000)
CHANGES
faxd/faxQueueApp.c++

diff --git a/CHANGES b/CHANGES
index 5eb516e8bc3ab46be1e9a8a028f74c290a2bddab..e9015d5f7d9848d09b08180142bba0ae38c48656 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,7 @@
 
 Changelog for HylaFAX
 
+* batch sleeping jobs too (27 Sep 2005)
 * fix and improve copy quality correction (27 Sep 2005)
 * fix PAM support for non-passworded authentication (27 Sep 2005)
 * add comments for enscript typerules entry (27 Sep 2005)
index e77b344b393ed366cb7b9cc7c6169f65617805bd..7ea4f03cd7d218c73bad650624d760577a1ae5c2 100644 (file)
@@ -2372,8 +2372,26 @@ faxQueueApp::runScheduler()
                         * jobs to other destinations.
                         */
                        unblockDestJobs(job, di);
+                       /*
+                        * Jobs that are on the sleep queue with state_sleeping
+                        * can be batched because the tts that the submitter requested
+                        * is known to have passed already.  So we pull these jobs out
+                        * of the sleep queue and place them into the run queue so that
+                        * the batching loop below can pick them up.  Note that we cannot
+                        * read the queue file (readRequest) at this point.  Any needed
+                        * alteration to the queue file must occur below within the loop
+                        * where the queue file is updated.
+                        */
+                       for (JobIter sleepiter(sleepq); sleepiter.notDone(); sleepiter++) {
+                           if (sleepiter.job().dest != job.dest || sleepiter.job().state != FaxRequest::state_sleeping)
+                               continue;
+                           sleepiter.job().stopTTSTimer();
+                           sleepiter.job().tts = now;
+                           sleepiter.job().state = FaxRequest::state_ready;
+                           sleepiter.job().remove();
+                           setReadyToRun(sleepiter.job());
+                       }
 
-                       JobIter joblist = iter;
                        Job* bjob = &job;       // Last batched Job
                        Job* cjob;              // current Job
                        FaxRequest* creq;       // current request
@@ -2385,37 +2403,46 @@ faxQueueApp::runScheduler()
                         */
                        if (maxBatchJobs > 64) maxBatchJobs = 64;
                        
-                       joblist++;              // Skip the current job
                        u_int batchedjobs = 1;
-                       for (; batchedjobs < maxBatchJobs && joblist.notDone(); joblist++) {
-                           cjob = joblist;
-                           fxAssert(cjob->tts <= Sys::now(), "Sleeping job on run queue");
-                           fxAssert(cjob->modem == NULL, "Job on run queue holding modem");
-                           if (job.dest != cjob->dest)
-                               continue;
-
-                           /* Check priorities */
-                           cjob->modem = job.modem;
-
-                           creq = readRequest(*cjob);
-
-                           /* XXX Should do some check here:
-                            * normal checks for a request (use a function?)
-                            * max total of pages in a batch,
-                            * We don't have to worry about compression format, resolution, 
-                            * and other negotiation parameters because we renegotiate settings
-                            * between jobs after EOM.
-                            * ... */
-
-                           traceJob(job, "ADDING JOB " | cjob->jobid | " TO BATCH");
-                           if (iter.notDone() && &iter.job() == bjob)
-                               iter++;
-                           cjob->remove();
-                           bjob->bnext = cjob;
-                           cjob->bprev = bjob;
-                           bjob = cjob;
-                           cjob->breq = creq;
-                           batchedjobs++;
+                       for (u_int j = 0; batchedjobs < maxBatchJobs && j < NQHASH; j++) {
+                           for (JobIter joblist(runqs[j]); batchedjobs < maxBatchJobs && joblist.notDone(); joblist++) {
+                               cjob = joblist;
+                               if (job.jobid == cjob->jobid)
+                                   continue;   // Skip the current job
+                               fxAssert(cjob->tts <= Sys::now(), "Sleeping job on run queue");
+                               fxAssert(cjob->modem == NULL, "Job on run queue holding modem");
+                               if (job.dest != cjob->dest)
+                                   continue;
+
+                               /* Check priorities */
+                               cjob->modem = job.modem;
+
+                               creq = readRequest(*cjob);
+
+                               /* XXX Should do some check here:
+                                * normal checks for a request (use a function?)
+                                * max total of pages in a batch,
+                                * We don't have to worry about compression format, resolution, 
+                                * and other negotiation parameters because we renegotiate settings
+                                * between jobs after EOM.
+                                * ... */
+
+                               traceJob(job, "ADDING JOB " | cjob->jobid | " TO BATCH");
+                               if (iter.notDone() && &iter.job() == bjob)
+                                   iter++;
+                               cjob->remove();
+                               bjob->bnext = cjob;
+                               cjob->bprev = bjob;
+                               bjob = cjob;
+                               cjob->breq = creq;
+                               if (creq->tts > now) {
+                                   // This job was batched from sleeping, things have
+                                   // changed; Update the queue file for onlookers.
+                                   creq->tts = now;
+                                   updateRequest(*creq, *cjob);
+                               }
+                               batchedjobs++;
+                           }
                        }
                        bjob->bnext = NULL;
                    } else