From 72f9b1df14ad645311c6500198ce93ef48fd94fe Mon Sep 17 00:00:00 2001 From: Rich Graham Date: Thu, 18 Nov 2004 04:18:33 +0000 Subject: [PATCH] remove the shared memory control backing file on termination. remove some debug code. This commit was SVN r3615. --- src/mca/common/sm/common_sm_mmap.c | 5 ----- src/mca/ptl/sm/src/ptl_sm_component.c | 25 ++++++++++++++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/mca/common/sm/common_sm_mmap.c b/src/mca/common/sm/common_sm_mmap.c index 45271c78b1..3c55e69a69 100644 --- a/src/mca/common/sm/common_sm_mmap.c +++ b/src/mca/common/sm/common_sm_mmap.c @@ -99,11 +99,6 @@ mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name, return NULL; } - /* debug */ - fprintf(stderr," open %s \n",file_name); - fflush(stderr); - /* end debug */ - /* open the backing file - only the first process accessing this * file will succeed. */ fd=mca_common_sm_mmap_open(file_name); diff --git a/src/mca/ptl/sm/src/ptl_sm_component.c b/src/mca/ptl/sm/src/ptl_sm_component.c index 8e1129c960..4cbf56ba00 100644 --- a/src/mca/ptl/sm/src/ptl_sm_component.c +++ b/src/mca/ptl/sm/src/ptl_sm_component.c @@ -169,13 +169,36 @@ int mca_ptl_sm_component_open(void) int mca_ptl_sm_component_close(void) { + int return_value=OMPI_SUCCESS; + OBJ_DESTRUCT(&mca_ptl_sm_component.sm_lock); OBJ_DESTRUCT(&mca_ptl_sm_component.sm_send_requests); OBJ_DESTRUCT(&mca_ptl_sm_component.sm_first_frags); OBJ_DESTRUCT(&mca_ptl_sm_component.sm_second_frags); OBJ_DESTRUCT(&mca_ptl_sm_component.sm_pending_ack_lock); OBJ_DESTRUCT(&mca_ptl_sm_component.sm_pending_ack); - return OMPI_SUCCESS; + + /* unmap the shared memory control structure */ + return_value=munmap(mca_ptl_sm_component.mmap_file->map_addr, + mca_ptl_sm_component.mmap_file->map_size); + if(-1 == return_value) { + return_value=OMPI_ERROR; + ompi_output(0," munmap failed :: file - %s :: errno - %d \n", + mca_ptl_sm_component.mmap_file->map_addr, + errno); + goto CLEANUP; + } + + /* unlink file, so that it will be deleted when all references + * to it are gone - no error checking, since we want all procs + * to call this, so that in an abnormal termination scanario, + * this file will still get cleaned up */ + unlink(mca_ptl_sm_component.mmap_file->map_path); + +CLEANUP: + + /* return */ + return return_value; }