summaryrefslogtreecommitdiff
path: root/source3/lib/server_prefork.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-08-14 18:11:18 -0400
committerSimo Sorce <idra@samba.org>2011-08-15 04:13:50 +0200
commit2e5fc8335022df44a015817d4628a48e9195e311 (patch)
treeb34a9816501d7be6dcff4b3be1fa7f3d3c1fab17 /source3/lib/server_prefork.c
parent039ddef20900322760093a04881007dbb0897b50 (diff)
downloadsamba-2e5fc8335022df44a015817d4628a48e9195e311.tar.gz
samba-2e5fc8335022df44a015817d4628a48e9195e311.tar.bz2
samba-2e5fc8335022df44a015817d4628a48e9195e311.zip
s3-prefork: Do not use mmap/mremap/munmap directly
Use the wrappers in util.h as they deal with trying to do the best they can on platfroms that do not support mmap extensions. Autobuild-User: Simo Sorce <idra@samba.org> Autobuild-Date: Mon Aug 15 04:13:51 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3/lib/server_prefork.c')
-rw-r--r--source3/lib/server_prefork.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source3/lib/server_prefork.c b/source3/lib/server_prefork.c
index 501fbc1b88..5206c36e8d 100644
--- a/source3/lib/server_prefork.c
+++ b/source3/lib/server_prefork.c
@@ -50,7 +50,7 @@ static bool prefork_setup_sigchld_handler(struct tevent_context *ev_ctx,
static int prefork_pool_destructor(struct prefork_pool *pfp)
{
- munmap(pfp->pool, pfp->pool_size * sizeof(struct pf_worker_data));
+ anonymous_shared_free(pfp->pool);
return 0;
}
@@ -97,9 +97,8 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
pfp->pool_size = max_children;
data_size = sizeof(struct pf_worker_data) * max_children;
- pfp->pool = mmap(NULL, data_size, PROT_READ|PROT_WRITE,
- MAP_SHARED|MAP_ANONYMOUS, -1, 0);
- if (pfp->pool == MAP_FAILED) {
+ pfp->pool = anonymous_shared_allocate(data_size);
+ if (pfp->pool == NULL) {
DEBUG(1, ("Failed to mmap memory for prefork pool!\n"));
talloc_free(pfp);
return false;
@@ -153,9 +152,10 @@ bool prefork_create_pool(TALLOC_CTX *mem_ctx,
*/
int prefork_expand_pool(struct prefork_pool *pfp, int new_max)
{
- struct pf_worker_data *pool;
+ struct prefork_pool *pool;
size_t old_size;
size_t new_size;
+ int ret;
if (new_max <= pfp->pool_size) {
return EINVAL;
@@ -164,10 +164,12 @@ int prefork_expand_pool(struct prefork_pool *pfp, int new_max)
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;
+ pool = anonymous_shared_resize(&pfp->pool, new_size, false);
+ if (pool == NULL) {
+ ret = errno;
+ DEBUG(3, ("Failed to mremap memory (%d: %s)!\n",
+ ret, strerror(ret)));
+ return ret;
}
memset(&pool[pfp->pool_size], 0, new_size - old_size);