remove semphore file at exit
authorGengbin Zheng <gzheng@illinois.edu>
Thu, 2 Feb 2012 17:38:38 +0000 (11:38 -0600)
committerGengbin Zheng <gzheng@illinois.edu>
Thu, 2 Feb 2012 17:38:38 +0000 (11:38 -0600)
src/arch/util/machine-pxshm.c
src/arch/util/machine-xpmem.c

index 841684e54c8df30cf82b7ca3ecb9d31b3072788a..b3a7106c979466c5e47174a025f43abe461a93ce 100644 (file)
@@ -600,20 +600,24 @@ void createShmObject(char *name,int size,char **pPtr){
 }
 
 void tearDownSharedBuffers(){
+#if PXSHM_LOCK
        int i;
        for(i= 0;i<pxshmContext->nodesize;i++){
-               if(i != pxshmContext->noderank){
-                       if(     shm_unlink(pxshmContext->recvBufNames[i]) < 0){
-                               fprintf(stderr,"Error from shm_unlink %s \n",strerror(errno));
-                       }
-
-#if PXSHM_LOCK
-                       sem_close(pxshmContext->recvBufs[i].mutex);
-                       //sem_unlink(pxshmContext->recvBufNames[i]);
-                       sem_close(pxshmContext->sendBufs[i].mutex);
-#endif
-               }
+           if(i != pxshmContext->noderank){
+                if (pxshmContext->recvBufs[i].mutex != NULL)
+                {
+                   sem_close(pxshmContext->recvBufs[i].mutex);
+                   if(shm_unlink(pxshmContext->recvBufNames[i]) < 0){
+                       fprintf(stderr,"Error from shm_unlink %s \n",strerror(errno));
+                   }
+                   sem_close(pxshmContext->sendBufs[i].mutex);
+                   sem_unlink(pxshmContext->sendBufNames[i]);
+                    pxshmContext->recvBufs[i].mutex = NULL;
+                    pxshmContext->sendBufs[i].mutex = NULL;
+                }
+           }
        }
+#endif
 };
 
 
index 20bb0c8833d370ec0f210a79e05361d346783379..7d9881839c94368ef12c93ce9e46343f4b4a91fd 100644 (file)
@@ -674,25 +674,26 @@ void removeXpmemFiles()
 }
 
 void tearDownSharedBuffers(){
+#if PXSHM_LOCK
        int i;
-       for(i= 0;i<xpmemContext->nodesize;i++){
-               if(i != xpmemContext->noderank){
-#if 0
-                       if(shm_unlink(xpmemContext->recvBufNames[i]) < 0) {
-                               fprintf(stderr,"Error from shm_unlink %s \n",strerror(errno));
-                       }
-#endif
-
-#if XPMEM_LOCK
-                       sem_close(xpmemContext->recvBufs[i].mutex);
-                       //sem_unlink(xpmemContext->recvBufNames[i]);
-                       sem_close(xpmemContext->sendBufs[i].mutex);
-#endif
-               }
+       for(i= 0;i<pxshmContext->nodesize;i++){
+           if(i != pxshmContext->noderank){
+                if (pxshmContext->recvBufs[i].mutex != NULL)
+                {
+                   sem_close(pxshmContext->recvBufs[i].mutex);
+                   if(shm_unlink(pxshmContext->recvBufNames[i]) < 0){
+                       fprintf(stderr,"Error from shm_unlink %s \n",strerror(errno));
+                   }
+                   sem_close(pxshmContext->sendBufs[i].mutex);
+                   sem_unlink(pxshmContext->sendBufNames[i]);
+                    pxshmContext->recvBufs[i].mutex = NULL;
+                    pxshmContext->sendBufs[i].mutex = NULL;
+                }
+           }
        }
+#endif
 };
 
-
 void initSendQ(XpmemSendQ *q,int size);
 
 void initAllSendQs(){