summaryrefslogtreecommitdiff
path: root/source3/lib/server_prefork.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-05-16 10:46:35 -0400
committerAndreas Schneider <asn@samba.org>2011-08-10 18:14:04 +0200
commit0a910c93472e1e4aff120219e09866d4a20ec2b2 (patch)
tree21b595373c4fe52393fbafafe3376959799c8ff2 /source3/lib/server_prefork.c
parente0aa6eec0b498db345666df4b02d4917fa3e259a (diff)
downloadsamba-0a910c93472e1e4aff120219e09866d4a20ec2b2.tar.gz
samba-0a910c93472e1e4aff120219e09866d4a20ec2b2.tar.bz2
samba-0a910c93472e1e4aff120219e09866d4a20ec2b2.zip
s3-prefork: Provide a cleanup function
This way the parent doesn't need to know how to handle dead children and keeps all of that within the prefork abstraction. Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/lib/server_prefork.c')
-rw-r--r--source3/lib/server_prefork.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c
index 211a54b95b..ef76a55486 100644
--- a/source3/lib/server_prefork.c
+++ b/source3/lib/server_prefork.c
@@ -291,29 +291,37 @@ int prefork_count_active_children(struct prefork_pool *pfp, int *total)
return a;
}
-/* to be used to finally mark a children as dead, so that it's slot can
- * be reused */
-bool prefork_mark_pid_dead(struct prefork_pool *pfp, pid_t pid)
+void prefork_cleanup_loop(struct prefork_pool *pfp)
{
+ int status;
+ pid_t pid;
int i;
+ /* TODO: should we use a process group id wait instead of looping ? */
for (i = 0; i < pfp->pool_size; i++) {
- if (pfp->pool[i].pid == pid) {
+ if (pfp->pool[i].status == PF_WORKER_NONE ||
+ pfp->pool[i].pid == 0) {
+ continue;
+ }
+
+ pid = sys_waitpid(pfp->pool[i].pid, &status, WNOHANG);
+ if (pid > 0) {
+
if (pfp->pool[i].status != PF_WORKER_EXITING) {
- DEBUG(2, ("pid %d terminated abnormally!\n",
- (int)pid));
+ DEBUG(3, ("Child (%d) terminated abnormally:"
+ " %d\n", (int)pid, status));
+ } else {
+ DEBUG(10, ("Child (%d) terminated with status:"
+ " %d\n", (int)pid, status));
}
/* reset all fields,
* this makes status = PF_WORK_NONE */
memset(&pfp->pool[i], 0,
sizeof(struct pf_worker_data));
-
- return true;
}
}
- return false;
}
void prefork_increase_allowed_clients(struct prefork_pool *pfp, int max)