diff options
author | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2008-05-21 04:56:19 +0000 |
---|---|---|
committer | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2008-05-21 04:56:19 +0000 |
commit | 3f03879a41309a4604232caa3c73b25e595d983a (patch) | |
tree | 8d38ff167a1bb290f3513e83fc5ec370041e6ee6 /shmem | |
parent | cd2b215824de151f69860a866d203785ea5ea6a7 (diff) | |
download | libapr-3f03879a41309a4604232caa3c73b25e595d983a.tar.gz |
Backport r658105 from trunk
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.3.x@658555 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'shmem')
-rw-r--r-- | shmem/win32/shm.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/shmem/win32/shm.c b/shmem/win32/shm.c index 580421e33..da736aa62 100644 --- a/shmem/win32/shm.c +++ b/shmem/win32/shm.c @@ -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 @@ struct apr_shm_t { 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 @@ static apr_status_t shm_cleanup(void* shm) 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 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, (*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 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, (*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 @@ APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m, /* 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); |