apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r658105 - in /apr/apr/trunk: CHANGES shmem/win32/shm.c
Date Tue, 20 May 2008 05:40:36 GMT
Author: mturk
Date: Mon May 19 22:40:36 2008
New Revision: 658105

URL: http://svn.apache.org/viewvc?rev=658105&view=rev
Log:
Remove shm backed file on cleanup/remove for creator

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/shmem/win32/shm.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=658105&r1=658104&r2=658105&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Mon May 19 22:40:36 2008
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.4.0
 
+  *) Make sure WIN32 behaves the same as posix for file backed
+     shared memory by removing the file on cleanup/remove.
+     [Mladen Turk]
+
   *) Fix Solaris poll failure.  PR 43000
      [Henry Jen <henryjen ztune.net>]
 

Modified: apr/apr/trunk/shmem/win32/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/shmem/win32/shm.c?rev=658105&r1=658104&r2=658105&view=diff
==============================================================================
--- apr/apr/trunk/shmem/win32/shm.c (original)
+++ apr/apr/trunk/shmem/win32/shm.c Mon May 19 22:40:36 2008
@@ -18,6 +18,7 @@
 #include "apr_errno.h"
 #include "apr_file_io.h"
 #include "apr_shm.h"
+#include "apr_strings.h"
 #include "apr_arch_file_io.h"
 #include "limits.h"
 
@@ -33,6 +34,7 @@
     apr_size_t  size;
     apr_size_t  length;
     HANDLE      hMap;
+    const char *filename;
 };
 
 static apr_status_t shm_cleanup(void* shm)
@@ -44,11 +46,13 @@
         rv = apr_get_os_error();
     }
     if (!CloseHandle(m->hMap)) {
-        return (rv != APR_SUCCESS) ? rv : apr_get_os_error();
+        rv = rv != APR_SUCCESS ? rv : apr_get_os_error();
+    }
+    if (m->filename) {
+        /* Remove file if file backed */
+        apr_status_t rc = apr_file_remove(m->filename, m->pool);
+        rv = rv != APR_SUCCESS ? rv : rc;
     }
-    /* ### Do we want to make a point of unlinking m->file here? 
-     * Need to add the fname to the apr_shm_t, in that case.
-     */
     return rv;
 }
 
@@ -159,6 +163,7 @@
     
     (*m)->memblk->length = (*m)->length;
     (*m)->memblk->size = (*m)->size;
+    (*m)->filename = file ? apr_pstrdup(pool, file) : NULL;
 
     apr_pool_cleanup_register((*m)->pool, *m, 
                               shm_cleanup, apr_pool_cleanup_null);
@@ -252,6 +257,8 @@
     (*m)->hMap = hMap;
     (*m)->length = (*m)->memblk->length;
     (*m)->usrmem = (char*)base + sizeof(memblock_t);
+    (*m)->filename = NULL;
+
     apr_pool_cleanup_register((*m)->pool, *m, 
                               shm_cleanup, apr_pool_cleanup_null);
     return APR_SUCCESS;
@@ -301,6 +308,7 @@
     /* Real (*m)->mem->size could be recovered with VirtualQuery */
     (*m)->size = (*m)->memblk->size;
     (*m)->length = (*m)->memblk->length;
+    (*m)->filename = NULL;
 
     apr_pool_cleanup_register((*m)->pool, *m, 
                               shm_cleanup, apr_pool_cleanup_null);



Mime
View raw message