diff options
-rw-r--r-- | source3/lib/server_prefork.c | 35 | ||||
-rw-r--r-- | source3/lib/server_prefork.h | 6 |
2 files changed, 38 insertions, 3 deletions
diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c index b337fa0c3b..0a8199a6ea 100644 --- a/source3/lib/server_prefork.c +++ b/source3/lib/server_prefork.c @@ -36,6 +36,8 @@ struct prefork_pool { int pool_size; struct pf_worker_data *pool; + + int allowed_clients; }; int prefork_pool_destructor(struct prefork_pool *pfp) @@ -86,6 +88,10 @@ bool prefork_create_pool(struct tevent_context *ev_ctx, talloc_set_destructor(pfp, prefork_pool_destructor); for (i = 0; i < min_children; i++) { + + pfp->pool[i].allowed_clients = 1; + pfp->pool[i].started = now; + pid = sys_fork(); switch (pid) { case -1: @@ -102,7 +108,6 @@ bool prefork_create_pool(struct tevent_context *ev_ctx, default: /* THE PARENT */ pfp->pool[i].pid = pid; - pfp->pool[i].started = now; break; } } @@ -126,6 +131,9 @@ int prefork_add_children(struct tevent_context *ev_ctx, continue; } + pfp->pool[i].allowed_clients = 1; + pfp->pool[i].started = now; + pid = sys_fork(); switch (pid) { case -1: @@ -144,7 +152,6 @@ int prefork_add_children(struct tevent_context *ev_ctx, default: /* THE PARENT */ pfp->pool[i].pid = pid; - pfp->pool[i].started = now; j++; break; } @@ -263,6 +270,30 @@ bool prefork_mark_pid_dead(struct prefork_pool *pfp, pid_t pid) return false; } +void prefork_increase_allowed_clients(struct prefork_pool *pfp, int max) +{ + int i; + + for (i = 0; i < pfp->pool_size; i++) { + if (pfp->pool[i].status == PF_WORKER_NONE) { + continue; + } + + if (pfp->pool[i].allowed_clients < max) { + pfp->pool[i].allowed_clients++; + } + } +} + +void prefork_reset_allowed_clients(struct prefork_pool *pfp) +{ + int i; + + for (i = 0; i < pfp->pool_size; i++) { + pfp->pool[i].allowed_clients = 1; + } +} + /* ==== Functions used by children ==== */ static SIG_ATOMIC_T pf_alarm; diff --git a/source3/lib/server_prefork.h b/source3/lib/server_prefork.h index 7e95602e81..bf9f3d3fe7 100644 --- a/source3/lib/server_prefork.h +++ b/source3/lib/server_prefork.h @@ -37,10 +37,12 @@ enum pf_server_cmds { struct pf_worker_data { pid_t pid; enum pf_worker_status status; - enum pf_server_cmds cmds; time_t started; time_t last_used; int num_clients; + + enum pf_server_cmds cmds; + int allowed_clients; }; typedef int (prefork_main_fn_t)(struct tevent_context *ev, @@ -67,6 +69,8 @@ int prefork_retire_children(struct prefork_pool *pfp, int num_children, time_t age_limit); int prefork_count_active_children(struct prefork_pool *pfp, int *total); bool prefork_mark_pid_dead(struct prefork_pool *pfp, pid_t pid); +void prefork_increase_allowed_clients(struct prefork_pool *pfp, int max); +void prefork_reset_allowed_clients(struct prefork_pool *pfp); /* ==== Functions used by children ==== */ |