On Tue, Oct 16, 2018 at 02:28:06PM +0200, Ruediger Pluem wrote:
> Gentle ping :-). Did you find some time to have a look?

"I'm not Greg, but..."

This seems to be duplicating the ctx->scratchpool which was added for 
use in dav_propfind_walker specifically to solve this kind of problem, I 
think?

I see constant memory use for a simple PROPFIND/depth:1 for the 
attached, though I'm not sure this is sufficient to repro the problem 
you saw before.

I think the patch makes sense anyway, though I don't remember why that 
dav_close_propdb() wasn't destroying the pool before, hopefully Greg 
does.

Regards, Joe
Index: modules/dav/main/mod_dav.c
===================================================================
--- modules/dav/main/mod_dav.c  (revision 1843977)
+++ modules/dav/main/mod_dav.c  (working copy)
@@ -2027,8 +2027,9 @@
     ** Note: we cast to lose the "const". The propdb won't try to change
     ** the resource, however, since we are opening readonly.
     */
-    err = dav_open_propdb(ctx->r, ctx->w.lockdb, wres->resource, 1,
-                          ctx->doc ? ctx->doc->namespaces : NULL, &propdb);
+    err = dav_popen_propdb(ctx->scratchpool,
+                           ctx->r, ctx->w.lockdb, wres->resource, 1,
+                           ctx->doc ? ctx->doc->namespaces : NULL, &propdb);
     if (err != NULL) {
         /* ### do something with err! */
 
Index: modules/dav/main/mod_dav.h
===================================================================
--- modules/dav/main/mod_dav.h  (revision 1843977)
+++ modules/dav/main/mod_dav.h  (working copy)
@@ -1596,6 +1596,16 @@
     apr_array_header_t *ns_xlate,
     dav_propdb **propdb);
 
+DAV_DECLARE(dav_error *) dav_popen_propdb(
+    apr_pool_t *p,
+    request_rec *r,
+    dav_lockdb *lockdb,
+    const dav_resource *resource,
+    int ro,
+    apr_array_header_t *ns_xlate,
+    dav_propdb **propdb);
+
+
 DAV_DECLARE(void) dav_close_propdb(dav_propdb *db);
 
 DAV_DECLARE(dav_get_props_result) dav_get_props(
Index: modules/dav/main/props.c
===================================================================
--- modules/dav/main/props.c    (revision 1843977)
+++ modules/dav/main/props.c    (working copy)
@@ -524,22 +524,21 @@
                                         apr_array_header_t * ns_xlate,
                                         dav_propdb **p_propdb)
 {
+    return dav_popen_propdb(r->pool, r, lockdb, resource, ro, ns_xlate, 
p_propdb);
+}
+
+DAV_DECLARE(dav_error *)dav_popen_propdb(apr_pool_t *p,
+                                         request_rec *r, dav_lockdb *lockdb,
+                                         const dav_resource *resource,
+                                         int ro,
+                                         apr_array_header_t * ns_xlate,
+                                         dav_propdb **p_propdb)
+{
     dav_propdb *propdb = NULL;
-    /*
-     * Check if we have tucked away a previous propdb and reuse it.
-     * Otherwise create a new one and tuck it away
-     */
-    apr_pool_userdata_get((void **)&propdb, "propdb", r->pool);
-    if (!propdb) {
-        propdb = apr_pcalloc(r->pool, sizeof(*propdb));
-        apr_pool_userdata_setn(propdb, "propdb", NULL, r->pool);
-        apr_pool_create(&propdb->p, r->pool);
-    }
-    else {
-        /* Play safe and clear the pool of the reused probdb */
-        apr_pool_clear(propdb->p);
-    }
 
+    propdb = apr_pcalloc(p, sizeof(*propdb));
+    propdb->p = p;
+
     *p_propdb = NULL;
 
 #if DAV_DEBUG

Reply via email to