]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Don't log in faxq signal handler
authorPatrice Fournier <patrice.fournier@ifax.com>
Mon, 11 Jan 2016 04:25:36 +0000 (23:25 -0500)
committerPatrice Fournier <patrice.fournier@ifax.com>
Mon, 5 Aug 2024 09:42:35 +0000 (05:42 -0400)
Logging in signal handler can cause deadlock if signal arrives while
the process is already logging.

faxd/faxQueueApp.c++
faxd/faxQueueApp.h

index 4edc8a2b8088bda679d100de94db9650f7a21d55..e72d8d735caab927b6d5aee549fe6196e5e5ba40 100644 (file)
@@ -423,7 +423,7 @@ faxQueueApp::prepareCleanup(int s)
 {
     int old_errno = errno;
     signal(s, fxSIGHANDLER(faxQueueApp::prepareCleanup));
-    logError("CAUGHT SIGNAL %d, ABORT JOB PREPARATION", s);
+    faxQueueApp::instance().abortSignal = s;
     faxQueueApp::instance().abortPrepare = true;
     errno = old_errno;
 }
@@ -442,6 +442,7 @@ faxQueueApp::prepareStart(Batch& batch, Job& job, FaxRequest* req)
 {
     traceQueue(job, "PREPARE START");
     abortPrepare = false;
+    abortSignal = 0;
     pid_t pid = fork();
     switch (pid) {
     case 0:                            // child, do work
@@ -797,6 +798,8 @@ faxQueueApp::prepareJob(Job& job, FaxRequest& req,
            updateQFile = true;
        }    
     }
+    if (abortPrepare)
+       logError("CAUGHT SIGNAL %d, ABORT JOB PREPARATION", abortSignal);
     if (updateQFile)
        updateRequest(req, job);
     return (status);
index b9888c3b56cee856d311ebcffdd6afa761295fc0..b86cb702810d7aebbfa2d96683c9bac9770c12e8 100644 (file)
@@ -134,6 +134,7 @@ private:
 // runtime state
     bool       timeout;                // timeout occurred
     bool       abortPrepare;           // job preparation should be aborted
+    int                abortSignal;            // signal used to abort job preparation
     bool       quit;                   // terminate server
     int                fifo;                   // fifo job queue interface
     QLink      runq;                   // list of DestInfo ready to run