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