From 2e5fc8335022df44a015817d4628a48e9195e311 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 14 Aug 2011 18:11:18 -0400 Subject: 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 Autobuild-Date: Mon Aug 15 04:13:51 CEST 2011 on sn-devel-104 --- source3/lib/server_prefork.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source3/lib/server_prefork.c') 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); -- cgit