summaryrefslogtreecommitdiff
path: root/shmem
diff options
context:
space:
mode:
authorRyan Bloom <rbb@apache.org>2000-12-02 07:08:07 +0000
committerRyan Bloom <rbb@apache.org>2000-12-02 07:08:07 +0000
commit84177e59f931130c60e129b8dc68d02bbabf8f29 (patch)
treece76b85c2092918480725b0a07dacbdbf82819d9 /shmem
parentf335eac6f8e1df7921a0b94d031a65e633a42928 (diff)
downloadapr-84177e59f931130c60e129b8dc68d02bbabf8f29.tar.gz
MPMs that require multiple segments of shared memory now just use two
shared memory blocks to ensure that all of the memory is available. This removes the hack that added 80 bytes to each shared memory block. We end up needing two apr_shmem_t variables, because it is difficult to determine exactly how much memory will be needed. MM automatically tries to align the shared memory allocations, so we either need to pad the shared memory segments, or just use two different segments. This also changes APR and MM to take into account whatever memory those packages need to allocate when creating a shared memory segment. Any memory that APR and MM need is automatically added to the size requested by the program. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60842 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem')
-rw-r--r--shmem/unix/mm/mm.h5
-rw-r--r--shmem/unix/mm/mm_alloc.c6
-rw-r--r--shmem/unix/mm/mm_global.c2
-rw-r--r--shmem/unix/mm/mm_test.c2
-rw-r--r--shmem/unix/shmem.c2
5 files changed, 12 insertions, 5 deletions
diff --git a/shmem/unix/mm/mm.h b/shmem/unix/mm/mm.h
index bc14b1ac8..9d2542591 100644
--- a/shmem/unix/mm/mm.h
+++ b/shmem/unix/mm/mm.h
@@ -66,6 +66,9 @@ typedef enum {
MM_LOCK_RD, MM_LOCK_RW
} mm_lock_mode;
+#define MM_ALLOCATE_ENOUGH 1
+#define MM_ALLOCATE_EXACT 2
+
/*
** ____ Private Part of the API ___________________________
*/
@@ -339,7 +342,7 @@ size_t MM_available(void);
char *MM_error(void);
/* Standard Malloc-Style API */
-MM *mm_create(size_t size, const char *file);
+MM *mm_create(size_t size, const char *file, int flag);
int mm_permission(MM *mm, mode_t mode, uid_t owner, gid_t group);
void mm_destroy(MM *mm);
int mm_lock(MM *mm, mm_lock_mode mode);
diff --git a/shmem/unix/mm/mm_alloc.c b/shmem/unix/mm/mm_alloc.c
index 00d59d295..6efcbfc21 100644
--- a/shmem/unix/mm/mm_alloc.c
+++ b/shmem/unix/mm/mm_alloc.c
@@ -50,7 +50,7 @@
/*
* Create a memory pool
*/
-MM *mm_create(size_t usize, const char *file)
+MM *mm_create(size_t usize, const char *file, int flag)
{
MM *mm = NULL;
void *core;
@@ -66,6 +66,10 @@ MM *mm_create(size_t usize, const char *file)
if (usize < MM_ALLOC_MINSIZE)
usize = MM_ALLOC_MINSIZE;
+ if (flag & MM_ALLOCATE_ENOUGH) {
+ usize += sizeof(*mm);
+ }
+
/* determine size */
size = usize+SIZEOF_mem_pool;
diff --git a/shmem/unix/mm/mm_global.c b/shmem/unix/mm/mm_global.c
index 33b046463..6f9967fea 100644
--- a/shmem/unix/mm/mm_global.c
+++ b/shmem/unix/mm/mm_global.c
@@ -53,7 +53,7 @@ int MM_create(size_t size, const char *file)
{
if (mm_global != NULL)
return FALSE;
- if ((mm_global = mm_create(size, file)) == NULL)
+ if ((mm_global = mm_create(size, file, MM_ALLOCATE_EXACT)) == NULL)
return FALSE;
return TRUE;
}
diff --git a/shmem/unix/mm/mm_test.c b/shmem/unix/mm/mm_test.c
index 5c344d49a..922529bf0 100644
--- a/shmem/unix/mm/mm_test.c
+++ b/shmem/unix/mm/mm_test.c
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
size = mm_maxsize();
if (size > 1024*1024*1)
size = 1024*1024*1;
- mm = mm_create(size, NULL);
+ mm = mm_create(size, NULL, MM_ALLOCATE_EXACT);
FAILED_IF(mm == NULL)
mm_display_info(mm);
s = mm_available(mm);
diff --git a/shmem/unix/shmem.c b/shmem/unix/shmem.c
index 34bb94ff6..4970b19d8 100644
--- a/shmem/unix/shmem.c
+++ b/shmem/unix/shmem.c
@@ -63,7 +63,7 @@ struct shmem_t {
apr_status_t apr_shm_init(struct shmem_t **m, apr_size_t reqsize, const char *file, apr_pool_t *cont)
{
- MM *newmm = mm_create(reqsize, file);
+ MM *newmm = mm_create(reqsize + sizeof(*newmm), file, MM_ALLOCATE_ENOUGH);
if (newmm == NULL) {
return errno;
}