summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-05-09 04:51:47 -0400
committerAndreas Schneider <asn@samba.org>2011-08-10 18:14:03 +0200
commit567ca037866e188142ddc4533324e80080e93b81 (patch)
tree3ebd111f6ba2aeb088473403c6b02505784bc058 /source3/lib
parentafc4dda7d078fb697ebfc36d021115007786c401 (diff)
downloadsamba-567ca037866e188142ddc4533324e80080e93b81.tar.gz
samba-567ca037866e188142ddc4533324e80080e93b81.tar.bz2
samba-567ca037866e188142ddc4533324e80080e93b81.zip
s3-prefork: provide means to expand the pool size
Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/server_prefork.c32
-rw-r--r--source3/lib/server_prefork.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c
index 0a8199a6ea..000539da0f 100644
--- a/source3/lib/server_prefork.c
+++ b/source3/lib/server_prefork.c
@@ -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)
diff --git a/source3/lib/server_prefork.h b/source3/lib/server_prefork.h
index bf9f3d3fe7..19ba32dff0 100644
--- a/source3/lib/server_prefork.h
+++ b/source3/lib/server_prefork.h
@@ -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,