summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2018-07-16 13:06:57 +0200
committerYann Ylavic <ylavic@apache.org>2018-07-16 13:06:57 +0200
commiteb5e821beae8362ccc6b8b30d0d8a02d4131b8e1 (patch)
tree877f2536acd57602e1e77b5d2784477f09aa9af9 /server
parentutil_filter: follow up to r1835640: pending_filter_cleanup() precedence. (diff)
downloadapache2-eb5e821beae8362ccc6b8b30d0d8a02d4131b8e1.tar.xz
apache2-eb5e821beae8362ccc6b8b30d0d8a02d4131b8e1.zip
core: Add ap_reuse_brigade_from_pool().
Current RETRIEVE_BRIGADE_FROM_POOL macro from "http_request.c" is turned into a helper and used in ap_request_core_filter(). We will need it in a subsequent commit in "util_filter.c" too. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1836018 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/request.c14
-rw-r--r--server/util.c16
2 files changed, 20 insertions, 10 deletions
diff --git a/server/request.c b/server/request.c
index 1297cf007e..926148cf73 100644
--- a/server/request.c
+++ b/server/request.c
@@ -2081,13 +2081,8 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_request_core_filter(ap_filter_t *f,
}
if (!tmp_bb) {
- const char *tmp_bb_key = "ap_request_core_filter_bb";
- tmp_bb = (void *)apr_table_get(f->c->notes, tmp_bb_key);
- if (!tmp_bb) {
- tmp_bb = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
- apr_table_setn(f->c->notes, tmp_bb_key, (void *)tmp_bb);
- }
- f->ctx = tmp_bb;
+ f->ctx = tmp_bb = ap_reuse_brigade_from_pool("ap_rcf_bb", f->c->pool,
+ f->c->bucket_alloc);
}
/* Reinstate any buffered content */
@@ -2137,13 +2132,12 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_request_core_filter(ap_filter_t *f,
}
status = ap_pass_brigade(f->next, tmp_bb);
+ apr_brigade_cleanup(tmp_bb);
+
if (seen_eor || (status != APR_SUCCESS &&
!APR_STATUS_IS_EOF(status))) {
- apr_brigade_cleanup(tmp_bb);
return status;
}
-
- apr_brigade_cleanup(tmp_bb);
}
return ap_filter_setaside_brigade(f, bb);
diff --git a/server/util.c b/server/util.c
index 38ed346ce1..57d3023979 100644
--- a/server/util.c
+++ b/server/util.c
@@ -2675,6 +2675,22 @@ AP_DECLARE_NONSTD(apr_status_t) ap_pool_cleanup_set_null(void *data_)
return APR_SUCCESS;
}
+AP_DECLARE(apr_bucket_brigade *) ap_reuse_brigade_from_pool(const char *key,
+ apr_pool_t *pool,
+ apr_bucket_alloc_t *alloc)
+{
+ apr_bucket_brigade *bb = NULL;
+ apr_pool_userdata_get((void **)&bb, key, pool);
+ if (bb == NULL) {
+ bb = apr_brigade_create(pool, alloc);
+ apr_pool_userdata_set(bb, key, NULL, pool);
+ }
+ else {
+ apr_brigade_cleanup(bb);
+ }
+ return bb;
+}
+
AP_DECLARE(apr_status_t) ap_str2_alnum(const char *src, char *dest) {
for ( ; *src; src++, dest++)