96af6c
--- a/modules/dav/main/mod_dav.c
96af6c
+++ b/modules/dav/main/mod_dav.c
96af6c
@@ -557,6 +557,7 @@
96af6c
     dav_begin_multistatus(bb, r, status, namespaces);
96af6c
 
96af6c
     apr_pool_create(&subpool, r->pool);
96af6c
+    apr_pool_tag(subpool, "mod_dav-multistatus");
96af6c
 
96af6c
     for (; first != NULL; first = first->next) {
96af6c
       apr_pool_clear(subpool);
96af6c
@@ -1980,8 +1981,9 @@
96af6c
     ** Note: we cast to lose the "const". The propdb won't try to change
96af6c
     ** the resource, however, since we are opening readonly.
96af6c
     */
96af6c
-    err = dav_open_propdb(ctx->r, ctx->w.lockdb, wres->resource, 1,
96af6c
-                          ctx->doc ? ctx->doc->namespaces : NULL, &propdb);
96af6c
+    err = dav_popen_propdb(ctx->scratchpool,
96af6c
+                           ctx->r, ctx->w.lockdb, wres->resource, 1,
96af6c
+                           ctx->doc ? ctx->doc->namespaces : NULL, &propdb);
96af6c
     if (err != NULL) {
96af6c
         /* ### do something with err! */
96af6c
 
96af6c
--- a/modules/dav/main/mod_dav.h
96af6c
+++ b/modules/dav/main/mod_dav.h
96af6c
@@ -1590,6 +1590,16 @@
96af6c
     apr_array_header_t *ns_xlate,
96af6c
     dav_propdb **propdb);
96af6c
 
96af6c
+DAV_DECLARE(dav_error *) dav_popen_propdb(
96af6c
+    apr_pool_t *p,
96af6c
+    request_rec *r,
96af6c
+    dav_lockdb *lockdb,
96af6c
+    const dav_resource *resource,
96af6c
+    int ro,
96af6c
+    apr_array_header_t *ns_xlate,
96af6c
+    dav_propdb **propdb);
96af6c
+
96af6c
+
96af6c
 DAV_DECLARE(void) dav_close_propdb(dav_propdb *db);
96af6c
 
96af6c
 DAV_DECLARE(dav_get_props_result) dav_get_props(
96af6c
--- a/modules/dav/main/props.c
96af6c
+++ b/modules/dav/main/props.c
96af6c
@@ -323,7 +323,7 @@
96af6c
 {
96af6c
     /* need to escape the uri that's in the resource struct because during
96af6c
      * the property walker it's not encoded. */
96af6c
-    const char *e_uri = ap_escape_uri(propdb->resource->pool,
96af6c
+    const char *e_uri = ap_escape_uri(propdb->p,
96af6c
                                       propdb->resource->uri);
96af6c
 
96af6c
     /* perform a "GET" on the resource's URI (note that the resource
96af6c
@@ -524,8 +524,21 @@
96af6c
                                         apr_array_header_t * ns_xlate,
96af6c
                                         dav_propdb **p_propdb)
96af6c
 {
96af6c
-    dav_propdb *propdb = apr_pcalloc(r->pool, sizeof(*propdb));
96af6c
+    return dav_popen_propdb(r->pool, r, lockdb, resource, ro, ns_xlate, p_propdb);
96af6c
+}
96af6c
 
96af6c
+DAV_DECLARE(dav_error *)dav_popen_propdb(apr_pool_t *p,
96af6c
+                                         request_rec *r, dav_lockdb *lockdb,
96af6c
+                                         const dav_resource *resource,
96af6c
+                                         int ro,
96af6c
+                                         apr_array_header_t * ns_xlate,
96af6c
+                                         dav_propdb **p_propdb)
96af6c
+{
96af6c
+    dav_propdb *propdb = NULL;
96af6c
+
96af6c
+    propdb = apr_pcalloc(p, sizeof(*propdb));
96af6c
+    propdb->p = p;
96af6c
+
96af6c
     *p_propdb = NULL;
96af6c
 
96af6c
 #if DAV_DEBUG
96af6c
@@ -537,7 +550,6 @@
96af6c
 #endif
96af6c
 
96af6c
     propdb->r = r;
96af6c
-    apr_pool_create(&propdb->p, r->pool);
96af6c
     propdb->resource = resource;
96af6c
     propdb->ns_xlate = ns_xlate;
96af6c
 
96af6c
@@ -562,10 +574,10 @@
96af6c
         (*propdb->db_hooks->close)(propdb->db);
96af6c
     }
96af6c
 
96af6c
-    /* Currently, mod_dav's pool usage doesn't allow clearing this pool. */
96af6c
-#if 0
96af6c
-    apr_pool_destroy(propdb->p);
96af6c
-#endif
96af6c
+    if (propdb->subreq) {
96af6c
+        ap_destroy_sub_req(propdb->subreq);
96af6c
+        propdb->subreq = NULL;
96af6c
+    }
96af6c
 }
96af6c
 
96af6c
 DAV_DECLARE(dav_get_props_result) dav_get_allprops(dav_propdb *propdb,
96af6c
@@ -739,7 +751,8 @@
96af6c
         */
96af6c
 
96af6c
         if (elem->priv == NULL) {
96af6c
-            elem->priv = apr_pcalloc(propdb->p, sizeof(*priv));
96af6c
+            /* elem->priv outlives propdb->p. Hence use the request pool */
96af6c
+            elem->priv = apr_pcalloc(propdb->r->pool, sizeof(*priv));
96af6c
         }
96af6c
         priv = elem->priv;
96af6c