svn rev #25178: trunk/src/kdc/

ghudson@MIT.EDU ghudson at MIT.EDU
Wed Sep 14 12:12:39 EDT 2011


http://src.mit.edu/fisheye/changelog/krb5/?cs=25178
Commit By: ghudson
Log Message:
Simplify terminate_workers() in the KDC.

Fixes a bug where we wait for one too many workers to terminate after
one of them crashes.


Changed Files:
U   trunk/src/kdc/main.c
Modified: trunk/src/kdc/main.c
===================================================================
--- trunk/src/kdc/main.c	2011-09-14 16:12:36 UTC (rev 25177)
+++ trunk/src/kdc/main.c	2011-09-14 16:12:39 UTC (rev 25178)
@@ -509,15 +509,17 @@
  * in the array.
  */
 static void
-terminate_workers(pid_t *pids, int bound, int num_active)
+terminate_workers(pid_t *pids, int bound)
 {
-    int i, status;
+    int i, status, num_active;
     pid_t pid;
 
     /* Kill the active worker pids. */
     for (i = 0; i < bound; i++) {
-        if (pids[i] != -1)
-            kill(pids[i], SIGTERM);
+        if (pids[i] == -1)
+            continue;
+        kill(pids[i], SIGTERM);
+        num_active++;
     }
 
     /* Wait for them to exit. */
@@ -537,7 +539,7 @@
 create_workers(verto_ctx *ctx, int num)
 {
     krb5_error_code retval;
-    int i, status, numleft;
+    int i, status;
     pid_t pid, *pids;
 #ifdef POSIX_SIGNALS
     struct sigaction s_action;
@@ -590,7 +592,7 @@
         if (pid == -1) {
             /* Couldn't fork enough times. */
             status = errno;
-            terminate_workers(pids, i, i);
+            terminate_workers(pids, i);
             free(pids);
             return status;
         }
@@ -601,7 +603,6 @@
     loop_free(ctx);
 
     /* Supervise the worker processes. */
-    numleft = num;
     while (!signal_received) {
         /* Wait until a worker process exits or we get a signal. */
         pid = wait(&status);
@@ -633,7 +634,7 @@
         krb5_klog_syslog(LOG_INFO, _("signal %d received in supervisor"),
                          signal_received);
 
-    terminate_workers(pids, num, numleft);
+    terminate_workers(pids, num);
     free(pids);
     exit(0);
 }




More information about the cvs-krb5 mailing list