summaryrefslogtreecommitdiff
path: root/mmap/unix/mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mmap/unix/mmap.c')
-rw-r--r--mmap/unix/mmap.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/mmap/unix/mmap.c b/mmap/unix/mmap.c
index 4a54b860e..707702662 100644
--- a/mmap/unix/mmap.c
+++ b/mmap/unix/mmap.c
@@ -83,13 +83,17 @@
static apr_status_t mmap_cleanup(void *themmap)
{
apr_mmap_t *mm = themmap;
- int rv;
+ apr_mmap_t *next = APR_RING_NEXT(mm,link);
+ int rv = 0;
- if (!mm->is_owner) {
- return APR_EINVAL;
- }
- else if (mm->mm == (void *)-1) {
- return APR_ENOENT;
+ /* we no longer refer to the mmaped region */
+ APR_RING_REMOVE(mm,link);
+ APR_RING_NEXT(mm,link) = NULL;
+ APR_RING_PREV(mm,link) = NULL;
+
+ if (next != mm) {
+ /* more references exist, so we're done */
+ return APR_SUCCESS;
}
#ifdef BEOS
@@ -163,7 +167,7 @@ APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **new,
(*new)->mm = mm;
(*new)->size = size;
(*new)->cntxt = cont;
- (*new)->is_owner = 1;
+ APR_RING_ELEM_INIT(*new, link);
/* register the cleanup... */
apr_pool_cleanup_register((*new)->cntxt, (void*)(*new), mmap_cleanup,
@@ -179,21 +183,10 @@ APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap,
*new_mmap = (apr_mmap_t *)apr_pmemdup(p, old_mmap, sizeof(apr_mmap_t));
(*new_mmap)->cntxt = p;
- /* The old_mmap can transfer ownership only if the old_mmap itself
- * is an owner of the mmap'ed segment.
- */
- if (old_mmap->is_owner) {
- if (transfer_ownership) {
- (*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_RING_INSERT_AFTER(old_mmap, *new_mmap, link);
+
+ apr_pool_cleanup_register(p, *new_mmap, mmap_cleanup,
+ apr_pool_cleanup_null);
return APR_SUCCESS;
}