1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-24 13:57:43 +03:00

s3-prefork: provide means to expand the pool size

Signed-off-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Simo Sorce 2011-05-09 04:51:47 -04:00 committed by Andreas Schneider
parent afc4dda7d0
commit 567ca03786
2 changed files with 33 additions and 0 deletions

View File

@ -116,6 +116,38 @@ bool prefork_create_pool(struct tevent_context *ev_ctx,
return true;
}
/* Provide the new max children number in new_max
* (must be larger than current max).
* Returns: 0 if all fine
* ENOSPC if mremap fails to expand
* EINVAL if new_max is invalid
*/
int prefork_expand_pool(struct prefork_pool *pfp, int new_max)
{
struct pf_worker_data *pool;
size_t old_size;
size_t new_size;
if (new_max <= pfp->pool_size) {
return EINVAL;
}
old_size = sizeof(struct pf_worker_data) * pfp->pool_size;
new_size = sizeof(struct pf_worker_data) * new_max;
pool = mremap(pfp->pool, old_size, new_size, 0);
if (pool == MAP_FAILED) {
DEBUG(3, ("Failed to mremap memory for prefork pool!\n"));
return ENOSPC;
}
memset(&pool[pfp->pool_size], 0, new_size - old_size);
pfp->pool_size = new_max;
return 0;
}
int prefork_add_children(struct tevent_context *ev_ctx,
struct prefork_pool *pfp,
int num_children)

View File

@ -61,6 +61,7 @@ bool prefork_create_pool(struct tevent_context *ev_ctx,
int min_children, int max_children,
prefork_main_fn_t *main_fn, void *private_data,
struct prefork_pool **pf_pool);
int prefork_expand_pool(struct prefork_pool *pfp, int new_max);
int prefork_add_children(struct tevent_context *ev_ctx,
struct prefork_pool *pfp,