--- mm_core.c 2002/12/19 09:25:24 1.19
+++ mm_core.c 2003/03/07 14:59:15 1.20
@@ -189,7 +189,9 @@
{
mem_core *mc;
void *area = ((void *)-1);
+#if defined(MM_SHMT_MMPOSX) || defined(MM_SHMT_MMZERO) || defined(MM_SHMT_MMFILE) || defined(MM_SHMT_IPCSHM)
int fdmem = -1;
+#endif
int fdsem = -1;
#if defined(MM_SEMT_IPCSEM)
int fdsem_rd = -1;
@@ -262,6 +264,7 @@
MAP_SHARED, fdmem, mm_core_mapoffset)) == (void *)MAP_FAILED)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to memory map tempfile");
shm_unlink(fnmem);
+ close(fdmem); fdmem = -1;
mm_core_mapoffset += size;
#endif /* MM_SHMT_MMPOSX */
@@ -278,6 +281,7 @@
if ((area = (void *)mmap(NULL, size, PROT_READ|PROT_WRITE,
MAP_SHARED, fdmem, mm_core_mapoffset)) == (void *)MAP_FAILED)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to memory map /dev/zero");
+ close(fdmem); fdmem = -1;
mm_core_mapoffset += size;
#endif /* MM_SHMT_MMZERO */
@@ -295,6 +299,7 @@
if ((area = (void *)mmap(NULL, size, PROT_READ|PROT_WRITE,
MAP_SHARED, fdmem, mm_core_mapoffset)) == (void *)MAP_FAILED)
FAIL(MM_ERR_CORE|MM_ERR_SYSTEM, "failed to memory map memory file");
+ close(fdmem); fdmem = -1;
mm_core_mapoffset += size;
#endif /* MM_SHMT_MMFILE */
@@ -357,7 +362,9 @@
mc->mc_size = size;
mc->mc_usize = usersize;
mc->mc_pid = getpid();
+#if defined(MM_SHMT_IPCSHM)
mc->mc_fdmem = fdmem;
+#endif
#if defined(MM_SEMT_FLOCK)
mc->mc_fdsem[0].pid = getpid();
mc->mc_fdsem[0].fd = fdsem;
@@ -401,7 +408,7 @@
if (area != ((void *)-1))
shmdt(area);
#endif
-#if defined(MM_SHMT_MMPOSX) || defined(MM_SHMT_MMFILE)
+#if defined(MM_SHMT_MMPOSX) || defined(MM_SHMT_MMZERO) || defined(MM_SHMT_MMFILE)
if (fdmem != -1)
close(fdmem);
#endif
@@ -489,7 +496,9 @@
void mm_core_delete(void *core)
{
mem_core *mc;
+#if defined(MM_SHMT_IPCSHM)
int fdmem;
+#endif
int fdsem;
#if defined(MM_SEMT_IPCSEM)
int fdsem_rd;
@@ -506,7 +515,9 @@
return;
mc = (mem_core *)((char *)core-SIZEOF_mem_core);
size = mc->mc_size;
+#if defined(MM_SHMT_IPCSHM)
fdmem = mc->mc_fdmem;
+#endif
#if !defined(MM_SEMT_FLOCK)
fdsem = mc->mc_fdsem;
#endif
@@ -530,9 +541,6 @@
shmdt((void *)mc);
shmctl(fdmem, IPC_RMID, NULL);
#endif
-#if defined(MM_SHMT_MMPOSX) || defined(MM_SHMT_MMZERO) || defined(MM_SHMT_MMFILE)
- close(fdmem);
-#endif
#if defined(MM_SHMT_MMFILE)
unlink(fnmem);
#endif
|