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