diff options
| author | Greg Hudson <ghudson@mit.edu> | 2010-09-19 12:03:18 +0000 |
|---|---|---|
| committer | Greg Hudson <ghudson@mit.edu> | 2010-09-19 12:03:18 +0000 |
| commit | 4b365b97f7972f6a18f14e286017a25404b4179b (patch) | |
| tree | ae2336336521b841e3d36abc85288d221e79f3c7 /src | |
| parent | 62c814a80d26879594c78f750cd7e138fe1d7f96 (diff) | |
| download | krb5-4b365b97f7972f6a18f14e286017a25404b4179b.tar.gz krb5-4b365b97f7972f6a18f14e286017a25404b4179b.tar.xz krb5-4b365b97f7972f6a18f14e286017a25404b4179b.zip | |
Slight revisions to create_workers() in the KDC:
* Use calloc() to allocate the pids array; squashes a Coverity false
positive.
* Don't leak the pids array in worker processes.
* Use consistent terminology in comments.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24329 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
| -rw-r--r-- | src/kdc/main.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/kdc/main.c b/src/kdc/main.c index 6aac1d8fc..8d5d9a800 100644 --- a/src/kdc/main.c +++ b/src/kdc/main.c @@ -564,13 +564,16 @@ create_workers(int num) /* Create child worker processes; return in each child. */ krb5_klog_syslog(LOG_INFO, "creating %d worker processes", num); - pids = malloc(num * sizeof(pid_t)); + pids = calloc(num, sizeof(pid_t)); if (pids == NULL) return ENOMEM; for (i = 0; i < num; i++) { pid = fork(); - if (pid == 0) + if (pid == 0) { + /* Return control to main() in the new worker process. */ + free(pids); return 0; + } if (pid == -1) { /* Couldn't fork enough times. */ status = errno; @@ -581,10 +584,10 @@ create_workers(int num) pids[i] = pid; } - /* Supervise the child processes. */ + /* Supervise the worker processes. */ numleft = num; while (!signal_requests_exit) { - /* Wait until a child process exits or we get a signal. */ + /* Wait until a worker process exits or we get a signal. */ pid = wait(&status); if (pid >= 0) { krb5_klog_syslog(LOG_ERR, "worker %ld exited with status %d", @@ -596,8 +599,8 @@ create_workers(int num) pids[i] = -1; } - /* When one process exits, terminate them all, so that KDC crashes - * behave similarly with or without worker processes. */ + /* When one worker process exits, terminate them all, so that KDC + * crashes behave similarly with or without worker processes. */ break; } |
