On Wed, Oct 17, 2018 at 03:32:34PM +0100, Joe Orton wrote:
> 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 needed to also remove the new apr_pool_clear() there.  Is the repro 
case for this something other than depth:1 PROPFIND?  Am seing constant 
memory use with

$ mkdir t/htdocs/modules/dav/
$ (cd t/htdocs/modules/dav/; 
  seq 1 100000 | sed 's/^/file.b/;s/$/.txt/' | xargs -n100 touch )
$ ./t/TEST -start

and then run a PROPFIND against /modules/dav/

Curiously inefficient writev use when stracing the process, though, 
dunno what's going on there (trunk/prefork):

writev(46, [{iov_base="\r\n", iov_len=2}], 1) = 2
writev(46, [{iov_base="1f84\r\n", iov_len=6}], 1) = 6
writev(46, [{iov_base="<D:lockdiscovery/>\n<D:getcontent"..., iov_len=7820}], 
1) = 7820
writev(46, [{iov_base="<D:supportedlock>\n<D:lockentry>\n"..., iov_len=248}], 
1) = 248


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
@@ -579,8 +578,6 @@
         ap_destroy_sub_req(propdb->subreq);
         propdb->subreq = NULL;
     }
-
-    apr_pool_clear(propdb->p);
 }
 
 DAV_DECLARE(dav_get_props_result) dav_get_allprops(dav_propdb *propdb,

Reply via email to