summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/server_prefork.c21
-rw-r--r--source3/lib/server_prefork.h4
-rw-r--r--source3/lib/server_prefork_util.c2
3 files changed, 16 insertions, 11 deletions
diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c
index bcb5e0f19e..016f65c5c3 100644
--- a/source3/lib/server_prefork.c
+++ b/source3/lib/server_prefork.c
@@ -240,9 +240,11 @@ static int prefork_sort_oldest(const void *ap, const void *bp)
return -1;
}
-int prefork_retire_children(struct prefork_pool *pfp,
+int prefork_retire_children(struct messaging_context *msg_ctx,
+ struct prefork_pool *pfp,
int num_children, time_t age_limit)
{
+ const DATA_BLOB ping = data_blob_null;
time_t now = time(NULL);
struct prefork_oldest *oldest;
int i, j;
@@ -267,13 +269,15 @@ int prefork_retire_children(struct prefork_pool *pfp,
prefork_sort_oldest);
for (i = 0, j = 0; i < pfp->pool_size && j < num_children; i++) {
- if ((pfp->pool[i].status == PF_WORKER_ALIVE ||
- pfp->pool[i].status == PF_WORKER_ACCEPTING) &&
- pfp->pool[i].started <= age_limit) {
+ if (((pfp->pool[i].status == PF_WORKER_ALIVE) &&
+ (pfp->pool[i].num_clients < 1)) &&
+ (pfp->pool[i].started <= age_limit)) {
/* tell the child it's time to give up */
DEBUG(5, ("Retiring pid %d!\n", pfp->pool[i].pid));
pfp->pool[i].cmds = PF_SRV_MSG_EXIT;
- kill(pfp->pool[i].pid, SIGHUP);
+ messaging_send(msg_ctx,
+ pid_to_procid(pfp->pool[i].pid),
+ MSG_PREFORK_PARENT_EVENT, &ping);
j++;
}
}
@@ -581,12 +585,11 @@ static void prefork_listen_accept_handler(struct tevent_context *ev,
req = ctx->req;
state = tevent_req_data(ctx->req, struct pf_listen_state);
- if (state->pf->cmds == PF_SRV_MSG_EXIT) {
+ if ((state->pf->cmds == PF_SRV_MSG_EXIT) &&
+ (state->pf->num_clients <= 0)) {
/* We have been asked to exit, so drop here and the next
* child will pick it up */
- if (state->pf->num_clients <= 0) {
- state->pf->status = PF_WORKER_EXITING;
- }
+ state->pf->status = PF_WORKER_EXITING;
state->error = EINTR;
goto done;
}
diff --git a/source3/lib/server_prefork.h b/source3/lib/server_prefork.h
index 17491536ff..1d203e6317 100644
--- a/source3/lib/server_prefork.h
+++ b/source3/lib/server_prefork.h
@@ -152,6 +152,7 @@ int prefork_add_children(struct tevent_context *ev_ctx,
/**
* @brief Commands a number of children to stop and exit
*
+* @param msg_ctx The messaging context.
* @param pfp The pool.
* @param num_children The number of children we need to retire.
* @param age_limit The minimum age a child has been active to be
@@ -165,7 +166,8 @@ int prefork_add_children(struct tevent_context *ev_ctx,
* If all the available children are too young or are busy then it
* is possible that none will be asked to stop.
*/
-int prefork_retire_children(struct prefork_pool *pfp,
+int prefork_retire_children(struct messaging_context *msg_ctx,
+ struct prefork_pool *pfp,
int num_children, time_t age_limit);
/**
* @brief Count the number of children
diff --git a/source3/lib/server_prefork_util.c b/source3/lib/server_prefork_util.c
index 01c7994f60..3e14015c81 100644
--- a/source3/lib/server_prefork_util.c
+++ b/source3/lib/server_prefork_util.c
@@ -102,7 +102,7 @@ void pfh_manage_pool(struct tevent_context *ev_ctx,
n = total - cfg->min_children;
}
if (n >= 0) {
- prefork_retire_children(pool, n,
+ prefork_retire_children(msg_ctx, pool, n,
now - cfg->child_min_life);
}
}