]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 667: correct the return status of jobs in a batch when an abort occurs
authorLee Howard <faxguy@howardsilvan.com>
Fri, 15 Jul 2005 16:43:19 +0000 (16:43 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Fri, 15 Jul 2005 16:43:19 +0000 (16:43 +0000)
CHANGES
faxd/faxQueueApp.c++
faxd/faxQueueApp.h

diff --git a/CHANGES b/CHANGES
index 86eca939225b35ef55d1aefd7ca13f3faf97d536..987dfad3fe60f7ea1824fc5698f4be91273ada14 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -11,7 +11,7 @@ Changelog for HylaFAX 4.2.2
 * 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
-  all other jobs in the batch to also abort (11 Jul 2005)
+  all other jobs in the batch to also abort (11, 15 Jul 2005)
 * restrict MaxBatchJobs to 64 in order to prevent command-line
   parameters from causing faxsend invocation errors (11 Jul 2005)
 * fix ECM frame data from being overwritten by corrupt frames later
index 5877d59415e272c7d96c6580d3344c71c5549d6c..eae55a376969082648d25f0560ae05bf0e4621b3 100644 (file)
@@ -1355,8 +1355,9 @@ faxQueueApp::sendJobStart(Job& job, FaxRequest* req, const DestControlInfo& dci)
            | " (PID %lu)"
            , pid
        );
+       job.startSend(pid);
        for (cjob = &job; cjob != NULL; cjob = njob) {
-           cjob->startSend(pid);
+           cjob->pid = pid;
            njob = cjob->bnext;
            Trigger::post(Trigger::SEND_BEGIN, *cjob);
            delete cjob->breq;          // discard handle (NB: releases lock)
@@ -1372,55 +1373,47 @@ faxQueueApp::sendJobDone(Job& job, int status)
     Job* cjob;
     Job* njob;
     FaxRequest* req;
-    int cstatus = status;
-    bool seenabort = false;
+    FaxSendStatus cstatus = send_retry;
 
     DestInfo& di = destJobs[job.dest];
     di.hangup();
     unblockDestJobs(job, di);
+    releaseModem(job);                         // done with modem
+
+    traceQueue(job, "CMD DONE: exit status %#x", status);
+    if (status&0xff)
+       logError("Send program terminated abnormally with exit status %#x", status);
 
     for (cjob = &job; cjob != NULL; cjob = njob) {
        njob = cjob->bnext;
        req = readRequest(*cjob);               // reread the qfile
-       if ((!(status&0xff) || seenabort) && req)
-           cstatus = (req->status << 8);
-       else {
-           cstatus = status;
-           seenabort = true;
+       if (!req) {
+           time_t now = Sys::now();
+           time_t duration = now - job.start;
+           logError("JOB %s: SEND FINISHED: %s; but job file vanished",
+               (const char*) job.jobid, fmtTime(duration));
+           setDead(job);
+           continue;
        }
-       sendJobDone(*cjob, req, cstatus);
+       sendJobDone(*cjob, req);
     }
 }
 
 void
-faxQueueApp::sendJobDone(Job& job, FaxRequest* req, int status)
+faxQueueApp::sendJobDone(Job& job, FaxRequest* req)
 {
     time_t now = Sys::now();
     time_t duration = now - job.start;
 
-    traceQueue(job, "CMD DONE: exit status %#x", status);
     Trigger::post(Trigger::SEND_END, job);
     job.bnext = NULL; job.bprev = NULL;                // clear any batching
-    releaseModem(job);                         // done with modem
-    if (!req) {
-       logError("JOB %s: SEND FINISHED: %s; but job file vanished",
-           (const char*) job.jobid, fmtTime(duration));
-       setDead(job);
-       return;
-    }
     job.commid = req->commid;                  // passed from subprocess
-    if (status&0xff) {
-       req->notice = fxStr::format(
-           "Send program terminated abnormally with exit status %#x", status);
-       req->status = send_failed;
-       logError("JOB " | job.jobid | ": " | req->notice);
-    } else if ((status >>= 8) == 127) {
+    if (req->status == 127) {
        req->notice = "Send program terminated abnormally; unable to exec " |
            pickCmd(*req);
        req->status = send_failed;
        logError("JOB " | job.jobid | ": " | req->notice);
-    } else
-       req->status = (FaxSendStatus) status;
+    }
     if (req->status == send_reformat) {
        /*
         * Job requires reformatting to deal with the discovery
index a21ba7da73beefe2da050086ab151195eb29c231..c7b0a558601e48bd231d620adf98b028f8fe3c93 100644 (file)
@@ -199,7 +199,7 @@ private:
                    DestInfo&, const DestControlInfo&);
     void       sendJobStart(Job&, FaxRequest*, const DestControlInfo&);
     void       sendJobDone(Job& job, int status);
-    void       sendJobDone(Job& job, FaxRequest* req, int status);
+    void       sendJobDone(Job& job, FaxRequest* req);
     void       blockJob(Job&, FaxRequest&, const char*);
     void       delayJob(Job&, FaxRequest&, const char*, time_t);
     void       rejectJob(Job& job, FaxRequest& req, const fxStr& reason);