1
1

This fixes the initialization of the usable size of the shared memory.

The original code was not compensating for the space used by the header.  

When memory got tight, the allocator would return a pointer to memory that 
did not exist resulting in a SEGV for the application.  This is a partial 
fix for ticket #929.

Reviewed by Rich Graham.  

This commit was SVN r13950.
Этот коммит содержится в:
Rolf vandeVaart 2007-03-07 13:28:06 +00:00
родитель fe3ea0085f
Коммит 333357f4cc

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -165,7 +166,8 @@ mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
/* initialize the segment - only the first process to open the file */
seg->seg_offset = mem_offset;
seg->seg_size = size;
/* initialize size after subtracting out space used by the header */
seg->seg_size = size - mem_offset;
opal_atomic_unlock(&seg->seg_lock);
seg->seg_inited = false;
@ -370,7 +372,8 @@ mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
opal_atomic_unlock(&seg->seg_lock);
seg->seg_inited = false;
seg->seg_offset = mem_offset;
seg->seg_size = size;
/* initialize size after subtracting out space used by the header */
seg->seg_size = size - mem_offset;
}
map->hMappedObject = hMapObject;
@ -432,7 +435,7 @@ void* mca_common_sm_mmap_seg_alloc(
void* addr;
opal_atomic_lock(&seg->seg_lock);
if(seg->seg_offset + *size > map->map_size) {
if(seg->seg_offset + *size > seg->seg_size) {
addr = NULL;
} else {
size_t fixup;