diff options
author | Greg Hudson <ghudson@mit.edu> | 2011-09-14 16:12:39 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2011-09-14 16:12:39 +0000 |
commit | 72f42cefb51afc939a621c6b1560d210492c45a4 (patch) | |
tree | 2730a53d78da9746c06cddaaf7b860d21f56db67 | |
parent | 3038d7a0017b729cecbf26d4757228e56e87ac9a (diff) | |
download | krb5-72f42cefb51afc939a621c6b1560d210492c45a4.tar.gz krb5-72f42cefb51afc939a621c6b1560d210492c45a4.tar.xz krb5-72f42cefb51afc939a621c6b1560d210492c45a4.zip |
Simplify terminate_workers() in the KDC
Fixes a bug where we wait for one too many workers to terminate after
one of them crashes.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25178 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r-- | src/kdc/main.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/kdc/main.c b/src/kdc/main.c index bee5bd95ac..fbccdb90f0 100644 --- a/src/kdc/main.c +++ b/src/kdc/main.c @@ -509,15 +509,17 @@ on_monitor_sighup(int signo) * 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 @@ static krb5_error_code 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 @@ create_workers(verto_ctx *ctx, int num) 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 @@ create_workers(verto_ctx *ctx, int num) 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 @@ create_workers(verto_ctx *ctx, int num) 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); } |