]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
This makes our handling of the pid more intentional. We need to get
authorAidan Van Dyk <aidan@ifax.com>
Mon, 24 Apr 2006 20:54:40 +0000 (20:54 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Mon, 24 Apr 2006 20:54:40 +0000 (20:54 +0000)
our pid into the childQueue as soon as possible.  If it is not in there
when when it fires, then it's signal will be lost forever.

faxd/Job.c++
faxd/faxQueueApp.c++

index e38164933e113714f4c95e9ce7b2be7600a95bbd..9b9302dde2dcf468f1b2e30f798fd7ef068353c0 100644 (file)
@@ -207,13 +207,21 @@ Job::startSend(pid_t p)
 void
 Job::startControl(pid_t p, int fd)
 {
-    if (jci) {
-       delete jci;
-       jci = NULL;
-    }
+    // Order is important here.
+    // 1) We need to guaranted that jci is NULL and not needed, incase
+    //  our SIGCHLD comes before we get to delete it.
+    // 2) We want our child pid noted as soon as possible (once we're sure
+    //    jci is taken care of)
+    // And then we can worry about deleting and linking fd...
+    JobControlInfo *tmp_jci = jci;
+    jci = NULL;
+    Dispatcher::instance().startChild(pid = p, &ctrlHandler);
+
+    if (tmp_jci)
+       delete tmp_jci;
+
     ctrlHandler.fd = fd;
     Dispatcher::instance().link(fd, Dispatcher::ReadMask, &ctrlHandler);
-    Dispatcher::instance().startChild(pid = p, &ctrlHandler);
 }
 
 fxStr
index f47842deb000eebf9c86ebb0ca243a7cbfc9177a..2c821c2dd9c06bc351d8c7f7a0e87e8051f7fdca 100644 (file)
@@ -1642,10 +1642,8 @@ faxQueueApp::setReadyToRun(Job& job)
                _exit(255);
                /*NOTREACHED*/
            default:                    // parent, read from pipe and wait
+               job.startControl(pid, pfd[0]);  // First, get our child PID handled
                Sys::close(pfd[1]);
-
-               job.startControl(pid, pfd[0]);
-
            }
        }
        if (jobCtrlWait)