You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Cliff Woolley <jw...@virginia.edu> on 2002/04/10 06:17:33 UTC

[PATCH] mmap/win32/mmap.c

This is the patch for win32 that fixes up the is_owner cleanup problem.
It should correspond exactly to the patch for unix/mmap.c that I posted to
dev@httpd the other day.

Pretty simple.

--Cliff

Index: mmap.c
===================================================================
RCS file: /home/cvs/apr/mmap/win32/mmap.c,v
retrieving revision 1.11
diff -u -d -r1.11 mmap.c
--- mmap.c	13 Mar 2002 20:39:24 -0000	1.11
+++ mmap.c	10 Apr 2002 04:16:31 -0000
@@ -68,8 +68,9 @@
     apr_mmap_t *mm = themmap;
     apr_status_t rv = 0;

-    if (!mm->is_owner) {
-        return APR_SUCCESS;
+    if (!mm->is_owner || !mm->mhandle) {
+        /* XXX: we shouldn't ever get here */
+        return APR_ENOENT;
     }

     if (mm->mv) {
@@ -184,21 +185,21 @@
             (*new_mmap)->is_owner = 1;
             old_mmap->is_owner = 0;
             apr_pool_cleanup_kill(old_mmap->cntxt, old_mmap, mmap_cleanup);
+            apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup,
+                                      apr_pool_cleanup_null);
         }
         else {
             (*new_mmap)->is_owner = 0;
         }
-        apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup,
-                                  apr_pool_cleanup_null);
     }
     return APR_SUCCESS;
 }

 APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm)
 {
-    apr_status_t rv;
+    apr_status_t rv = APR_SUCCESS;

-    if ((rv = mmap_cleanup(mm)) == APR_SUCCESS) {
+    if (mm->is_owner && ((rv = mmap_cleanup(mm)) == APR_SUCCESS)) {
         apr_pool_cleanup_kill(mm->cntxt, mm, mmap_cleanup);
         return APR_SUCCESS;
     }

--------------------------------------------------------------
   Cliff Woolley
   cliffwoolley@yahoo.com
   Charlottesville, VA