]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
[Bug 445] Ancient faxes get re-sent, and to the wrong people!!!
authorDarren Nickerson <darren.nickerson@ifax.com>
Wed, 5 Nov 2003 22:36:37 +0000 (22:36 +0000)
committerDarren Nickerson <darren.nickerson@ifax.com>
Wed, 5 Nov 2003 22:36:37 +0000 (22:36 +0000)
Thanks to iFAX Solutions for tracking down one of the most serious and
long-standing bugs I've ever been unfortunate enough to see happen to an
important production system. Because of blocking issues, HylaFAX was
orphaning original documents, and re-faxing them months (or years) later.
This patch removes the unnecessary blocking in cases where faxq already
has the framework to handle children properly, and prevents this situation
from ever arising.

faxd/faxApp.c++
faxd/faxApp.h
faxd/faxGettyApp.c++
faxd/faxQueueApp.c++
faxd/faxQueueApp.h
faxd/faxSendApp.c++

index 016e1993fd81f673cb489807f44f5556d2035f6a..165821037b94adb83d8b32bab935712893e75dbb 100644 (file)
@@ -373,7 +373,7 @@ const fxStr faxApp::enquote = "\"";
  * from address.
  */
 bool
-faxApp::runCmd(const char* cmd, bool changeIDs)
+faxApp::runCmd(const char* cmd, bool changeIDs, IOHandler* waiter)
 {
     pid_t pid = fork();
     switch (pid) {
@@ -388,12 +388,16 @@ faxApp::runCmd(const char* cmd, bool changeIDs)
        logError("Can not fork for \"%s\"", cmd);
        return (false);
     default:
+       if (waiter == NULL)
        { int status = 0;
          Sys::waitpid(pid, status);
          if (status != 0) {
            logError("Bad exit status %#o for \'%s\'", status, cmd);
            return (false);
          }
+       } else
+       {
+           Dispatcher::instance().startChild(pid, waiter);
        }
        return (true);
     }
index 9a83b43d840a39c3b7037614b7bd2b1870d5f283..98fe113a36dbd64f5b0c70f675ed789d285c82ad 100644 (file)
@@ -30,6 +30,7 @@
  */
 #include "Str.h"
 #include "Syslog.h"
+#include "Dispatcher.h"
 #include <stdarg.h>
 
 class faxApp : public Syslog {
@@ -78,7 +79,7 @@ public:
     static const fxStr quote;
     static const fxStr enquote;
 
-    bool runCmd(const char* cmd, bool changeIDs = false);
+    bool runCmd(const char* cmd, bool changeIDs = false, IOHandler* waiter = NULL);
 };
 inline bool faxApp::isRunning(void) const      { return running; }
 
index 47fda8f2f8d1f68a4f1846b9d8fbd0e90ad3c55e..63424be68ecd460cf32973e426cef64db2a8b2d8 100644 (file)
@@ -731,7 +731,7 @@ faxGettyApp::notifyRecvDone(const FaxRecvInfo& ri, const CallerID& cid)
     );
     traceServer("RECV FAX: %s", (const char*) cmd);
     setProcessPriority(BASE);                  // lower priority
-    runCmd(cmd, true);
+    runCmd(cmd, true, this);
     setProcessPriority(state);                 // restore priority
 }
 
index 624901084f2bfae30e972d0355cdd81da33c510e..a589a2cb134eec70bf2b9b403acb97a6600f2a2d 100644 (file)
@@ -2583,7 +2583,7 @@ faxQueueApp::notifyModemWedged(Modem& modem)
        | quote |                  dev | enquote
     );
     traceServer("MODEM WEDGED: %s", (const char*) cmd);
-    runCmd(cmd, true);
+    runCmd(cmd, true, this);
 }
 
 void
@@ -3042,7 +3042,7 @@ faxQueueApp::notifySender(Job& job, JobStatus why, const char* duration)
        cmd.append(buf);
     }
     traceServer("NOTIFY: %s", (const char*) cmd);
-    runCmd(cmd, true);
+    runCmd(cmd, true, this);
 }
 
 void
@@ -3135,6 +3135,12 @@ faxQueueApp::jobError(const Job& job, const char* fmt ...)
     va_end(ap);
 }
 
+void faxQueueApp::childStatus(pid_t pid, int status)
+{
+    // We don't do anything here - nothing to act on.
+    traceServer("NOTIFY exit status: %#o (%u)", status, pid);
+}
+
 static void
 usage(const char* appName)
 {
index f17c053c4b3a8b5c258479b87b46ff836fca885d..5ce416ba1e5e0bd26489b4afa514c5031999ae7c 100644 (file)
@@ -171,6 +171,7 @@ private:
     void       stopTimeout(const char* whichdir);
     const fxStr& pickCmd(const FaxRequest& req);
 // FIFO-related stuff
+    void       childStatus(pid_t, int);        // Dispatcher hook
     int                inputReady(int);                // Dispatcher hook
     void       openFIFOs();
     void       closeFIFOs();
index f95c1106f859e40431c69a544bb1f19f6ea0aacb..fc1627f021c49f9cb0226b100474626f4b6eeb56 100644 (file)
@@ -317,7 +317,7 @@ faxSendApp::notifyPollRecvd(FaxRequest& req, const FaxRecvInfo& ri)
      );
     traceServer("RECV POLL: %s", (const char*) cmd);
     setProcessPriority(BASE);                  // lower priority
-    runCmd(cmd, true);
+    runCmd(cmd, true, this);
     setProcessPriority(state);                 // restore previous priority
 }