OSSP CVS Repository

ossp - Check-in [3300]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3300
Date: 2003-Mar-07 15:59:15 (local)
2003-Mar-07 14:59:15 (UTC)
User:rse
Branch:
Comment: 1. Correctly cleanup under MM_SHMT_MMZERO in case of a shared memory segment creation error.

2. Close the filedescriptor of the underlying object immediately after mmap(2)'ing it in case of MM_SHMT_MMPOSX, MM_SHMT_MMZERO and MM_SHMT_MMFILE.

Hints by: Joe Orton <jorton@redhat.com>

Tickets:
Inspections:
Files:
ossp-pkg/mm/ChangeLog      1.43 -> 1.44     11 inserted, 0 deleted
ossp-pkg/mm/mm.h      1.27 -> 1.28     2 inserted, 0 deleted
ossp-pkg/mm/mm_core.c      1.19 -> 1.20     12 inserted, 4 deleted

ossp-pkg/mm/ChangeLog 1.43 -> 1.44

--- ChangeLog    2002/12/23 19:32:54     1.43
+++ ChangeLog    2003/03/07 14:59:15     1.44
@@ -14,6 +14,17 @@
     | |_ / __/
   __|_(_)_____|______________________________________________________
 
+ Changes between 1.2.2 and 1.3.0 (23-Dec-2002 to 07-Mar-2003)
+
+  *) Correctly cleanup under MM_SHMT_MMZERO in case of a shared
+     memory segment creation error.
+     [Ralf S. Engelschall]
+
+  *) Close the filedescriptor of the underlying object immediately
+     after mmap(2)'ing it in case of MM_SHMT_MMPOSX, MM_SHMT_MMZERO
+     and MM_SHMT_MMFILE.
+     [Ralf S. Engelschall, Joe Orton <jorton@redhat.com>]
+
  Changes between 1.2.1 and 1.2.2 (28-Jul-2002 to 23-Dec-2002)
 
   *) Stripped trailing whitespaces from all files in source tree.


ossp-pkg/mm/mm.h 1.27 -> 1.28

--- mm.h 2002/12/19 09:25:23     1.27
+++ mm.h 2003/03/07 14:59:15     1.28
@@ -284,7 +284,9 @@
    size_t       mc_size;
    size_t       mc_usize;
    pid_t        mc_pid;
+#if defined(MM_SHMT_IPCSHM)
    int          mc_fdmem;
+#endif
 #if defined(MM_SHMT_MMFILE)
    char         mc_fnmem[MM_MAXPATH];
 #endif


ossp-pkg/mm/mm_core.c 1.19 -> 1.20

--- 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

CVSTrac 2.0.1