From 3ec324f9ff4c136c7f7951a49d96c8202f40f382 Mon Sep 17 00:00:00 2001 From: Ruediger Pluem Date: Wed, 9 Feb 2022 12:29:13 +0000 Subject: [PATCH] Merge r1897182, r1897614, r1897615, r1897619 from trunk: * Allocate the dav_liveprop_elem structure only once in the lifetime of the resource->pool and reuse it to avoid unnecessary huge memory allocations during collection walks. * CHANGES entry for r1897182 * Fix typo * Stupid mine. Evgeny is a committer here Reviewed by: rpluem, jorton, ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1897901 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 12 ------------ changes-entries/mod_dav_memory_regresssion.txt | 3 +++ modules/dav/main/props.c | 10 ++++++++-- 3 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 changes-entries/mod_dav_memory_regresssion.txt diff --git a/STATUS b/STATUS index 26d4c8e3b0e..670b6155b95 100644 --- a/STATUS +++ b/STATUS @@ -179,18 +179,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: Proposed for backport below, in place of or after this one. rpluem: +1 on PR 289 as well. - *) mod_dav: Fix regression when gathering properties which could lead to huge - memory consumption proportional to the number of resources. - Trunk version of patch: - https://svn.apache.org/r1897182 - https://svn.apache.org/r1897614 - https://svn.apache.org/r1897615 - https://svn.apache.org/r1897619 - Backport version for 2.4.x of patch: - Trunk version of patch works - svn merge -c 1897182,1897614,1897615,1897619 ^/httpd/httpd/trunk . - +1: rpluem, jorton, ylavic - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/changes-entries/mod_dav_memory_regresssion.txt b/changes-entries/mod_dav_memory_regresssion.txt new file mode 100644 index 00000000000..65b50c5756a --- /dev/null +++ b/changes-entries/mod_dav_memory_regresssion.txt @@ -0,0 +1,3 @@ + *) mod_dav: Fix regression when gathering properties which could lead to huge + memory consumption proportional to the number of resources. + [Evgeny Kotkov, Ruediger Pluem] diff --git a/modules/dav/main/props.c b/modules/dav/main/props.c index a117bc0395e..9ad6d6db584 100644 --- a/modules/dav/main/props.c +++ b/modules/dav/main/props.c @@ -728,9 +728,15 @@ DAV_DECLARE(dav_get_props_result) dav_get_props(dav_propdb *propdb, /* we lose both the document and the element when calling (insert_prop), * make these available in the pool. */ - element = apr_pcalloc(propdb->resource->pool, sizeof(dav_liveprop_elem)); + element = dav_get_liveprop_element(propdb->resource); + if (!element) { + element = apr_pcalloc(propdb->resource->pool, sizeof(dav_liveprop_elem)); + apr_pool_userdata_setn(element, DAV_PROP_ELEMENT, NULL, propdb->resource->pool); + } + else { + memset(element, 0, sizeof(dav_liveprop_elem)); + } element->doc = doc; - apr_pool_userdata_setn(element, DAV_PROP_ELEMENT, NULL, propdb->resource->pool); /* ### NOTE: we should pass in TWO buffers -- one for keys, one for the marks */ -- 2.47.2