apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r658555 - /apr/apr/branches/1.3.x/shmem/win32/shm.c
Date Wed, 21 May 2008 04:56:20 GMT
Author: mturk
Date: Tue May 20 21:56:19 2008
New Revision: 658555

URL: http://svn.apache.org/viewvc?rev=658555&view=rev
Log:
Backport r658105 from trunk

Modified:
    apr/apr/branches/1.3.x/shmem/win32/shm.c

Modified: apr/apr/branches/1.3.x/shmem/win32/shm.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/shmem/win32/shm.c?rev=658555&r1=658554&r2=658555&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/shmem/win32/shm.c (original)
+++ apr/apr/branches/1.3.x/shmem/win32/shm.c Tue May 20 21:56:19 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