]> andersk Git - moira.git/commitdiff
Don't call critical_alert() from our SIGCHLD handler. It mallocs, and
authorzacheiss <zacheiss>
Wed, 25 Feb 2004 02:25:39 +0000 (02:25 +0000)
committerzacheiss <zacheiss>
Wed, 25 Feb 2004 02:25:39 +0000 (02:25 +0000)
we can deadlock if the daemon is in the middle of a malloc() when it
receives the signal.

server/mr_main.c

index 08b761284b5b00b2fe1aa115b91210451bbd249c..1b90b849c797cd982117ec4ef26969295fb5085c 100644 (file)
@@ -48,6 +48,8 @@ client **clients;
 int nclients, clientssize;
 
 int dormant;
+int child_exited_abnormally = 0;
+int child_pid, child_signal, child_status;
 
 void reapchild(int x);
 void godormant(int x);
@@ -212,6 +214,14 @@ int main(int argc, char **argv)
 
       if (takedown)
        break;
+
+      if (child_exited_abnormally)
+       {
+         critical_alert("moirad", "%d: child exits with signal %d status %d",
+                        child_pid, child_signal, child_status);
+         child_exited_abnormally = 0;
+       }
+
       time(&now);
       if (!inc_running || now - inc_started > INC_TIMEOUT)
        next_incremental();
@@ -371,8 +381,10 @@ void reapchild(int x)
        inc_running = 0;
       if (!takedown && (WTERMSIG(status) != 0 || WEXITSTATUS(status) != 0))
        {
-         critical_alert("moirad", "%d: child exits with signal %d status %d",
-                        pid, WTERMSIG(status), WEXITSTATUS(status));
+         child_exited_abnormally = 1;
+         child_pid = pid;
+         child_signal = WTERMSIG(status);
+         child_status = WEXITSTATUS(status);
        }
     }
 }
This page took 0.040087 seconds and 5 git commands to generate.