]> granicus.if.org Git - apache/commitdiff
Simplify handling of short-lived pool for dav_propdb in mod_dav. No
authorJoe Orton <jorton@apache.org>
Tue, 25 Jun 2019 08:54:01 +0000 (08:54 +0000)
committerJoe Orton <jorton@apache.org>
Tue, 25 Jun 2019 08:54:01 +0000 (08:54 +0000)
functional change.

* modules/dav/main/props.c (dav_popen_propdb): Rename from
  dav_open_propdb, take a pool argument.
  (dav_open_propdb): Reimplement in terms of above, using
  r->pool.
  (dav_propfind_walker): Switch to using dav_open_propdb
  with scratchpool.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1862039 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/main/mod_dav.c
modules/dav/main/mod_dav.h
modules/dav/main/props.c

index 54a3eb5531b534e990d08918ac1881a37e2303c4..a6cc321f77052499101d40dffcca31bdec2413a4 100644 (file)
@@ -2027,8 +2027,9 @@ static dav_error * dav_propfind_walker(dav_walk_resource *wres, int calltype)
     ** 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 cb7cac9abbd5c3d8c7c9a272d14d7809652a5b21..45d325d52b45afbd9a40ade478e78e246357689b 100644 (file)
@@ -1596,6 +1596,16 @@ DAV_DECLARE(dav_error *) dav_open_propdb(
     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 3b95dc4ed2a84654f4e4d650cad70f567a52448b..f8c4e9b4a0cb51e78642cca4bd776dcd943eef6e 100644 (file)
@@ -523,22 +523,21 @@ DAV_DECLARE(dav_error *)dav_open_propdb(request_rec *r, dav_lockdb *lockdb,
                                         int ro,
                                         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;
 
@@ -579,8 +578,6 @@ DAV_DECLARE(void) dav_close_propdb(dav_propdb *propdb)
         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,