diff options
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | shmem/unix/mm/mm.h | 5 | ||||
-rw-r--r-- | shmem/unix/mm/mm_alloc.c | 6 | ||||
-rw-r--r-- | shmem/unix/mm/mm_global.c | 2 | ||||
-rw-r--r-- | shmem/unix/mm/mm_test.c | 2 | ||||
-rw-r--r-- | shmem/unix/shmem.c | 2 |
6 files changed, 17 insertions, 5 deletions
@@ -1,4 +1,9 @@ Changes with APR a9 + *) Make APR's shared memory routines always allocate enough memory + for the requested segment, the MM internal types, and the APR + internal types. + [Ryan Bloom] + *) Add APR_SIZE_T_FMT. Get the other APR_xx_T_FMT variables defined properly on AIX. [Jeff Trawick] 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; } |