]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 747: Job batching shouldn't allow a job to bypass modem restrictions
authorAidan Van Dyk <aidan@ifax.com>
Fri, 28 Apr 2006 17:24:03 +0000 (17:24 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Fri, 28 Apr 2006 17:24:03 +0000 (17:24 +0000)
This batch adds areBatchable(), and verifies that a new job is allowed
to go on the modem that the batch is using.  Ported from Lee's work.

CHANGES
faxd/Modem.c++
faxd/Modem.h
faxd/faxQueueApp.c++
faxd/faxQueueApp.h

diff --git a/CHANGES b/CHANGES
index d7240b3ffa75c0a910af2a06f5d509f1443a7c24..6f601f41f6f1649206de84a07f6743c75ea92f6b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 
 Changelog
 
+* Use Lee's areBatchable() to make sure batching doesn't ignore job
+  modems (28 Apr 2006)
 * Enhance Italian translation (26 Apr 2006)
 * Fix faxq sleepq concurrency problem (Bug 745) (26 Apr 2006)
 * Fix runSchedule() concurrency problem (Bug 745) (26 Apr 2006)
index 41f325ca8bf3b4f16c0b5d050aae0b1a40a48d60..9312e7a43cd1e8a79d52991a39ef3890be01987f 100644 (file)
@@ -131,6 +131,15 @@ Modem::isCapable(const Job& job) const
     return (true);
 }
 
+bool
+Modem::isInGroup(const fxStr& mgroup)
+{
+    RE* c = ModemGroup::find(mgroup);
+    if (c)
+       return (c->Find(mgroup));
+    return ((devID == mgroup));
+}
+
 /*
  * Find a modem that is capable of handling
  * work associated with the specified job.
index 994a97bec952da053d6f66d565b920bc49c45b3c..c9e9fb8cd4c781812777e0d434e9e82094173dbd 100644 (file)
@@ -108,6 +108,7 @@ public:
     static Modem& getModemByID(const fxStr& id);
     static Modem* modemExists(const fxStr& id);
     static Modem* findModem(const Job& job);
+    bool isInGroup(const fxStr& mgroup);
 
     bool assign(Job&);         // assign modem
     void release();                    // release modem
index f757ba6419ad393d070c22b6b88ac0cb8b6823d0..ba198c2228867ac8f90d80c42a661a77744b260e 100644 (file)
@@ -2292,6 +2292,20 @@ faxQueueApp::removeDestInfoJob(Job& job)
        destJobs.remove(job.dest);
     }
 }
+
+/*
+ * Compare two job requests to each other and to a selected
+ * job to see if they can be batched together.
+ */
+bool
+faxQueueApp::areBatchable(Job& job, Job& nextjob, FaxRequest& nextreq)
+{
+    // make sure the job's modem is in the requested ModemGroup 
+    if (!job.modem->isInGroup(nextreq.modem))
+       return(false);
+    return(true);
+}
+
 /*
  * Scan the list of jobs and process those that are ready
  * to go.  Note that the scheduler should only ever be
@@ -2482,8 +2496,7 @@ inSchedule = true;
                        }
 
                        Job* bjob = &job;       // Last batched Job
-                       Job* cjob;              // current Job
-                       FaxRequest* creq;       // current request
+                       Job* cjob = &job;       // current Job
 
                        /*
                         * Since job files are passed to the send program as command-line
@@ -2498,30 +2511,26 @@ inSchedule = true;
                                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;
+                               fxAssert(cjob->tts <= Sys::now(), "Sleeping job on run queue");
+                               fxAssert(cjob->modem == NULL, "Job on run queue holding modem");
 
-                               /* 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.
-                                * ... */
+                               FaxRequest* creq = readRequest(*cjob);
+                               if (!areBatchable(job, *cjob, *creq)) {
+                                   delete creq;
+                                   continue;
+                               }
 
-                               traceJob(job, "ADDING JOB " | cjob->jobid | " TO BATCH");
                                if (iter.notDone() && &iter.job() == bjob)
                                    iter++;
+
+                               traceJob(job, "ADDING JOB " | cjob->jobid | " TO BATCH");
                                cjob->remove();
                                bjob->bnext = cjob;
                                cjob->bprev = bjob;
+                               cjob->modem = job.modem;
+
                                bjob = cjob;
                                cjob->breq = creq;
                                if (creq->tts > now) {
index dfc140e10bf2e6064a63bf83b4285612c47dbaf2..6dc05f0a45e63135b844465069282f8181cc6be7 100644 (file)
@@ -215,6 +215,7 @@ private:
     bool       submitJob(const fxStr& jobid, bool checkState = false);
     bool       suspendJob(const fxStr& jobid, bool abortActive);
     void       rejectSubmission(Job&, FaxRequest&, const fxStr& reason);
+    bool       areBatchable(Job& job, Job& nextjob, FaxRequest& nextreq);
 
     void       setReadyToRun(Job& job, bool wait);
     void       setSleep(Job& job, time_t tts);