1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

BUCKET FREELISTS

Add an allocator-passing mechanism throughout the bucket brigades API.

From Apache's standpoint, the apr_bucket_alloc_t* used throughout a given
connection is stored in the conn_rec by the create_connection hook.  That
means it's the MPM's job to optimize recycling of apr_bucket_alloc_t's --
the MPM must ensure that no two threads can ever use the same one at the
same time, for instance.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94304 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Cliff Woolley
2002-03-29 08:17:26 +00:00
parent b699ec0f91
commit 3e2ce19baf
44 changed files with 396 additions and 266 deletions

View File

@@ -1,5 +1,10 @@
Changes with Apache 2.0.35 Changes with Apache 2.0.35
*) Change bucket brigades API to allow a "bucket allocator" to be
passed in at certain points. This allows us to implement freelists
so that we can stop using malloc/free so frequently.
[Cliff Woolley, Brian Pane]
*) Add support for macro expansion within the variable names in *) Add support for macro expansion within the variable names in
<!--#echo--> and <!--#set--> directives [Brian Pane] <!--#echo--> and <!--#set--> directives [Brian Pane]

16
STATUS
View File

@@ -1,5 +1,5 @@
APACHE 2.0 STATUS: -*-text-*- APACHE 2.0 STATUS: -*-text-*-
Last modified at [$Date: 2002/03/26 20:35:50 $] Last modified at [$Date: 2002/03/29 08:17:19 $]
Release: Release:
@@ -49,10 +49,6 @@ CURRENT RELEASE NOTES:
FINAL RELEASE SHOWSTOPPERS: FINAL RELEASE SHOWSTOPPERS:
* API changes planned for 2.0 that should happen before the
GA release:
* Free lists for bucket allocation
* We do not properly substitute the prefix-variables in the configuration * We do not properly substitute the prefix-variables in the configuration
scripts or generated-configs. (i.e. if sysconfdir is etc, scripts or generated-configs. (i.e. if sysconfdir is etc,
httpd-std.conf points to conf.) httpd-std.conf points to conf.)
@@ -311,14 +307,8 @@ RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
bands, double free detection, etc. would be cool but certainly bands, double free detection, etc. would be cool but certainly
not a hard requirement. not a hard requirement.
Status: Cliff started to implement this using SMS as has Status: The necessary API changes are in... apr_buckets_alloc.c
been discussed at length for months, but since just needs to be fleshed out.
SMS is not being used anywhere else in the server,
several people expressed the opinion that we should
get rid of it entirely, meaning that the buckets
need their own memory management (free list) functions.
Cliff will implement that this weekend so we at least
have something to look at/compare with.
* Eliminate unnecessary creation of pipes in mod_cgid * Eliminate unnecessary creation of pipes in mod_cgid

View File

@@ -102,12 +102,13 @@
* 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed * 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed
* 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253 * 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253
* 20020327 (2.0.35-dev) Add parameter to quick_handler hook * 20020327 (2.0.35-dev) Add parameter to quick_handler hook
* 20020329 (2.0.35-dev) bump for addition of freelists to bucket API
*/ */
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */ #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR #ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20020327 #define MODULE_MAGIC_NUMBER_MAJOR 20020329
#endif #endif
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */ #define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */ #define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */

View File

@@ -57,6 +57,7 @@
#include "apr_hooks.h" #include "apr_hooks.h"
#include "apr_network_io.h" #include "apr_network_io.h"
#include "apr_buckets.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -114,7 +115,8 @@ AP_DECLARE(void) ap_lingering_close(conn_rec *c);
* @return An allocated connection record or NULL. * @return An allocated connection record or NULL.
*/ */
AP_DECLARE_HOOK(conn_rec *, create_connection, AP_DECLARE_HOOK(conn_rec *, create_connection,
(apr_pool_t *p, server_rec *server, apr_socket_t *csd, long conn_id, void *sbh)) (apr_pool_t *p, server_rec *server, apr_socket_t *csd,
long conn_id, void *sbh, apr_bucket_alloc_t *alloc))
/** /**
* This hook gives protocol modules an opportunity to set everything up * This hook gives protocol modules an opportunity to set everything up

View File

@@ -666,12 +666,14 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
* Create a bucket referring to an HTTP error. * Create a bucket referring to an HTTP error.
* @param error The HTTP error code to put in the bucket. * @param error The HTTP error code to put in the bucket.
* @param buf An optional error string to put in the bucket. * @param buf An optional error string to put in the bucket.
* @param p A pool to allocate out of. * @param p A pool to allocate the error string out of.
* @param list The bucket allocator from which to allocate the bucket
* @return The new bucket, or NULL if allocation failed * @return The new bucket, or NULL if allocation failed
* @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p) * @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
*/ */
AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
const char *buf, apr_pool_t *p); apr_pool_t *p,
apr_bucket_alloc_t *list);
AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b); AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b);
AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b); AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b);

View File

@@ -1008,6 +1008,8 @@ struct conn_rec {
struct ap_filter_t *output_filters; struct ap_filter_t *output_filters;
/** handle to scoreboard information for this connection */ /** handle to scoreboard information for this connection */
void *sbh; void *sbh;
/** The bucket allocator to use for all bucket/brigade creations */
struct apr_bucket_alloc_t *bucket_alloc;
}; };
/* Per-vhost config... */ /* Per-vhost config... */

View File

@@ -646,16 +646,17 @@ BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpdwBytes,
DWORD dwReserved) DWORD dwReserved)
{ {
request_rec *r = ((isapi_cid *)ConnID)->r; request_rec *r = ((isapi_cid *)ConnID)->r;
conn_rec *c = r->connection;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
if (dwReserved == HSE_IO_SYNC) if (dwReserved == HSE_IO_SYNC)
; /* XXX: Fake it */ ; /* XXX: Fake it */
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_transient_create(Buffer, *lpdwBytes); b = apr_bucket_transient_create(Buffer, *lpdwBytes, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb); ap_pass_brigade(r->output_filters, bb);
@@ -739,6 +740,7 @@ BOOL WINAPI ServerSupportFunction(HCONN hConn, DWORD dwHSERequest,
{ {
isapi_cid *cid = (isapi_cid *)hConn; isapi_cid *cid = (isapi_cid *)hConn;
request_rec *r = cid->r; request_rec *r = cid->r;
conn_rec *c = r->connection;
request_rec *subreq; request_rec *subreq;
switch (dwHSERequest) { switch (dwHSERequest) {
@@ -792,11 +794,11 @@ BOOL WINAPI ServerSupportFunction(HCONN hConn, DWORD dwHSERequest,
else if ((apr_size_t)ate < headlen) { else if ((apr_size_t)ate < headlen) {
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
bb = apr_brigade_create(cid->r->pool); bb = apr_brigade_create(cid->r->pool, c->bucket_alloc);
b = apr_bucket_transient_create((char*) lpdwDataType + ate, b = apr_bucket_transient_create((char*) lpdwDataType + ate,
headlen - ate); headlen - ate, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(cid->r->output_filters, bb); ap_pass_brigade(cid->r->output_filters, bb);
} }
@@ -897,7 +899,7 @@ BOOL WINAPI ServerSupportFunction(HCONN hConn, DWORD dwHSERequest,
} }
/* apr_dupfile_oshandle (&fd, tf->hFile, r->pool); */ /* apr_dupfile_oshandle (&fd, tf->hFile, r->pool); */
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
if (tf->dwFlags & HSE_IO_SEND_HEADERS) if (tf->dwFlags & HSE_IO_SEND_HEADERS)
{ {
@@ -923,27 +925,29 @@ BOOL WINAPI ServerSupportFunction(HCONN hConn, DWORD dwHSERequest,
if ((apr_size_t)ate < tf->HeadLength) if ((apr_size_t)ate < tf->HeadLength)
{ {
b = apr_bucket_transient_create((char*)tf->pHead + ate, b = apr_bucket_transient_create((char*)tf->pHead + ate,
tf->HeadLength - ate); tf->HeadLength - ate,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
} }
} }
else if (tf->pHead && tf->HeadLength) { else if (tf->pHead && tf->HeadLength) {
b = apr_bucket_transient_create((char*)tf->pHead, b = apr_bucket_transient_create((char*)tf->pHead,
tf->HeadLength); tf->HeadLength,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
} }
b = apr_bucket_file_create(fd, tf->Offset, b = apr_bucket_file_create(fd, tf->Offset,
tf->BytesToWrite, r->pool); tf->BytesToWrite, r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if (tf->pTail && tf->TailLength) { if (tf->pTail && tf->TailLength) {
b = apr_bucket_transient_create((char*)tf->pTail, b = apr_bucket_transient_create((char*)tf->pTail,
tf->TailLength); tf->TailLength, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
} }
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb); ap_pass_brigade(r->output_filters, bb);
@@ -1095,11 +1099,12 @@ BOOL WINAPI ServerSupportFunction(HCONN hConn, DWORD dwHSERequest,
else if ((apr_size_t)ate < shi->cchHeader) { else if ((apr_size_t)ate < shi->cchHeader) {
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
bb = apr_brigade_create(cid->r->pool); bb = apr_brigade_create(cid->r->pool, c->bucket_alloc);
b = apr_bucket_transient_create(shi->pszHeader + ate, b = apr_bucket_transient_create(shi->pszHeader + ate,
shi->cchHeader - ate); shi->cchHeader - ate,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(cid->r->output_filters, bb); ap_pass_brigade(cid->r->output_filters, bb);
} }

View File

@@ -349,12 +349,14 @@ static int file_cache_xlat(request_rec *r)
static int mmap_handler(request_rec *r, a_file *file) static int mmap_handler(request_rec *r, a_file *file)
{ {
#if APR_HAS_MMAP #if APR_HAS_MMAP
conn_rec *c = r->connection;
apr_bucket *b; apr_bucket *b;
apr_bucket_brigade *bb = apr_brigade_create(r->pool); apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_mmap_create(file->mm, 0, (apr_size_t)file->finfo.size); b = apr_bucket_mmap_create(file->mm, 0, (apr_size_t)file->finfo.size,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS) if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
@@ -366,13 +368,14 @@ static int mmap_handler(request_rec *r, a_file *file)
static int sendfile_handler(request_rec *r, a_file *file) static int sendfile_handler(request_rec *r, a_file *file)
{ {
#if APR_HAS_SENDFILE #if APR_HAS_SENDFILE
conn_rec *c = r->connection;
apr_bucket *b; apr_bucket *b;
apr_bucket_brigade *bb = apr_brigade_create(r->pool); apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_file_create(file->file, 0, b = apr_bucket_file_create(file->file, 0, (apr_size_t)file->finfo.size,
(apr_size_t)file->finfo.size, r->pool); r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS) if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)

View File

@@ -59,6 +59,7 @@
#include "apr.h" #include "apr.h"
#include "apr_file_io.h" #include "apr_file_io.h"
#include "apr_strings.h" #include "apr_strings.h"
#include "apr_buckets.h"
#if APR_HAVE_STDIO_H #if APR_HAVE_STDIO_H
#include <stdio.h> /* for sprintf() */ #include <stdio.h> /* for sprintf() */
@@ -995,15 +996,15 @@ static dav_error * dav_fs_deliver(const dav_resource *resource,
"File permissions deny server access."); "File permissions deny server access.");
} }
bb = apr_brigade_create(pool); bb = apr_brigade_create(pool, output->c->bucket_alloc);
/* ### this does not handle large files. but this is test code anyway */ /* ### this does not handle large files. but this is test code anyway */
bkt = apr_bucket_file_create(fd, 0, bkt = apr_bucket_file_create(fd, 0,
(apr_size_t)resource->info->finfo.size, (apr_size_t)resource->info->finfo.size,
pool); pool, output->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, bkt); APR_BRIGADE_INSERT_TAIL(bb, bkt);
bkt = apr_bucket_eos_create(); bkt = apr_bucket_eos_create(output->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, bkt); APR_BRIGADE_INSERT_TAIL(bb, bkt);
if ((status = ap_pass_brigade(output, bb)) != APR_SUCCESS) { if ((status = ap_pass_brigade(output, bb)) != APR_SUCCESS) {

View File

@@ -101,7 +101,7 @@ static int process_echo_connection(conn_rec *c)
return DECLINED; return DECLINED;
} }
bb = apr_brigade_create(c->pool); bb = apr_brigade_create(c->pool, c->bucket_alloc);
for ( ; ; ) { for ( ; ; ) {
/* Get a single line of input from the client */ /* Get a single line of input from the client */
@@ -113,7 +113,7 @@ static int process_echo_connection(conn_rec *c)
} }
/* Make sure the data is flushed to the client */ /* Make sure the data is flushed to the client */
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(c->output_filters, bb); ap_pass_brigade(c->output_filters, bb);
} }

View File

@@ -202,6 +202,7 @@ static int cache_url_handler(request_rec *r, int lookup)
/* cache file exists */ /* cache file exists */
if (cache->fresh) { if (cache->fresh) {
apr_bucket_brigade *out; apr_bucket_brigade *out;
conn_rec *c = r->connection;
/* fresh data available */ /* fresh data available */
if (lookup) { if (lookup) {
@@ -227,7 +228,7 @@ static int cache_url_handler(request_rec *r, int lookup)
ap_add_output_filter("CACHE_OUT", NULL, r, r->connection); ap_add_output_filter("CACHE_OUT", NULL, r, r->connection);
/* kick off the filter stack */ /* kick off the filter stack */
out = apr_brigade_create(r->pool); out = apr_brigade_create(r->pool, c->bucket_alloc);
if (APR_SUCCESS != (rv = ap_pass_brigade(r->output_filters, out))) { if (APR_SUCCESS != (rv = ap_pass_brigade(r->output_filters, out))) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
"cache: error returned while trying to return %s " "cache: error returned while trying to return %s "

View File

@@ -40,11 +40,12 @@ static void CaseFilterInsertFilter(request_rec *r)
static apr_status_t CaseFilterOutFilter(ap_filter_t *f, static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
apr_bucket_brigade *pbbIn) apr_bucket_brigade *pbbIn)
{ {
request_rec *r = f->r;
conn_rec *c = r->connection;
apr_bucket *pbktIn; apr_bucket *pbktIn;
apr_bucket_brigade *pbbOut; apr_bucket_brigade *pbbOut;
/* XXX: is this the most appropriate pool? */ pbbOut=apr_brigade_create(r->pool, c->bucket_alloc);
pbbOut=apr_brigade_create(f->r->pool);
APR_BRIGADE_FOREACH(pbktIn,pbbIn) APR_BRIGADE_FOREACH(pbktIn,pbbIn)
{ {
const char *data; const char *data;
@@ -55,8 +56,7 @@ static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
if(APR_BUCKET_IS_EOS(pbktIn)) if(APR_BUCKET_IS_EOS(pbktIn))
{ {
/* XXX: why can't I reuse pbktIn??? */ apr_bucket *pbktEOS=apr_bucket_eos_create(c->bucket_alloc);
apr_bucket *pbktEOS=apr_bucket_eos_create();
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS); APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
continue; continue;
} }
@@ -65,11 +65,12 @@ static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ); apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
/* write */ /* write */
buf=malloc(len); buf = apr_bucket_alloc(len, c->bucket_alloc);
for(n=0 ; n < len ; ++n) for(n=0 ; n < len ; ++n)
buf[n]=toupper(data[n]); buf[n]=toupper(data[n]);
pbktOut=apr_bucket_heap_create(buf,len,0); pbktOut = apr_bucket_heap_create(buf, len, apr_bucket_free,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktOut); APR_BRIGADE_INSERT_TAIL(pbbOut,pbktOut);
} }

View File

@@ -105,12 +105,13 @@ static apr_status_t CaseFilterInFilter(ap_filter_t *f,
apr_off_t nBytes) apr_off_t nBytes)
{ {
request_rec *r = f->r; request_rec *r = f->r;
conn_rec *c = r->connection;
CaseFilterInContext *pCtx; CaseFilterInContext *pCtx;
apr_status_t ret; apr_status_t ret;
if (!(pCtx = f->ctx)) { if (!(pCtx = f->ctx)) {
f->ctx = pCtx = apr_palloc(r->pool, sizeof *pCtx); f->ctx = pCtx = apr_palloc(r->pool, sizeof *pCtx);
pCtx->pbbTmp = apr_brigade_create(r->pool); pCtx->pbbTmp = apr_brigade_create(r->pool, c->bucket_alloc);
} }
if (APR_BRIGADE_EMPTY(pCtx->pbbTmp)) { if (APR_BRIGADE_EMPTY(pCtx->pbbTmp)) {
@@ -149,7 +150,7 @@ static apr_status_t CaseFilterInFilter(ap_filter_t *f,
for(n=0 ; n < len ; ++n) for(n=0 ; n < len ; ++n)
buf[n] = toupper(data[n]); buf[n] = toupper(data[n]);
pbktOut = apr_bucket_heap_create(buf, len, 0); pbktOut = apr_bucket_heap_create(buf, len, 0, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut); APR_BRIGADE_INSERT_TAIL(pbbOut, pbktOut);
apr_bucket_delete(pbktIn); apr_bucket_delete(pbktIn);
} }

View File

@@ -347,7 +347,8 @@ static int find_code_page(request_rec *r)
* of it. * of it.
*/ */
input_ctx = apr_pcalloc(r->pool, sizeof(charset_filter_ctx_t)); input_ctx = apr_pcalloc(r->pool, sizeof(charset_filter_ctx_t));
input_ctx->bb = apr_brigade_create(r->pool); input_ctx->bb = apr_brigade_create(r->pool,
r->connection->bucket_alloc);
input_ctx->tmp = apr_palloc(r->pool, INPUT_XLATE_BUF_SIZE); input_ctx->tmp = apr_palloc(r->pool, INPUT_XLATE_BUF_SIZE);
input_ctx->dc = dc; input_ctx->dc = dc;
reqinfo->input_ctx = input_ctx; reqinfo->input_ctx = input_ctx;
@@ -443,13 +444,15 @@ static void xlate_insert_filter(request_rec *r)
*/ */
static apr_status_t send_downstream(ap_filter_t *f, const char *tmp, apr_size_t len) static apr_status_t send_downstream(ap_filter_t *f, const char *tmp, apr_size_t len)
{ {
request_rec *r = f->r;
conn_rec *c = r->connection;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
charset_filter_ctx_t *ctx = f->ctx; charset_filter_ctx_t *ctx = f->ctx;
apr_status_t rv; apr_status_t rv;
bb = apr_brigade_create(f->r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_transient_create(tmp, len); b = apr_bucket_transient_create(tmp, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(f->next, bb); rv = ap_pass_brigade(f->next, bb);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
@@ -460,13 +463,15 @@ static apr_status_t send_downstream(ap_filter_t *f, const char *tmp, apr_size_t
static apr_status_t send_eos(ap_filter_t *f) static apr_status_t send_eos(ap_filter_t *f)
{ {
request_rec *r = f->r;
conn_rec *c = r->connection;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
charset_filter_ctx_t *ctx = f->ctx; charset_filter_ctx_t *ctx = f->ctx;
apr_status_t rv; apr_status_t rv;
bb = apr_brigade_create(f->r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(f->next, bb); rv = ap_pass_brigade(f->next, bb);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
@@ -1053,7 +1058,8 @@ static int xlate_in_filter(ap_filter_t *f, apr_bucket_brigade *bb,
apr_bucket *e; apr_bucket *e;
e = apr_bucket_heap_create(ctx->tmp, e = apr_bucket_heap_create(ctx->tmp,
INPUT_XLATE_BUF_SIZE - buffer_size, 1); INPUT_XLATE_BUF_SIZE - buffer_size,
NULL, f->r->connection->bucket_alloc);
/* make sure we insert at the head, because there may be /* make sure we insert at the head, because there may be
* an eos bucket already there, and the eos bucket should * an eos bucket already there, and the eos bucket should
* come after the data * come after the data

View File

@@ -273,8 +273,8 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
} }
/* We're cool with filtering this. */ /* We're cool with filtering this. */
ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); ctx = f->ctx = apr_pcalloc(r->pool, sizeof(*ctx));
ctx->bb = apr_brigade_create(f->r->pool); ctx->bb = apr_brigade_create(r->pool, f->c->bucket_alloc);
/* /*
ctx->stream.zalloc = (alloc_func) 0; ctx->stream.zalloc = (alloc_func) 0;
ctx->stream.zfree = (free_func) 0; ctx->stream.zfree = (free_func) 0;
@@ -297,7 +297,7 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
buf = apr_psprintf(r->pool, "%c%c%c%c%c%c%c%c%c%c", deflate_magic[0], buf = apr_psprintf(r->pool, "%c%c%c%c%c%c%c%c%c%c", deflate_magic[0],
deflate_magic[1], Z_DEFLATED, 0 /* flags */ , 0, 0, deflate_magic[1], Z_DEFLATED, 0 /* flags */ , 0, 0,
0, 0 /* time */ , 0 /* xflags */ , OS_CODE); 0, 0 /* time */ , 0 /* xflags */ , OS_CODE);
e = apr_bucket_pool_create(buf, 10, r->pool); e = apr_bucket_pool_create(buf, 10, r->pool, f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb, e); APR_BRIGADE_INSERT_TAIL(ctx->bb, e);
apr_table_setn(r->headers_out, "Content-Encoding", "gzip"); apr_table_setn(r->headers_out, "Content-Encoding", "gzip");
@@ -323,7 +323,8 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
if (deflate_len != 0) { if (deflate_len != 0) {
b = apr_bucket_heap_create((char *)ctx->buffer, b = apr_bucket_heap_create((char *)ctx->buffer,
deflate_len, 1); deflate_len, NULL,
f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb, b); APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
ctx->stream.next_out = ctx->buffer; ctx->stream.next_out = ctx->buffer;
ctx->stream.avail_out = FILTER_BUFSIZE; ctx->stream.avail_out = FILTER_BUFSIZE;
@@ -359,7 +360,7 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
*p++ = len_array[2]; *p++ = len_array[2];
*p++ = len_array[3]; *p++ = len_array[3];
b = apr_bucket_pool_create(buf, 8, r->pool); b = apr_bucket_pool_create(buf, 8, r->pool, f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb, b); APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r, ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r,
"Zlib: Compressed %ld to %ld : URL %s", "Zlib: Compressed %ld to %ld : URL %s",
@@ -421,7 +422,8 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
ctx->stream.next_out = ctx->buffer; ctx->stream.next_out = ctx->buffer;
len = FILTER_BUFSIZE - ctx->stream.avail_out; len = FILTER_BUFSIZE - ctx->stream.avail_out;
b = apr_bucket_heap_create((char *)ctx->buffer, len, 1); b = apr_bucket_heap_create((char *)ctx->buffer, len,
NULL, f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb, b); APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
ctx->stream.avail_out = FILTER_BUFSIZE; ctx->stream.avail_out = FILTER_BUFSIZE;
} }

View File

@@ -504,10 +504,10 @@ static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_briga
apr_bucket *e; apr_bucket *e;
disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj; disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj;
e = apr_bucket_file_create(dobj->fd, 0, dobj->file_size, p); e = apr_bucket_file_create(dobj->fd, 0, dobj->file_size, p,
bb->bucket_alloc);
APR_BRIGADE_INSERT_HEAD(bb, e); APR_BRIGADE_INSERT_HEAD(bb, e);
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(bb->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
return APR_SUCCESS; return APR_SUCCESS;

View File

@@ -532,6 +532,8 @@ static apr_status_t init_filter_instance(ap_filter_t *f)
*/ */
static apr_status_t drain_available_output(ap_filter_t *f) static apr_status_t drain_available_output(ap_filter_t *f)
{ {
request_rec *r = f->r;
conn_rec *c = r->connection;
ef_ctx_t *ctx = f->ctx; ef_ctx_t *ctx = f->ctx;
ef_dir_t *dc = ctx->dc; ef_dir_t *dc = ctx->dc;
apr_size_t len; apr_size_t len;
@@ -547,18 +549,18 @@ static apr_status_t drain_available_output(ap_filter_t *f)
&len); &len);
if ((rv && !APR_STATUS_IS_EAGAIN(rv)) || if ((rv && !APR_STATUS_IS_EAGAIN(rv)) ||
dc->debug >= DBGLVL_GORY) { dc->debug >= DBGLVL_GORY) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r, ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r,
"apr_file_read(child output), len %" APR_SIZE_T_FMT, "apr_file_read(child output), len %" APR_SIZE_T_FMT,
!rv ? len : -1); !rv ? len : -1);
} }
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
return rv; return rv;
} }
bb = apr_brigade_create(f->r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_transient_create(buf, len); b = apr_bucket_transient_create(buf, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) { if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"ap_pass_brigade()"); "ap_pass_brigade()");
return rv; return rv;
} }
@@ -632,6 +634,8 @@ static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data,
static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
{ {
request_rec *r = f->r;
conn_rec *c = r->connection;
ef_ctx_t *ctx = f->ctx; ef_ctx_t *ctx = f->ctx;
apr_bucket *b; apr_bucket *b;
ef_dir_t *dc; ef_dir_t *dc;
@@ -662,7 +666,7 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
rv = apr_bucket_read(b, &data, &len, APR_BLOCK_READ); rv = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, "apr_bucket_read()"); ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "apr_bucket_read()");
return rv; return rv;
} }
@@ -682,7 +686,7 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
* that will cause the child to finish generating output * that will cause the child to finish generating output
*/ */
if ((rv = apr_file_close(ctx->proc->in)) != APR_SUCCESS) { if ((rv = apr_file_close(ctx->proc->in)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"apr_file_close(child input)"); "apr_file_close(child input)");
return rv; return rv;
} }
@@ -690,9 +694,9 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
* timeout; we don't care if we don't return from apr_file_read() for a while... * timeout; we don't care if we don't return from apr_file_read() for a while...
*/ */
rv = apr_file_pipe_timeout_set(ctx->proc->out, rv = apr_file_pipe_timeout_set(ctx->proc->out,
f->r->server->timeout * APR_USEC_PER_SEC); r->server->timeout * APR_USEC_PER_SEC);
if (rv) { if (rv) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"apr_file_pipe_timeout_set(child output)"); "apr_file_pipe_timeout_set(child output)");
return rv; return rv;
} }
@@ -705,7 +709,7 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
&len); &len);
if ((rv && !APR_STATUS_IS_EOF(rv) && !APR_STATUS_IS_EAGAIN(rv)) || if ((rv && !APR_STATUS_IS_EOF(rv) && !APR_STATUS_IS_EAGAIN(rv)) ||
dc->debug >= DBGLVL_GORY) { dc->debug >= DBGLVL_GORY) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, f->r, ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r,
"apr_file_read(child output), len %" APR_SIZE_T_FMT, "apr_file_read(child output), len %" APR_SIZE_T_FMT,
!rv ? len : -1); !rv ? len : -1);
} }
@@ -718,11 +722,11 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
} }
if (rv == APR_SUCCESS) { if (rv == APR_SUCCESS) {
bb = apr_brigade_create(f->r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_transient_create(buf, len); b = apr_bucket_transient_create(buf, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) { if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"ap_pass_brigade(filtered buffer) failed"); "ap_pass_brigade(filtered buffer) failed");
return rv; return rv;
} }
@@ -735,11 +739,11 @@ static apr_status_t ef_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
if (eos) { if (eos) {
/* pass down eos */ /* pass down eos */
bb = apr_brigade_create(f->r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) { if ((rv = ap_pass_brigade(f->next, bb)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"ap_pass_brigade(eos) failed"); "ap_pass_brigade(eos) failed");
return rv; return rv;
} }

View File

@@ -646,14 +646,14 @@ static apr_status_t read_body(cache_handle_t *h, apr_pool_t *p, apr_bucket_briga
/* CACHE_TYPE_FILE */ /* CACHE_TYPE_FILE */
apr_file_t *file; apr_file_t *file;
apr_os_file_put(&file, &mobj->fd, APR_READ|APR_XTHREAD, p); apr_os_file_put(&file, &mobj->fd, APR_READ|APR_XTHREAD, p);
b = apr_bucket_file_create(file, 0, mobj->m_len, p); b = apr_bucket_file_create(file, 0, mobj->m_len, p, bb->bucket_alloc);
} }
else { else {
/* CACHE_TYPE_HEAP */ /* CACHE_TYPE_HEAP */
b = apr_bucket_immortal_create(mobj->m, mobj->m_len); b = apr_bucket_immortal_create(mobj->m, mobj->m_len, bb->bucket_alloc);
} }
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(bb->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
return APR_SUCCESS; return APR_SUCCESS;

View File

@@ -1358,6 +1358,7 @@ static int handle_echo(include_ctx_t *ctx, apr_bucket_brigade **bb,
} }
} }
if (!strcmp(tag, "var")) { if (!strcmp(tag, "var")) {
conn_rec *c = r->connection;
const char *val = const char *val =
get_include_var(r, ctx, get_include_var(r, ctx,
ap_ssi_parse_string(r, ctx, tag_val, NULL, ap_ssi_parse_string(r, ctx, tag_val, NULL,
@@ -1377,7 +1378,7 @@ static int handle_echo(include_ctx_t *ctx, apr_bucket_brigade **bb,
e_len = strlen(echo_text); e_len = strlen(echo_text);
tmp_buck = apr_bucket_pool_create(echo_text, e_len, tmp_buck = apr_bucket_pool_create(echo_text, e_len,
r->pool); r->pool, c->bucket_alloc);
} }
else { else {
include_server_config *sconf= include_server_config *sconf=
@@ -1385,7 +1386,7 @@ static int handle_echo(include_ctx_t *ctx, apr_bucket_brigade **bb,
&include_module); &include_module);
tmp_buck = apr_bucket_pool_create(sconf->undefinedEcho, tmp_buck = apr_bucket_pool_create(sconf->undefinedEcho,
sconf->undefinedEchoLen, sconf->undefinedEchoLen,
r->pool); r->pool, c->bucket_alloc);
} }
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
@@ -1623,7 +1624,8 @@ static int handle_fsize(include_ctx_t *ctx, apr_bucket_brigade **bb,
s_len = pos; s_len = pos;
} }
tmp_buck = apr_bucket_heap_create(buff, s_len, 1); tmp_buck = apr_bucket_heap_create(buff, s_len, NULL,
r->connection->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
*inserted_head = tmp_buck; *inserted_head = tmp_buck;
@@ -1671,7 +1673,8 @@ static int handle_flastmod(include_ctx_t *ctx, apr_bucket_brigade **bb,
t_val = ap_ht_time(r->pool, finfo.mtime, ctx->time_str, 0); t_val = ap_ht_time(r->pool, finfo.mtime, ctx->time_str, 0);
t_len = strlen(t_val); t_len = strlen(t_val);
tmp_buck = apr_bucket_pool_create(t_val, t_len, r->pool); tmp_buck = apr_bucket_pool_create(t_val, t_len, r->pool,
r->connection->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
*inserted_head = tmp_buck; *inserted_head = tmp_buck;
@@ -2504,8 +2507,9 @@ static int parse_expr(request_rec *r, include_ctx_t *ctx, const char *expr,
if (cntx->flags & FLAG_COND_TRUE) { \ if (cntx->flags & FLAG_COND_TRUE) { \
cond_txt[31] = '1'; \ cond_txt[31] = '1'; \
} \ } \
memcpy(&cond_txt[5], tag_text, sizeof(tag_text)); \ memcpy(&cond_txt[5], tag_text, sizeof(tag_text)-1); \
t_buck = apr_bucket_heap_create(cond_txt, sizeof(cond_txt), 1); \ t_buck = apr_bucket_heap_create(cond_txt, sizeof(cond_txt)-1, \
NULL, h_ptr->list); \
APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \ APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \
\ \
if (ins_head == NULL) { \ if (ins_head == NULL) { \
@@ -2515,7 +2519,8 @@ static int parse_expr(request_rec *r, include_ctx_t *ctx, const char *expr,
#define DUMP_PARSE_EXPR_DEBUG(t_buck, h_ptr, d_buf, ins_head) \ #define DUMP_PARSE_EXPR_DEBUG(t_buck, h_ptr, d_buf, ins_head) \
{ \ { \
if (d_buf[0] != '\0') { \ if (d_buf[0] != '\0') { \
t_buck = apr_bucket_heap_create(d_buf, strlen(d_buf), 1); \ t_buck = apr_bucket_heap_create(d_buf, strlen(d_buf), \
NULL, h_ptr->list); \
APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \ APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \
\ \
if (ins_head == NULL) { \ if (ins_head == NULL) { \
@@ -2591,7 +2596,8 @@ static int handle_if(include_ctx_t *ctx, apr_bucket_brigade **bb,
if (1) { if (1) {
apr_size_t d_len = 0; apr_size_t d_len = 0;
d_len = sprintf(debug_buf, "**** if expr=\"%s\"\n", expr); d_len = sprintf(debug_buf, "**** if expr=\"%s\"\n", expr);
tmp_buck = apr_bucket_heap_create(debug_buf, d_len, 1); tmp_buck = apr_bucket_heap_create(debug_buf, d_len, NULL,
r->connection->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
@@ -2673,7 +2679,8 @@ static int handle_elif(include_ctx_t *ctx, apr_bucket_brigade **bb,
if (1) { if (1) {
apr_size_t d_len = 0; apr_size_t d_len = 0;
d_len = sprintf(debug_buf, "**** elif expr=\"%s\"\n", expr); d_len = sprintf(debug_buf, "**** elif expr=\"%s\"\n", expr);
tmp_buck = apr_bucket_heap_create(debug_buf, d_len, 1); tmp_buck = apr_bucket_heap_create(debug_buf, d_len, NULL,
r->connection->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
@@ -2854,7 +2861,8 @@ static int handle_printenv(include_ctx_t *ctx, apr_bucket_brigade **bb,
*next++ = '\n'; *next++ = '\n';
*next = 0; *next = 0;
tmp_buck = apr_bucket_pool_create(key_val, kv_length - 1, tmp_buck = apr_bucket_pool_create(key_val, kv_length - 1,
r->pool); r->pool,
r->connection->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
*inserted_head = tmp_buck; *inserted_head = tmp_buck;
@@ -2912,7 +2920,8 @@ static apr_status_t send_parsed_content(apr_bucket_brigade **bb,
apr_bucket *tmp_bkt; apr_bucket *tmp_bkt;
tmp_bkt = apr_bucket_immortal_create(ctx->start_seq, tmp_bkt = apr_bucket_immortal_create(ctx->start_seq,
cleanup_bytes); cleanup_bytes,
r->connection->bucket_alloc);
APR_BRIGADE_INSERT_HEAD(*bb, tmp_bkt); APR_BRIGADE_INSERT_HEAD(*bb, tmp_bkt);
apr_brigade_cleanup(ctx->ssi_tag_brigade); apr_brigade_cleanup(ctx->ssi_tag_brigade);
} }
@@ -2946,7 +2955,7 @@ static apr_status_t send_parsed_content(apr_bucket_brigade **bb,
/* Send the large chunk of pre-tag bytes... */ /* Send the large chunk of pre-tag bytes... */
tag_and_after = apr_brigade_split(*bb, tmp_dptr); tag_and_after = apr_brigade_split(*bb, tmp_dptr);
if (ctx->output_flush) { if (ctx->output_flush) {
APR_BRIGADE_INSERT_TAIL(*bb, apr_bucket_flush_create()); APR_BRIGADE_INSERT_TAIL(*bb, apr_bucket_flush_create((*bb)->bucket_alloc));
} }
rv = ap_pass_brigade(f->next, *bb); rv = ap_pass_brigade(f->next, *bb);
@@ -3281,7 +3290,8 @@ static apr_status_t includes_filter(ap_filter_t *f, apr_bucket_brigade *b)
if (ap_allow_options(r) & OPT_INCNOEXEC) { if (ap_allow_options(r) & OPT_INCNOEXEC) {
ctx->flags |= FLAG_NO_EXEC; ctx->flags |= FLAG_NO_EXEC;
} }
ctx->ssi_tag_brigade = apr_brigade_create(f->c->pool); ctx->ssi_tag_brigade = apr_brigade_create(f->c->pool,
f->c->bucket_alloc);
ctx->status = APR_SUCCESS; ctx->status = APR_SUCCESS;
ctx->error_str = conf->default_error_msg; ctx->error_str = conf->default_error_msg;

View File

@@ -189,7 +189,8 @@ typedef struct include_filter_ctx {
{ \ { \
/* XXX: it'd probably be nice to use a pool bucket here */ \ /* XXX: it'd probably be nice to use a pool bucket here */ \
t_buck = apr_bucket_heap_create(cntx->error_str, \ t_buck = apr_bucket_heap_create(cntx->error_str, \
strlen(cntx->error_str), 1); \ strlen(cntx->error_str), \
NULL, h_ptr->list); \
APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \ APR_BUCKET_INSERT_BEFORE(h_ptr, t_buck); \
\ \
if (ins_head == NULL) { \ if (ins_head == NULL) { \
@@ -208,7 +209,7 @@ if ((APR_BRIGADE_EMPTY((cntxt)->ssi_tag_brigade)) && \
\ \
tag_plus = apr_brigade_split((brgd), (cntxt)->head_start_bucket); \ tag_plus = apr_brigade_split((brgd), (cntxt)->head_start_bucket); \
if ((cntxt)->output_flush) { \ if ((cntxt)->output_flush) { \
APR_BRIGADE_INSERT_TAIL((brgd), apr_bucket_flush_create()); \ APR_BRIGADE_INSERT_TAIL((brgd), apr_bucket_flush_create((brgd)->bucket_alloc)); \
} \ } \
(rc) = ap_pass_brigade((next), (brgd)); \ (rc) = ap_pass_brigade((next), (brgd)); \
(cntxt)->bytes_parsed = 0; \ (cntxt)->bytes_parsed = 0; \

View File

@@ -72,6 +72,7 @@
static int asis_handler(request_rec *r) static int asis_handler(request_rec *r)
{ {
conn_rec *c = r->connection;
apr_file_t *f = NULL; apr_file_t *f = NULL;
apr_status_t rv; apr_status_t rv;
const char *location; const char *location;
@@ -130,7 +131,7 @@ static int asis_handler(request_rec *r)
return HTTP_INTERNAL_SERVER_ERROR; return HTTP_INTERNAL_SERVER_ERROR;
} }
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
#if APR_HAS_LARGE_FILES #if APR_HAS_LARGE_FILES
if (r->finfo.size - pos > AP_MAX_SENDFILE) { if (r->finfo.size - pos > AP_MAX_SENDFILE) {
/* APR_HAS_LARGE_FILES issue; must split into mutiple buckets, /* APR_HAS_LARGE_FILES issue; must split into mutiple buckets,
@@ -138,7 +139,8 @@ static int asis_handler(request_rec *r)
* in case the brigade code/filters attempt to read it directly. * in case the brigade code/filters attempt to read it directly.
*/ */
apr_off_t fsize = r->finfo.size - pos; apr_off_t fsize = r->finfo.size - pos;
b = apr_bucket_file_create(f, pos, AP_MAX_SENDFILE, r->pool); b = apr_bucket_file_create(f, pos, AP_MAX_SENDFILE,
r->pool, c->bucket_alloc);
while (fsize > AP_MAX_SENDFILE) { while (fsize > AP_MAX_SENDFILE) {
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
apr_bucket_copy(b, &b); apr_bucket_copy(b, &b);
@@ -149,9 +151,10 @@ static int asis_handler(request_rec *r)
} }
else else
#endif #endif
b = apr_bucket_file_create(f, pos, (apr_size_t) (r->finfo.size - pos), r->pool); b = apr_bucket_file_create(f, pos, (apr_size_t) (r->finfo.size - pos),
r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(r->output_filters, bb); rv = ap_pass_brigade(r->output_filters, bb);
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {

View File

@@ -702,14 +702,15 @@ static int cgi_handler(request_rec *r)
/* Handle script return... */ /* Handle script return... */
if (script_in && !nph) { if (script_in && !nph) {
conn_rec *c = r->connection;
const char *location; const char *location;
char sbuf[MAX_STRING_LEN]; char sbuf[MAX_STRING_LEN];
int ret; int ret;
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_pipe_create(script_in); b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) { if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) {
@@ -755,6 +756,7 @@ static int cgi_handler(request_rec *r)
} }
if (script_in && nph) { if (script_in && nph) {
conn_rec *c = r->connection;
struct ap_filter_t *cur; struct ap_filter_t *cur;
/* get rid of all filters up through protocol... since we /* get rid of all filters up through protocol... since we
@@ -768,10 +770,10 @@ static int cgi_handler(request_rec *r)
} }
r->output_filters = r->proto_output_filters = cur; r->output_filters = r->proto_output_filters = cur;
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_pipe_create(script_in); b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb); ap_pass_brigade(r->output_filters, bb);
} }
@@ -825,6 +827,7 @@ static int include_cgi(char *s, request_rec *r, ap_filter_t *next,
if (ap_is_HTTP_REDIRECT(rr_status)) { if (ap_is_HTTP_REDIRECT(rr_status)) {
apr_size_t len_loc; apr_size_t len_loc;
const char *location = apr_table_get(rr->headers_out, "Location"); const char *location = apr_table_get(rr->headers_out, "Location");
conn_rec *c = r->connection;
location = ap_escape_html(rr->pool, location); location = ap_escape_html(rr->pool, location);
len_loc = strlen(location); len_loc = strlen(location);
@@ -834,15 +837,20 @@ static int include_cgi(char *s, request_rec *r, ap_filter_t *next,
* and a single pool bucket */ * and a single pool bucket */
tmp_buck = apr_bucket_immortal_create("<A HREF=\"", tmp_buck = apr_bucket_immortal_create("<A HREF=\"",
sizeof("<A HREF=\"") - 1); sizeof("<A HREF=\"") - 1,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
tmp2_buck = apr_bucket_heap_create(location, len_loc, 1); tmp2_buck = apr_bucket_heap_create(location, len_loc, NULL,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
tmp2_buck = apr_bucket_immortal_create("\">", sizeof("\">") - 1); tmp2_buck = apr_bucket_immortal_create("\">", sizeof("\">") - 1,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
tmp2_buck = apr_bucket_heap_create(location, len_loc, 1); tmp2_buck = apr_bucket_heap_create(location, len_loc, NULL,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
tmp2_buck = apr_bucket_immortal_create("</A>", sizeof("</A>") - 1); tmp2_buck = apr_bucket_immortal_create("</A>", sizeof("</A>") - 1,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
@@ -890,8 +898,8 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb,
return HTTP_INTERNAL_SERVER_ERROR; return HTTP_INTERNAL_SERVER_ERROR;
} }
bcgi = apr_brigade_create(r->pool); bcgi = apr_brigade_create(r->pool, f->c->bucket_alloc);
b = apr_bucket_pipe_create(script_in); b = apr_bucket_pipe_create(script_in, f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bcgi, b); APR_BRIGADE_INSERT_TAIL(bcgi, b);
ap_pass_brigade(f->next, bcgi); ap_pass_brigade(f->next, bcgi);

View File

@@ -975,6 +975,7 @@ static int connect_to_daemon(int *sdptr, request_rec *r,
*/ */
static int cgid_handler(request_rec *r) static int cgid_handler(request_rec *r)
{ {
conn_rec *c = r->connection;
int retval, nph, dbpos = 0; int retval, nph, dbpos = 0;
char *argv0, *dbuf = NULL; char *argv0, *dbuf = NULL;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
@@ -1156,10 +1157,10 @@ static int cgid_handler(request_rec *r)
*/ */
apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket); apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket);
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_pipe_create(tempsock); b = apr_bucket_pipe_create(tempsock, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb); ap_pass_brigade(r->output_filters, bb);
} }
@@ -1185,10 +1186,10 @@ static int cgid_handler(request_rec *r)
} }
r->output_filters = r->proto_output_filters = cur; r->output_filters = r->proto_output_filters = cur;
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_pipe_create(tempsock); b = apr_bucket_pipe_create(tempsock, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb); ap_pass_brigade(r->output_filters, bb);
} }
@@ -1244,6 +1245,7 @@ static int include_cgi(char *s, request_rec *r, ap_filter_t *next,
if (ap_is_HTTP_REDIRECT(rr_status)) { if (ap_is_HTTP_REDIRECT(rr_status)) {
apr_size_t len_loc; apr_size_t len_loc;
const char *location = apr_table_get(rr->headers_out, "Location"); const char *location = apr_table_get(rr->headers_out, "Location");
conn_rec *c = r->connection;
location = ap_escape_html(rr->pool, location); location = ap_escape_html(rr->pool, location);
len_loc = strlen(location); len_loc = strlen(location);
@@ -1253,15 +1255,20 @@ static int include_cgi(char *s, request_rec *r, ap_filter_t *next,
* and a single pool bucket */ * and a single pool bucket */
tmp_buck = apr_bucket_immortal_create("<A HREF=\"", tmp_buck = apr_bucket_immortal_create("<A HREF=\"",
sizeof("<A HREF=\"") - 1); sizeof("<A HREF=\"") - 1,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
tmp2_buck = apr_bucket_heap_create(location, len_loc, 1); tmp2_buck = apr_bucket_heap_create(location, len_loc, NULL,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
tmp2_buck = apr_bucket_immortal_create("\">", sizeof("\">") - 1); tmp2_buck = apr_bucket_immortal_create("\">", sizeof("\">") - 1,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
tmp2_buck = apr_bucket_heap_create(location, len_loc, 1); tmp2_buck = apr_bucket_heap_create(location, len_loc, NULL,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
tmp2_buck = apr_bucket_immortal_create("</A>", sizeof("</A>") - 1); tmp2_buck = apr_bucket_immortal_create("</A>", sizeof("</A>") - 1,
c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck); APR_BUCKET_INSERT_BEFORE(head_ptr, tmp2_buck);
if (*inserted_head == NULL) { if (*inserted_head == NULL) {
@@ -1381,8 +1388,8 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb, char *comman
*/ */
apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket); apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket);
bcgi = apr_brigade_create(r->pool); bcgi = apr_brigade_create(r->pool, r->connection->bucket_alloc);
b = apr_bucket_pipe_create(tempsock); b = apr_bucket_pipe_create(tempsock, r->connection->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bcgi, b); APR_BRIGADE_INSERT_TAIL(bcgi, b);
ap_pass_brigade(f->next, bcgi); ap_pass_brigade(f->next, bcgi);
} }

View File

@@ -144,6 +144,7 @@ static apr_status_t chunk_filter(ap_filter_t *f, apr_bucket_brigade *b)
{ {
#define ASCII_CRLF "\015\012" #define ASCII_CRLF "\015\012"
#define ASCII_ZERO "\060" #define ASCII_ZERO "\060"
conn_rec *c = f->r->connection;
apr_bucket_brigade *more; apr_bucket_brigade *more;
apr_bucket *e; apr_bucket *e;
apr_status_t rv; apr_status_t rv;
@@ -214,14 +215,15 @@ static apr_status_t chunk_filter(ap_filter_t *f, apr_bucket_brigade *b)
hdr_len = apr_snprintf(chunk_hdr, sizeof(chunk_hdr), hdr_len = apr_snprintf(chunk_hdr, sizeof(chunk_hdr),
"%qx" CRLF, (apr_uint64_t)bytes); "%qx" CRLF, (apr_uint64_t)bytes);
ap_xlate_proto_to_ascii(chunk_hdr, hdr_len); ap_xlate_proto_to_ascii(chunk_hdr, hdr_len);
e = apr_bucket_transient_create(chunk_hdr, hdr_len); e = apr_bucket_transient_create(chunk_hdr, hdr_len,
c->bucket_alloc);
APR_BRIGADE_INSERT_HEAD(b, e); APR_BRIGADE_INSERT_HEAD(b, e);
/* /*
* Insert the end-of-chunk CRLF before an EOS or * Insert the end-of-chunk CRLF before an EOS or
* FLUSH bucket, or appended to the brigade * FLUSH bucket, or appended to the brigade
*/ */
e = apr_bucket_immortal_create(ASCII_CRLF, 2); e = apr_bucket_immortal_create(ASCII_CRLF, 2, c->bucket_alloc);
if (eos != NULL) { if (eos != NULL) {
APR_BUCKET_INSERT_BEFORE(eos, e); APR_BUCKET_INSERT_BEFORE(eos, e);
} }
@@ -248,7 +250,9 @@ static apr_status_t chunk_filter(ap_filter_t *f, apr_bucket_brigade *b)
*/ */
if (eos != NULL) { if (eos != NULL) {
/* XXX: (2) trailers ... does not yet exist */ /* XXX: (2) trailers ... does not yet exist */
e = apr_bucket_immortal_create(ASCII_ZERO ASCII_CRLF /* <trailers> */ ASCII_CRLF, 5); e = apr_bucket_immortal_create(ASCII_ZERO ASCII_CRLF
/* <trailers> */
ASCII_CRLF, 5, c->bucket_alloc);
APR_BUCKET_INSERT_BEFORE(eos, e); APR_BUCKET_INSERT_BEFORE(eos, e);
} }

View File

@@ -739,11 +739,12 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b,
} }
if (!ctx->remaining) { if (!ctx->remaining) {
conn_rec *c = f->r->connection;
switch (ctx->state) { switch (ctx->state) {
case BODY_NONE: case BODY_NONE:
break; break;
case BODY_LENGTH: case BODY_LENGTH:
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(b, e); APR_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS; return APR_SUCCESS;
case BODY_CHUNK: case BODY_CHUNK:
@@ -766,7 +767,7 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b,
if (!ctx->remaining) { if (!ctx->remaining) {
/* Handle trailers by calling get_mime_headers again! */ /* Handle trailers by calling get_mime_headers again! */
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(b, e); APR_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS; return APR_SUCCESS;
} }
@@ -1164,7 +1165,7 @@ AP_DECLARE_NONSTD(int) ap_send_http_trace(request_rec *r)
/* Now we recreate the request, and echo it back */ /* Now we recreate the request, and echo it back */
b = apr_brigade_create(r->pool); b = apr_brigade_create(r->pool, r->connection->bucket_alloc);
apr_brigade_putstrs(b, NULL, NULL, r->the_request, CRLF, NULL); apr_brigade_putstrs(b, NULL, NULL, r->the_request, CRLF, NULL);
h.pool = r->pool; h.pool = r->pool;
h.bb = b; h.bb = b;
@@ -1290,6 +1291,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
{ {
int i; int i;
request_rec *r = f->r; request_rec *r = f->r;
conn_rec *c = r->connection;
const char *clheader; const char *clheader;
const char *protocol; const char *protocol;
apr_bucket *e; apr_bucket *e;
@@ -1416,7 +1418,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f,
apr_table_unset(r->headers_out, "Content-Length"); apr_table_unset(r->headers_out, "Content-Length");
} }
b2 = apr_brigade_create(r->pool); b2 = apr_brigade_create(r->pool, c->bucket_alloc);
basic_http_header(r, b2, protocol); basic_http_header(r, b2, protocol);
h.pool = r->pool; h.pool = r->pool;
@@ -1575,6 +1577,7 @@ AP_DECLARE(int) ap_should_client_block(request_rec *r)
} }
if (r->expecting_100 && r->proto_num >= HTTP_VERSION(1,1)) { if (r->expecting_100 && r->proto_num >= HTTP_VERSION(1,1)) {
conn_rec *c = r->connection;
char *tmp; char *tmp;
apr_bucket *e; apr_bucket *e;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
@@ -1582,10 +1585,10 @@ AP_DECLARE(int) ap_should_client_block(request_rec *r)
/* sending 100 Continue interim response */ /* sending 100 Continue interim response */
tmp = apr_pstrcat(r->pool, AP_SERVER_PROTOCOL, " ", status_lines[0], tmp = apr_pstrcat(r->pool, AP_SERVER_PROTOCOL, " ", status_lines[0],
CRLF CRLF, NULL); CRLF CRLF, NULL);
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
e = apr_bucket_pool_create(tmp, strlen(tmp), r->pool); e = apr_bucket_pool_create(tmp, strlen(tmp), r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_HEAD(bb, e); APR_BRIGADE_INSERT_HEAD(bb, e);
e = apr_bucket_flush_create(); e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(r->connection->output_filters, bb); ap_pass_brigade(r->connection->output_filters, bb);
@@ -2585,6 +2588,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
{ {
#define MIN_LENGTH(len1, len2) ((len1 > len2) ? len2 : len1) #define MIN_LENGTH(len1, len2) ((len1 > len2) ? len2 : len1)
request_rec *r = f->r; request_rec *r = f->r;
conn_rec *c = r->connection;
byterange_ctx *ctx = f->ctx; byterange_ctx *ctx = f->ctx;
apr_bucket *e; apr_bucket *e;
apr_bucket_brigade *bsend; apr_bucket_brigade *bsend;
@@ -2602,11 +2606,11 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
if (num_ranges == -1) { if (num_ranges == -1) {
ap_remove_output_filter(f); ap_remove_output_filter(f);
bsend = apr_brigade_create(r->pool); bsend = apr_brigade_create(r->pool, c->bucket_alloc);
e = ap_bucket_error_create(HTTP_RANGE_NOT_SATISFIABLE, NULL, e = ap_bucket_error_create(HTTP_RANGE_NOT_SATISFIABLE, NULL,
r->pool); r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e); APR_BRIGADE_INSERT_TAIL(bsend, e);
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e); APR_BRIGADE_INSERT_TAIL(bsend, e);
return ap_pass_brigade(f->next, bsend); return ap_pass_brigade(f->next, bsend);
} }
@@ -2627,7 +2631,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
} }
/* create a brigade in case we never call ap_save_brigade() */ /* create a brigade in case we never call ap_save_brigade() */
ctx->bb = apr_brigade_create(r->pool); ctx->bb = apr_brigade_create(r->pool, c->bucket_alloc);
} }
/* We can't actually deal with byte-ranges until we have the whole brigade /* We can't actually deal with byte-ranges until we have the whole brigade
@@ -2664,7 +2668,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
clength = (apr_off_t)bb_length; clength = (apr_off_t)bb_length;
/* this brigade holds what we will be sending */ /* this brigade holds what we will be sending */
bsend = apr_brigade_create(r->pool); bsend = apr_brigade_create(r->pool, c->bucket_alloc);
while ((current = ap_getword(r->pool, &r->range, ',')) while ((current = ap_getword(r->pool, &r->range, ','))
&& (rv = parse_byterange(current, clength, &range_start, && (rv = parse_byterange(current, clength, &range_start,
@@ -2695,14 +2699,15 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
if (ctx->num_ranges > 1) { if (ctx->num_ranges > 1) {
char *ts; char *ts;
e = apr_bucket_pool_create(bound_head, e = apr_bucket_pool_create(bound_head, strlen(bound_head),
strlen(bound_head), r->pool); r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e); APR_BRIGADE_INSERT_TAIL(bsend, e);
ts = apr_psprintf(r->pool, BYTERANGE_FMT CRLF CRLF, ts = apr_psprintf(r->pool, BYTERANGE_FMT CRLF CRLF,
range_start, range_end, clength); range_start, range_end, clength);
ap_xlate_proto_to_ascii(ts, strlen(ts)); ap_xlate_proto_to_ascii(ts, strlen(ts));
e = apr_bucket_pool_create(ts, strlen(ts), r->pool); e = apr_bucket_pool_create(ts, strlen(ts), r->pool,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e); APR_BRIGADE_INSERT_TAIL(bsend, e);
} }
@@ -2739,11 +2744,11 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f,
/* add the final boundary */ /* add the final boundary */
end = apr_pstrcat(r->pool, CRLF "--", r->boundary, "--" CRLF, NULL); end = apr_pstrcat(r->pool, CRLF "--", r->boundary, "--" CRLF, NULL);
ap_xlate_proto_to_ascii(end, strlen(end)); ap_xlate_proto_to_ascii(end, strlen(end));
e = apr_bucket_pool_create(end, strlen(end), r->pool); e = apr_bucket_pool_create(end, strlen(end), r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e); APR_BRIGADE_INSERT_TAIL(bsend, e);
} }
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e); APR_BRIGADE_INSERT_TAIL(bsend, e);
/* we're done with the original content */ /* we're done with the original content */

View File

@@ -207,10 +207,11 @@ AP_DECLARE(void) ap_die(int type, request_rec *r)
static void check_pipeline_flush(request_rec *r) static void check_pipeline_flush(request_rec *r)
{ {
conn_rec *c = r->connection;
/* ### if would be nice if we could PEEK without a brigade. that would /* ### if would be nice if we could PEEK without a brigade. that would
### allow us to defer creation of the brigade to when we actually ### allow us to defer creation of the brigade to when we actually
### need to send a FLUSH. */ ### need to send a FLUSH. */
apr_bucket_brigade *bb = apr_brigade_create(r->pool); apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
/* Flush the filter contents if: /* Flush the filter contents if:
* *
@@ -222,7 +223,7 @@ static void check_pipeline_flush(request_rec *r)
if (!r->connection->keepalive || if (!r->connection->keepalive ||
ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF, ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF,
APR_NONBLOCK_READ, 0) != APR_SUCCESS) { APR_NONBLOCK_READ, 0) != APR_SUCCESS) {
apr_bucket *e = apr_bucket_flush_create(); apr_bucket *e = apr_bucket_flush_create(c->bucket_alloc);
/* We just send directly to the connection based filters. At /* We just send directly to the connection based filters. At
* this point, we know that we have seen all of the data * this point, we know that we have seen all of the data

View File

@@ -2813,6 +2813,7 @@ static int handle_map_file(request_rec *r)
if (best->body) if (best->body)
{ {
conn_rec *c = r->connection;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *e; apr_bucket *e;
@@ -2840,11 +2841,12 @@ static int handle_map_file(request_rec *r)
return res; return res;
} }
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
e = apr_bucket_file_create(map, best->body, e = apr_bucket_file_create(map, best->body,
(apr_size_t)best->bytes, r->pool); (apr_size_t)best->bytes, r->pool,
c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
return ap_pass_brigade(r->output_filters, bb); return ap_pass_brigade(r->output_filters, bb);

View File

@@ -315,8 +315,9 @@ typedef struct {
apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in) apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
{ {
request_rec *r = f->r; request_rec *r = f->r;
conn_rec *c = r->connection;
apr_pool_t *p = r->pool; apr_pool_t *p = r->pool;
apr_bucket_brigade *out = apr_brigade_create(p); apr_bucket_brigade *out = apr_brigade_create(p, c->bucket_alloc);
apr_status_t rv; apr_status_t rv;
register int n; register int n;
@@ -329,7 +330,7 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
if (!ctx) { if (!ctx) {
f->ctx = ctx = apr_pcalloc(p, sizeof(*ctx)); f->ctx = ctx = apr_pcalloc(p, sizeof(*ctx));
ctx->in = apr_brigade_create(p); ctx->in = apr_brigade_create(p, c->bucket_alloc);
ctx->buffer[0] = 0; ctx->buffer[0] = 0;
ctx->state = HEADER; ctx->state = HEADER;
} }
@@ -387,7 +388,8 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
site, basedir, ap_escape_uri(p, path), site, basedir, ap_escape_uri(p, path),
site, str); site, str);
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p)); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str),
p, c->bucket_alloc));
for (dir = path+1; (dir = strchr(dir, '/')) != NULL; ) for (dir = path+1; (dir = strchr(dir, '/')) != NULL; )
{ {
@@ -404,10 +406,14 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
*dir = '/'; *dir = '/';
while (*dir == '/') while (*dir == '/')
++dir; ++dir;
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p)); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str,
strlen(str), p,
c->bucket_alloc));
} }
if (wildcard != NULL) { if (wildcard != NULL) {
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(wildcard, strlen(wildcard), p)); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(wildcard,
strlen(wildcard), p,
c->bucket_alloc));
} }
/* If the caller has determined the current directory, and it differs */ /* If the caller has determined the current directory, and it differs */
@@ -419,18 +425,21 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
str = apr_psprintf(p, "</h2>\n\n(%s)\n\n <hr />\n\n<pre>", str = apr_psprintf(p, "</h2>\n\n(%s)\n\n <hr />\n\n<pre>",
ap_escape_html(p, pwd)); ap_escape_html(p, pwd));
} }
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p)); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str),
p, c->bucket_alloc));
/* print README */ /* print README */
if (readme) { if (readme) {
str = apr_psprintf(p, "%s\n</pre>\n\n<hr />\n\n<pre>\n", str = apr_psprintf(p, "%s\n</pre>\n\n<hr />\n\n<pre>\n",
ap_escape_html(p, readme)); ap_escape_html(p, readme));
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p)); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str,
strlen(str), p,
c->bucket_alloc));
} }
/* make sure page intro gets sent out */ /* make sure page intro gets sent out */
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_flush_create()); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_flush_create(c->bucket_alloc));
if (APR_SUCCESS != (rv = ap_pass_brigade(f->next, out))) { if (APR_SUCCESS != (rv = ap_pass_brigade(f->next, out))) {
return rv; return rv;
} }
@@ -581,8 +590,9 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
/* erase buffer for next time around */ /* erase buffer for next time around */
ctx->buffer[0] = 0; ctx->buffer[0] = 0;
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p)); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p,
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_flush_create()); c->bucket_alloc));
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_flush_create(c->bucket_alloc));
if (APR_SUCCESS != (rv = ap_pass_brigade(f->next, out))) { if (APR_SUCCESS != (rv = ap_pass_brigade(f->next, out))) {
return rv; return rv;
} }
@@ -592,9 +602,10 @@ apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
if (FOOTER == ctx->state) { if (FOOTER == ctx->state) {
str = apr_psprintf(p, "</pre>\n\n <hr />\n\n %s\n\n </body>\n</html>\n", ap_psignature("", r)); str = apr_psprintf(p, "</pre>\n\n <hr />\n\n %s\n\n </body>\n</html>\n", ap_psignature("", r));
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p)); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p,
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_flush_create()); c->bucket_alloc));
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_eos_create()); APR_BRIGADE_INSERT_TAIL(out, apr_bucket_flush_create(c->bucket_alloc));
APR_BRIGADE_INSERT_TAIL(out, apr_bucket_eos_create(c->bucket_alloc));
if (APR_SUCCESS != (rv = ap_pass_brigade(f->next, out))) { if (APR_SUCCESS != (rv = ap_pass_brigade(f->next, out))) {
return rv; return rv;
} }
@@ -619,9 +630,9 @@ proxy_ftp_command(const char *cmd, request_rec *r, conn_rec *ftp_ctrl,
/* If cmd == NULL, we retrieve the next ftp response line */ /* If cmd == NULL, we retrieve the next ftp response line */
if (cmd != NULL) { if (cmd != NULL) {
conn_rec *c = r->connection;
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(cmd, strlen(cmd), r->pool)); APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(cmd, strlen(cmd), r->pool, c->bucket_alloc));
APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_flush_create()); APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_flush_create(c->bucket_alloc));
ap_pass_brigade(ftp_ctrl->output_filters, bb); ap_pass_brigade(ftp_ctrl->output_filters, bb);
/* strip off the CRLF for logging */ /* strip off the CRLF for logging */
@@ -768,7 +779,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
apr_status_t rv; apr_status_t rv;
conn_rec *origin, *data = NULL; conn_rec *origin, *data = NULL;
int err; int err;
apr_bucket_brigade *bb = apr_brigade_create(p); apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
char *buf, *connectname; char *buf, *connectname;
apr_port_t connectport; apr_port_t connectport;
char buffer[MAX_STRING_LEN]; char buffer[MAX_STRING_LEN];
@@ -1013,7 +1024,8 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
} }
/* the socket is now open, create a new connection */ /* the socket is now open, create a new connection */
origin = ap_run_create_connection(p, r->server, sock, r->connection->id, r->connection->sbh); origin = ap_run_create_connection(p, r->server, sock, r->connection->id,
r->connection->sbh, c->bucket_alloc);
if (!origin) { if (!origin) {
/* /*
* the peer reset the connection already; ap_run_create_connection() closed * the peer reset the connection already; ap_run_create_connection() closed
@@ -1084,7 +1096,6 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
return ap_proxyerror(r, HTTP_BAD_GATEWAY, ftpmessage); return ap_proxyerror(r, HTTP_BAD_GATEWAY, ftpmessage);
} }
rc = proxy_ftp_command(apr_pstrcat(p, "USER ", user, CRLF, NULL), rc = proxy_ftp_command(apr_pstrcat(p, "USER ", user, CRLF, NULL),
r, origin, bb, &ftpmessage); r, origin, bb, &ftpmessage);
/* possible results; 230, 331, 332, 421, 500, 501, 530 */ /* possible results; 230, 331, 332, 421, 500, 501, 530 */
@@ -1774,7 +1785,8 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
} }
/* the transfer socket is now open, create a new connection */ /* the transfer socket is now open, create a new connection */
data = ap_run_create_connection(p, r->server, data_sock, r->connection->id, r->connection->sbh); data = ap_run_create_connection(p, r->server, data_sock, r->connection->id,
r->connection->sbh, c->bucket_alloc);
if (!data) { if (!data) {
/* /*
* the peer reset the connection already; ap_run_create_connection() closed * the peer reset the connection already; ap_run_create_connection() closed
@@ -1849,7 +1861,7 @@ int ap_proxy_ftp_handler(request_rec *r, proxy_server_conf *conf,
/* if no EOS yet, then we must flush */ /* if no EOS yet, then we must flush */
if (FALSE == finish) { if (FALSE == finish) {
e = apr_bucket_flush_create(); e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
} }

View File

@@ -375,7 +375,8 @@ apr_status_t ap_proxy_http_create_connection(apr_pool_t *p, request_rec *r,
/* the socket is now open, create a new backend server connection */ /* the socket is now open, create a new backend server connection */
*origin = ap_run_create_connection(c->pool, r->server, p_conn->sock, *origin = ap_run_create_connection(c->pool, r->server, p_conn->sock,
r->connection->id, r->connection->sbh); r->connection->id,
r->connection->sbh, c->bucket_alloc);
if (!origin) { if (!origin) {
/* the peer reset the connection already; ap_run_create_connection() /* the peer reset the connection already; ap_run_create_connection()
* closed the socket * closed the socket
@@ -412,6 +413,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
apr_uri_t *uri, apr_uri_t *uri,
char *url, apr_bucket_brigade *bb, char *url, apr_bucket_brigade *bb,
char *server_portstr) { char *server_portstr) {
conn_rec *c = r->connection;
char buffer[HUGE_STRING_LEN]; char buffer[HUGE_STRING_LEN];
char *buf; char *buf;
apr_bucket *e; apr_bucket *e;
@@ -442,7 +444,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
} }
buf = apr_pstrcat(p, r->method, " ", url, " HTTP/1.1" CRLF, NULL); buf = apr_pstrcat(p, r->method, " ", url, " HTTP/1.1" CRLF, NULL);
e = apr_bucket_pool_create(buf, strlen(buf), p); e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
if ( conf->preserve_host == 0 ) { if ( conf->preserve_host == 0 ) {
if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) { if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
@@ -468,7 +470,7 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
} }
buf = apr_pstrcat(p, "Host: ", hostname, CRLF, NULL); buf = apr_pstrcat(p, "Host: ", hostname, CRLF, NULL);
} }
e = apr_bucket_pool_create(buf, strlen(buf), p); e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
/* handle Via */ /* handle Via */
@@ -583,14 +585,14 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
buf = apr_pstrcat(p, headers_in[counter].key, ": ", buf = apr_pstrcat(p, headers_in[counter].key, ": ",
headers_in[counter].val, CRLF, headers_in[counter].val, CRLF,
NULL); NULL);
e = apr_bucket_pool_create(buf, strlen(buf), p); e = apr_bucket_pool_create(buf, strlen(buf), p, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
} }
/* add empty line at the end of the headers */ /* add empty line at the end of the headers */
e = apr_bucket_immortal_create(CRLF, sizeof(CRLF)-1); e = apr_bucket_immortal_create(CRLF, sizeof(CRLF)-1, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
e = apr_bucket_flush_create(); e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(origin->output_filters, bb); ap_pass_brigade(origin->output_filters, bb);
@@ -598,9 +600,9 @@ apr_status_t ap_proxy_http_request(apr_pool_t *p, request_rec *r,
/* send the request data, if any. */ /* send the request data, if any. */
if (ap_should_client_block(r)) { if (ap_should_client_block(r)) {
while ((counter = ap_get_client_block(r, buffer, sizeof(buffer))) > 0) { while ((counter = ap_get_client_block(r, buffer, sizeof(buffer))) > 0) {
e = apr_bucket_pool_create(buffer, counter, p); e = apr_bucket_pool_create(buffer, counter, p, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
e = apr_bucket_flush_create(); e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(origin->output_filters, bb); ap_pass_brigade(origin->output_filters, bb);
apr_brigade_cleanup(bb); apr_brigade_cleanup(bb);
@@ -617,6 +619,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
proxy_server_conf *conf, proxy_server_conf *conf,
apr_bucket_brigade *bb, apr_bucket_brigade *bb,
char *server_portstr) { char *server_portstr) {
conn_rec *c = r->connection;
char buffer[HUGE_STRING_LEN]; char buffer[HUGE_STRING_LEN];
request_rec *rp; request_rec *rp;
apr_bucket *e; apr_bucket *e;
@@ -789,7 +792,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
/* Is it an HTTP/0.9 response? If so, send the extra data */ /* Is it an HTTP/0.9 response? If so, send the extra data */
if (backasswards) { if (backasswards) {
apr_ssize_t cntr = len; apr_ssize_t cntr = len;
e = apr_bucket_heap_create(buffer, cntr, 1); e = apr_bucket_heap_create(buffer, cntr, NULL, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
} }
@@ -859,7 +862,7 @@ apr_status_t ap_proxy_http_process_response(apr_pool_t * p, request_rec *r,
/* if no EOS yet, then we must flush */ /* if no EOS yet, then we must flush */
if (FALSE == finish) { if (FALSE == finish) {
e = apr_bucket_flush_create(); e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
} }
@@ -958,7 +961,7 @@ int ap_proxy_http_handler(request_rec *r, proxy_server_conf *conf,
*/ */
apr_pool_t *p = r->connection->pool; apr_pool_t *p = r->connection->pool;
conn_rec *c = r->connection; conn_rec *c = r->connection;
apr_bucket_brigade *bb = apr_brigade_create(p); apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
apr_uri_t *uri = apr_palloc(r->connection->pool, sizeof(*uri)); apr_uri_t *uri = apr_palloc(r->connection->pool, sizeof(*uri));
proxy_http_conn_t *p_conn = apr_pcalloc(r->connection->pool, proxy_http_conn_t *p_conn = apr_pcalloc(r->connection->pool,
sizeof(*p_conn)); sizeof(*p_conn));

View File

@@ -99,7 +99,7 @@ static BIO_bucket_t *BIO_bucket_new(SSLFilterRec *frec, conn_rec *c)
b->frec = frec; b->frec = frec;
b->c = c; b->c = c;
b->bb = apr_brigade_create(c->pool); b->bb = apr_brigade_create(c->pool, c->bucket_alloc);
b->blen = 0; b->blen = 0;
b->length = 0; b->length = 0;
@@ -111,24 +111,25 @@ static BIO_bucket_t *BIO_bucket_new(SSLFilterRec *frec, conn_rec *c)
static int BIO_bucket_flush(BIO *bio) static int BIO_bucket_flush(BIO *bio)
{ {
BIO_bucket_t *b = BIO_bucket_ptr(bio); BIO_bucket_t *b = BIO_bucket_ptr(bio);
apr_bucket *e;
if (!(b->blen || b->length)) { if (!(b->blen || b->length)) {
return APR_SUCCESS; return APR_SUCCESS;
} }
if (b->blen) { if (b->blen) {
apr_bucket *bucket = e = apr_bucket_transient_create(b->buffer, b->blen,
apr_bucket_transient_create(b->buffer, b->bb->bucket_alloc);
b->blen);
/* we filled this buffer first so add it to the /* we filled this buffer first so add it to the
* head of the brigade * head of the brigade
*/ */
APR_BRIGADE_INSERT_HEAD(b->bb, bucket); APR_BRIGADE_INSERT_HEAD(b->bb, e);
b->blen = 0; b->blen = 0;
} }
b->length = 0; b->length = 0;
APR_BRIGADE_INSERT_TAIL(b->bb, apr_bucket_flush_create()); e = apr_bucket_flush_create(b->bb->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(b->bb, e);
return ap_pass_brigade(b->frec->pOutputFilter->next, b->bb); return ap_pass_brigade(b->frec->pOutputFilter->next, b->bb);
} }
@@ -187,7 +188,8 @@ static int bio_bucket_write(BIO *bio, const char *in, int inl)
* need to flush since we're using SSL's malloc-ed buffer * need to flush since we're using SSL's malloc-ed buffer
* which will be overwritten once we leave here * which will be overwritten once we leave here
*/ */
apr_bucket *bucket = apr_bucket_transient_create(in, inl); apr_bucket *bucket = apr_bucket_transient_create(in, inl,
b->bb->bucket_alloc);
b->length += inl; b->length += inl;
APR_BRIGADE_INSERT_TAIL(b->bb, bucket); APR_BRIGADE_INSERT_TAIL(b->bb, bucket);
@@ -732,9 +734,10 @@ static apr_status_t ssl_io_input_getline(ssl_io_input_ctx_t *ctx,
#define HTTP_ON_HTTPS_PORT \ #define HTTP_ON_HTTPS_PORT \
"GET /mod_ssl:error:HTTP-request HTTP/1.0\r\n\r\n" "GET /mod_ssl:error:HTTP-request HTTP/1.0\r\n\r\n"
#define HTTP_ON_HTTPS_PORT_BUCKET() \ #define HTTP_ON_HTTPS_PORT_BUCKET(alloc) \
apr_bucket_immortal_create(HTTP_ON_HTTPS_PORT, \ apr_bucket_immortal_create(HTTP_ON_HTTPS_PORT, \
sizeof(HTTP_ON_HTTPS_PORT) - 1) sizeof(HTTP_ON_HTTPS_PORT) - 1, \
alloc)
static apr_status_t ssl_io_filter_error(ap_filter_t *f, static apr_status_t ssl_io_filter_error(ap_filter_t *f,
apr_bucket_brigade *bb, apr_bucket_brigade *bb,
@@ -750,7 +753,7 @@ static apr_status_t ssl_io_filter_error(ap_filter_t *f,
"trying to send HTML error page"); "trying to send HTML error page");
/* fake the request line */ /* fake the request line */
bucket = HTTP_ON_HTTPS_PORT_BUCKET(); bucket = HTTP_ON_HTTPS_PORT_BUCKET(f->c->bucket_alloc);
break; break;
default: default:
@@ -824,7 +827,7 @@ static apr_status_t ssl_io_filter_Input(ap_filter_t *f,
if (len > 0) { if (len > 0) {
apr_bucket *bucket = apr_bucket *bucket =
apr_bucket_transient_create(ctx->buffer, len); apr_bucket_transient_create(ctx->buffer, len, f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, bucket); APR_BRIGADE_INSERT_TAIL(bb, bucket);
} }
@@ -847,7 +850,7 @@ static void ssl_io_input_add_filter(SSLFilterRec *frec, conn_rec *c,
ctx->inbio.ssl = ssl; ctx->inbio.ssl = ssl;
ctx->inbio.wbio = frec->pbioWrite; ctx->inbio.wbio = frec->pbioWrite;
ctx->inbio.f = frec->pInputFilter; ctx->inbio.f = frec->pInputFilter;
ctx->inbio.bb = apr_brigade_create(c->pool); ctx->inbio.bb = apr_brigade_create(c->pool, c->bucket_alloc);
ctx->inbio.bucket = NULL; ctx->inbio.bucket = NULL;
ctx->inbio.cbuf.length = 0; ctx->inbio.cbuf.length = 0;

View File

@@ -122,7 +122,7 @@ static apr_status_t bucketeer_out_filter(ap_filter_t *f,
/* We're cool with filtering this. */ /* We're cool with filtering this. */
ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(*ctx));
ctx->bb = apr_brigade_create(f->r->pool); ctx->bb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
apr_table_unset(f->r->headers_out, "Content-Length"); apr_table_unset(f->r->headers_out, "Content-Length");
} }
@@ -163,13 +163,13 @@ static apr_status_t bucketeer_out_filter(ap_filter_t *f,
p = apr_bucket_pool_create(apr_pmemdup( f->r->pool, p = apr_bucket_pool_create(apr_pmemdup( f->r->pool,
&data[lastpos], &data[lastpos],
i-lastpos), i-lastpos),
i-lastpos, i-lastpos, f->r->pool,
f->r->pool); f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb,p); APR_BRIGADE_INSERT_TAIL(ctx->bb,p);
} }
lastpos=i+1; lastpos=i+1;
if ( data[i] == c->flushdelimiter) { if ( data[i] == c->flushdelimiter) {
p = apr_bucket_flush_create(); p = apr_bucket_flush_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb,p); APR_BRIGADE_INSERT_TAIL(ctx->bb,p);
} }
if ( data[i] == c->flushdelimiter || data[i] == c->passdelimiter ) { if ( data[i] == c->flushdelimiter || data[i] == c->passdelimiter ) {
@@ -181,7 +181,11 @@ static apr_status_t bucketeer_out_filter(ap_filter_t *f,
/* XXX: really should append this to the next 'real' bucket */ /* XXX: really should append this to the next 'real' bucket */
if ( lastpos < i ) { if ( lastpos < i ) {
apr_bucket *p; apr_bucket *p;
p = apr_bucket_pool_create(apr_pmemdup( f->r->pool,&data[lastpos],i-lastpos),i-lastpos,f->r->pool); p = apr_bucket_pool_create(apr_pmemdup(f->r->pool,
&data[lastpos],
i-lastpos),
i-lastpos, f->r->pool,
f->c->bucket_alloc);
lastpos=i; lastpos=i;
APR_BRIGADE_INSERT_TAIL(ctx->bb,p); APR_BRIGADE_INSERT_TAIL(ctx->bb,p);
} }

View File

@@ -80,8 +80,8 @@ APR_HOOK_STRUCT(
APR_HOOK_LINK(pre_connection) APR_HOOK_LINK(pre_connection)
) )
AP_IMPLEMENT_HOOK_RUN_FIRST(conn_rec *,create_connection, AP_IMPLEMENT_HOOK_RUN_FIRST(conn_rec *,create_connection,
(apr_pool_t *p, server_rec *server, apr_socket_t *csd, long conn_id, void *sbh), (apr_pool_t *p, server_rec *server, apr_socket_t *csd, long conn_id, void *sbh, apr_bucket_alloc_t *alloc),
(p, server, csd, conn_id, sbh), NULL) (p, server, csd, conn_id, sbh, alloc), NULL)
AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED) AP_IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c, void *csd),(c, csd),OK,DECLINED) AP_IMPLEMENT_HOOK_RUN_ALL(int,pre_connection,(conn_rec *c, void *csd),(c, csd),OK,DECLINED)
/* /*
@@ -113,8 +113,8 @@ AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c)
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
bb = apr_brigade_create(c->pool); bb = apr_brigade_create(c->pool, c->bucket_alloc);
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(c->output_filters, bb); ap_pass_brigade(c->output_filters, bb);
} }

View File

@@ -3122,6 +3122,7 @@ static int core_override_type(request_rec *r)
static int default_handler(request_rec *r) static int default_handler(request_rec *r)
{ {
conn_rec *c = r->connection;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *e; apr_bucket *e;
core_dir_config *d; core_dir_config *d;
@@ -3215,7 +3216,7 @@ static int default_handler(request_rec *r)
ap_md5digest(r->pool, fd)); ap_md5digest(r->pool, fd));
} }
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
#if APR_HAS_LARGE_FILES #if APR_HAS_LARGE_FILES
if (r->finfo.size > AP_MAX_SENDFILE) { if (r->finfo.size > AP_MAX_SENDFILE) {
/* APR_HAS_LARGE_FILES issue; must split into mutiple buckets, /* APR_HAS_LARGE_FILES issue; must split into mutiple buckets,
@@ -3223,7 +3224,8 @@ static int default_handler(request_rec *r)
* in case the brigade code/filters attempt to read it directly. * in case the brigade code/filters attempt to read it directly.
*/ */
apr_off_t fsize = r->finfo.size; apr_off_t fsize = r->finfo.size;
e = apr_bucket_file_create(fd, 0, AP_MAX_SENDFILE, r->pool); e = apr_bucket_file_create(fd, 0, AP_MAX_SENDFILE, r->pool,
c->bucket_alloc);
while (fsize > AP_MAX_SENDFILE) { while (fsize > AP_MAX_SENDFILE) {
apr_bucket *ce; apr_bucket *ce;
apr_bucket_copy(e, &ce); apr_bucket_copy(e, &ce);
@@ -3235,10 +3237,11 @@ static int default_handler(request_rec *r)
} }
else else
#endif #endif
e = apr_bucket_file_create(fd, 0, (apr_size_t)r->finfo.size, r->pool); e = apr_bucket_file_create(fd, 0, (apr_size_t)r->finfo.size,
r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e); APR_BRIGADE_INSERT_TAIL(bb, e);
return ap_pass_brigade(r->output_filters, bb); return ap_pass_brigade(r->output_filters, bb);
@@ -3320,10 +3323,10 @@ static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
if (!ctx) if (!ctx)
{ {
ctx = apr_pcalloc(f->c->pool, sizeof(*ctx)); ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
ctx->b = apr_brigade_create(f->c->pool); ctx->b = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
/* seed the brigade with the client socket. */ /* seed the brigade with the client socket. */
e = apr_bucket_socket_create(net->client_socket); e = apr_bucket_socket_create(net->client_socket, f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->b, e); APR_BRIGADE_INSERT_TAIL(ctx->b, e);
net->in_ctx = ctx; net->in_ctx = ctx;
} }
@@ -3410,7 +3413,7 @@ static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
* so tack on an EOS too. */ * so tack on an EOS too. */
/* We have read until the brigade was empty, so we know that we /* We have read until the brigade was empty, so we know that we
* must be EOS. */ * must be EOS. */
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(b, e); APR_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS; return APR_SUCCESS;
} }
@@ -3444,7 +3447,7 @@ static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
apr_bucket_delete(e); apr_bucket_delete(e);
if (mode == AP_MODE_READBYTES) { if (mode == AP_MODE_READBYTES) {
e = apr_bucket_eos_create(); e = apr_bucket_eos_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(b, e); APR_BRIGADE_INSERT_TAIL(b, e);
} }
return APR_SUCCESS; return APR_SUCCESS;
@@ -3618,7 +3621,8 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
b = bb; b = bb;
} }
else { else {
temp_brig = apr_brigade_create(f->c->pool); temp_brig = apr_brigade_create(f->c->pool,
f->c->bucket_alloc);
} }
temp = APR_BRIGADE_FIRST(b); temp = APR_BRIGADE_FIRST(b);
@@ -3722,7 +3726,8 @@ static apr_status_t core_output_filter(ap_filter_t *f, apr_bucket_brigade *b)
* after the request_pool is cleared. * after the request_pool is cleared.
*/ */
if (ctx->b == NULL) { if (ctx->b == NULL) {
ctx->b = apr_brigade_create(net->c->pool); ctx->b = apr_brigade_create(net->c->pool,
net->c->bucket_alloc);
} }
APR_BRIGADE_FOREACH(bucket, b) { APR_BRIGADE_FOREACH(bucket, b) {
@@ -3925,7 +3930,7 @@ static int core_create_req(request_rec *r)
req_cfg->bb = main_req_cfg->bb; req_cfg->bb = main_req_cfg->bb;
} }
else { else {
req_cfg->bb = apr_brigade_create(r->pool); req_cfg->bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
if (!r->prev) { if (!r->prev) {
ap_add_input_filter_handle(ap_net_time_filter_handle, ap_add_input_filter_handle(ap_net_time_filter_handle,
NULL, r, r->connection); NULL, r, r->connection);
@@ -3948,7 +3953,8 @@ static int core_create_proxy_req(request_rec *r, request_rec *pr)
} }
static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server, static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
apr_socket_t *csd, long id, void *sbh) apr_socket_t *csd, long id, void *sbh,
apr_bucket_alloc_t *alloc)
{ {
apr_status_t rv; apr_status_t rv;
conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec)); conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
@@ -3984,6 +3990,8 @@ static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
c->base_server = server; c->base_server = server;
c->id = id; c->id = id;
c->bucket_alloc = alloc;
return c; return c;
} }

View File

@@ -55,7 +55,6 @@
#include "http_protocol.h" #include "http_protocol.h"
#include "apr_buckets.h" #include "apr_buckets.h"
#include "apr_strings.h" #include "apr_strings.h"
#include <stdlib.h>
#if APR_HAVE_STRINGS_H #if APR_HAVE_STRINGS_H
#include <strings.h> #include <strings.h>
#endif #endif
@@ -73,10 +72,7 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
{ {
ap_bucket_error *h; ap_bucket_error *h;
h = malloc(sizeof(*h)); h = apr_bucket_alloc(sizeof(*h), b->list);
if (h == NULL) {
return NULL;
}
h->status = error; h->status = error;
h->data = (buf) ? apr_pstrdup(p, buf) : NULL; h->data = (buf) ? apr_pstrdup(p, buf) : NULL;
@@ -87,19 +83,21 @@ AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error,
return b; return b;
} }
AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
const char *buf, apr_pool_t *p) apr_pool_t *p,
apr_bucket_alloc_t *list)
{ {
apr_bucket *b = (apr_bucket *)malloc(sizeof(*b)); apr_bucket *b = apr_bucket_alloc(sizeof(*b), list);
APR_BUCKET_INIT(b); APR_BUCKET_INIT(b);
b->free = free; b->free = apr_bucket_free;
b->list = list;
return ap_bucket_error_make(b, error, buf, p); return ap_bucket_error_make(b, error, buf, p);
} }
AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_error = { AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_error = {
"ERROR", 5, "ERROR", 5,
free, apr_bucket_free,
error_read, error_read,
apr_bucket_setaside_notimpl, apr_bucket_setaside_notimpl,
apr_bucket_split_notimpl, apr_bucket_split_notimpl,

View File

@@ -324,7 +324,8 @@ int ap_graceful_stop_signalled(void)
* Child process main loop. * Child process main loop.
*/ */
static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num) static void process_socket(apr_pool_t *p, apr_socket_t *sock,
int my_child_num, apr_bucket_alloc_t *bucket_alloc)
{ {
conn_rec *current_conn; conn_rec *current_conn;
long conn_id = my_child_num; long conn_id = my_child_num;
@@ -359,6 +360,7 @@ static int32 worker_thread(void * dummy)
apr_allocator_t *allocator; apr_allocator_t *allocator;
apr_socket_t *csd = NULL; apr_socket_t *csd = NULL;
apr_pool_t *ptrans; /* Pool for per-transaction stuff */ apr_pool_t *ptrans; /* Pool for per-transaction stuff */
apr_bucket_alloc_t *bucket_alloc;
apr_socket_t *sd = NULL; apr_socket_t *sd = NULL;
apr_status_t rv = APR_EINIT; apr_status_t rv = APR_EINIT;
int srv , n; int srv , n;
@@ -393,6 +395,8 @@ static int32 worker_thread(void * dummy)
for(n=0 ; n <= num_listening_sockets ; n++) for(n=0 ; n <= num_listening_sockets ; n++)
apr_poll_socket_add(pollset, listening_sockets[n], APR_POLLIN); apr_poll_socket_add(pollset, listening_sockets[n], APR_POLLIN);
bucket_alloc = apr_bucket_alloc_create(tpool);
while (1) { while (1) {
/* If we're here, then chances are (unless we're the first thread created) /* If we're here, then chances are (unless we're the first thread created)
* we're going to be held up in the accept mutex, so doing this here * we're going to be held up in the accept mutex, so doing this here
@@ -480,7 +484,7 @@ static int32 worker_thread(void * dummy)
ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
"apr_accept"); "apr_accept");
} else { } else {
process_socket(ptrans, csd, child_slot); process_socket(ptrans, csd, child_slot, bucket_alloc);
requests_this_child--; requests_this_child--;
} }
} }
@@ -493,6 +497,8 @@ static int32 worker_thread(void * dummy)
ap_update_child_status_from_indexes(0, child_slot, SERVER_DEAD, (request_rec*)NULL); ap_update_child_status_from_indexes(0, child_slot, SERVER_DEAD, (request_rec*)NULL);
apr_bucket_alloc_destroy(bucket_alloc);
ap_log_error(APLOG_MARK, APLOG_NOTICE | APLOG_NOERRNO, 0, NULL, ap_log_error(APLOG_MARK, APLOG_NOTICE | APLOG_NOERRNO, 0, NULL,
"worker_thread %ld exiting", find_thread(NULL)); "worker_thread %ld exiting", find_thread(NULL));

View File

@@ -1540,19 +1540,19 @@ static int pass_request(request_rec *r)
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
int sfd; int sfd;
struct iovec iov; struct iovec iov;
apr_bucket_brigade *bb = apr_brigade_create(r->pool); conn_rec *c = r->connection;
apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
perchild_server_conf *sconf = (perchild_server_conf *) perchild_server_conf *sconf = (perchild_server_conf *)
ap_get_module_config(r->server->module_config, ap_get_module_config(r->server->module_config,
&mpm_perchild_module); &mpm_perchild_module);
char *foo; char *foo;
apr_size_t len; apr_size_t len;
apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", c->pool);
r->connection->pool);
len = strlen(foo); len = strlen(foo);
apr_pool_userdata_set(NULL, "PERCHILD_BUFFER", apr_pool_cleanup_null, apr_pool_userdata_set(NULL, "PERCHILD_BUFFER", apr_pool_cleanup_null,
r->connection->pool); c->pool);
apr_os_sock_get(&sfd, thesock); apr_os_sock_get(&sfd, thesock);

View File

@@ -400,6 +400,7 @@ static void worker_main(void *vpArg)
long conn_id; long conn_id;
conn_rec *current_conn; conn_rec *current_conn;
apr_pool_t *pconn; apr_pool_t *pconn;
apr_bucket_alloc_t *bucket_alloc;
worker_args_t *worker_args; worker_args_t *worker_args;
HQUEUE workq; HQUEUE workq;
PID owner; PID owner;
@@ -430,14 +431,18 @@ static void worker_main(void *vpArg)
while (rc = DosReadQueue(workq, &rd, &len, (PPVOID)&worker_args, 0, DCWW_WAIT, &priority, NULLHANDLE), while (rc = DosReadQueue(workq, &rd, &len, (PPVOID)&worker_args, 0, DCWW_WAIT, &priority, NULLHANDLE),
rc == 0 && rd.ulData != WORKTYPE_EXIT) { rc == 0 && rd.ulData != WORKTYPE_EXIT) {
pconn = worker_args->pconn; pconn = worker_args->pconn;
bucket_alloc = apr_bucket_alloc_create(pconn);
ap_create_sb_handle(&sbh, pconn, child_slot, thread_slot); ap_create_sb_handle(&sbh, pconn, child_slot, thread_slot);
current_conn = ap_run_create_connection(pconn, ap_server_conf, worker_args->conn_sd, conn_id, sbh); current_conn = ap_run_create_connection(pconn, ap_server_conf,
worker_args->conn_sd, conn_id,
sbh, bucket_alloc);
if (current_conn) { if (current_conn) {
ap_process_connection(current_conn, worker_args->conn_sd); ap_process_connection(current_conn, worker_args->conn_sd);
ap_lingering_close(current_conn); ap_lingering_close(current_conn);
} }
apr_bucket_alloc_destroy(bucket_alloc);
apr_pool_destroy(pconn); apr_pool_destroy(pconn);
ap_update_child_status_from_indexes(child_slot, thread_slot, ap_update_child_status_from_indexes(child_slot, thread_slot,
SERVER_READY, NULL); SERVER_READY, NULL);

View File

@@ -353,6 +353,7 @@ void worker_main(void *arg)
ap_listen_rec *last_lr = NULL; ap_listen_rec *last_lr = NULL;
apr_pool_t *ptrans; apr_pool_t *ptrans;
apr_allocator_t *allocator; apr_allocator_t *allocator;
apr_bucket_alloc_t *bucket_alloc;
conn_rec *current_conn; conn_rec *current_conn;
apr_status_t stat = APR_EINIT; apr_status_t stat = APR_EINIT;
int worker_num_arg = (int)arg; int worker_num_arg = (int)arg;
@@ -374,6 +375,8 @@ void worker_main(void *arg)
apr_pool_create_ex(&ptrans, NULL, NULL, allocator); apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
apr_allocator_set_owner(allocator, ptrans); apr_allocator_set_owner(allocator, ptrans);
bucket_alloc = apr_bucket_alloc_create(ptrans);
apr_pool_tag(ptrans, "transaction"); apr_pool_tag(ptrans, "transaction");
apr_thread_mutex_lock(worker_thread_count_mutex); apr_thread_mutex_lock(worker_thread_count_mutex);
@@ -533,7 +536,8 @@ got_listener:
* socket options, file descriptors, and read/write buffers. * socket options, file descriptors, and read/write buffers.
*/ */
current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd,
my_worker_num, sbh); my_worker_num, sbh,
bucket_alloc);
if (current_conn) { if (current_conn) {
ap_process_connection(current_conn, csd); ap_process_connection(current_conn, csd);
ap_lingering_close(current_conn); ap_lingering_close(current_conn);

View File

@@ -1540,19 +1540,19 @@ static int pass_request(request_rec *r)
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
int sfd; int sfd;
struct iovec iov; struct iovec iov;
apr_bucket_brigade *bb = apr_brigade_create(r->pool); conn_rec *c = r->connection;
apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
perchild_server_conf *sconf = (perchild_server_conf *) perchild_server_conf *sconf = (perchild_server_conf *)
ap_get_module_config(r->server->module_config, ap_get_module_config(r->server->module_config,
&mpm_perchild_module); &mpm_perchild_module);
char *foo; char *foo;
apr_size_t len; apr_size_t len;
apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", c->pool);
r->connection->pool);
len = strlen(foo); len = strlen(foo);
apr_pool_userdata_set(NULL, "PERCHILD_BUFFER", apr_pool_cleanup_null, apr_pool_userdata_set(NULL, "PERCHILD_BUFFER", apr_pool_cleanup_null,
r->connection->pool); c->pool);
apr_os_sock_get(&sfd, thesock); apr_os_sock_get(&sfd, thesock);

View File

@@ -527,6 +527,7 @@ static void child_main(int child_num_arg)
void *csd; void *csd;
ap_sb_handle_t *sbh; ap_sb_handle_t *sbh;
apr_status_t rv; apr_status_t rv;
apr_bucket_alloc_t *bucket_alloc;
my_child_num = child_num_arg; my_child_num = child_num_arg;
ap_my_pid = getpid(); ap_my_pid = getpid();
@@ -576,6 +577,8 @@ static void child_main(int child_num_arg)
for (i = 0; i < num_listensocks; i++) for (i = 0; i < num_listensocks; i++)
apr_poll_socket_add(pollset, listensocks[i].sd, APR_POLLIN); apr_poll_socket_add(pollset, listensocks[i].sd, APR_POLLIN);
bucket_alloc = apr_bucket_alloc_create(pchild);
while (!die_now) { while (!die_now) {
/* /*
* (Re)initialize this child to a pre-connection state. * (Re)initialize this child to a pre-connection state.
@@ -667,7 +670,7 @@ static void child_main(int child_num_arg)
* socket options, file descriptors, and read/write buffers. * socket options, file descriptors, and read/write buffers.
*/ */
current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh); current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd, my_child_num, sbh, bucket_alloc);
if (current_conn) { if (current_conn) {
ap_process_connection(current_conn, csd); ap_process_connection(current_conn, csd);
ap_lingering_close(current_conn); ap_lingering_close(current_conn);

View File

@@ -1052,6 +1052,7 @@ static void worker_main(long thread_num)
{ {
static int requests_this_child = 0; static int requests_this_child = 0;
PCOMP_CONTEXT context = NULL; PCOMP_CONTEXT context = NULL;
apr_bucket_alloc_t *bucket_alloc;
apr_os_sock_info_t sockinfo; apr_os_sock_info_t sockinfo;
ap_sb_handle_t *sbh; ap_sb_handle_t *sbh;
@@ -1075,6 +1076,9 @@ static void worker_main(long thread_num)
break; break;
} }
/* XXX: where does this go? */
bucket_alloc = apr_bucket_alloc_create(context->ptrans);
/* Have we hit MaxRequestPerChild connections? */ /* Have we hit MaxRequestPerChild connections? */
if (ap_max_requests_per_child) { if (ap_max_requests_per_child) {
requests_this_child++; requests_this_child++;
@@ -1092,8 +1096,9 @@ static void worker_main(long thread_num)
apr_os_sock_make(&context->sock, &sockinfo, context->ptrans); apr_os_sock_make(&context->sock, &sockinfo, context->ptrans);
ap_create_sb_handle(&sbh, context->ptrans, 0, thread_num); ap_create_sb_handle(&sbh, context->ptrans, 0, thread_num);
c = ap_run_create_connection(context->ptrans, ap_server_conf, context->sock, c = ap_run_create_connection(context->ptrans, ap_server_conf,
thread_num, sbh); context->sock, thread_num, sbh,
bucket_alloc);
if (c) { if (c) {
ap_process_connection(c, context->sock); ap_process_connection(c, context->sock);

View File

@@ -575,7 +575,7 @@ int ap_graceful_stop_signalled(void)
*/ */
static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num, static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
int my_thread_num) int my_thread_num, apr_bucket_alloc_t *bucket_alloc)
{ {
conn_rec *current_conn; conn_rec *current_conn;
long conn_id = ID_FROM_CHILD_THREAD(my_child_num, my_thread_num); long conn_id = ID_FROM_CHILD_THREAD(my_child_num, my_thread_num);
@@ -595,7 +595,8 @@ static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num,
return; return;
} }
current_conn = ap_run_create_connection(p, ap_server_conf, sock, conn_id, sbh); current_conn = ap_run_create_connection(p, ap_server_conf, sock,
conn_id, sbh, bucket_alloc);
if (current_conn) { if (current_conn) {
ap_process_connection(current_conn, sock); ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn); ap_lingering_close(current_conn);
@@ -834,6 +835,7 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
int process_slot = ti->pid; int process_slot = ti->pid;
int thread_slot = ti->tid; int thread_slot = ti->tid;
apr_socket_t *csd = NULL; apr_socket_t *csd = NULL;
apr_bucket_alloc_t *bucket_alloc;
apr_pool_t *last_ptrans = NULL; apr_pool_t *last_ptrans = NULL;
apr_pool_t *ptrans; /* Pool for per-transaction stuff */ apr_pool_t *ptrans; /* Pool for per-transaction stuff */
apr_status_t rv; apr_status_t rv;
@@ -841,6 +843,9 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
free(ti); free(ti);
ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL); ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL);
bucket_alloc = apr_bucket_alloc_create(apr_thread_pool_get(thd));
while (!workers_may_exit) { while (!workers_may_exit) {
ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_READY, NULL); ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_READY, NULL);
rv = ap_queue_pop(worker_queue, &csd, &ptrans, last_ptrans); rv = ap_queue_pop(worker_queue, &csd, &ptrans, last_ptrans);
@@ -870,7 +875,7 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
} }
continue; continue;
} }
process_socket(ptrans, csd, process_slot, thread_slot); process_socket(ptrans, csd, process_slot, thread_slot, bucket_alloc);
requests_this_child--; /* FIXME: should be synchronized - aaron */ requests_this_child--; /* FIXME: should be synchronized - aaron */
apr_pool_clear(ptrans); apr_pool_clear(ptrans);
last_ptrans = ptrans; last_ptrans = ptrans;
@@ -879,6 +884,8 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
ap_update_child_status_from_indexes(process_slot, thread_slot, ap_update_child_status_from_indexes(process_slot, thread_slot,
(dying) ? SERVER_DEAD : SERVER_GRACEFUL, (request_rec *) NULL); (dying) ? SERVER_DEAD : SERVER_GRACEFUL, (request_rec *) NULL);
apr_bucket_alloc_destroy(bucket_alloc);
apr_thread_exit(thd, APR_SUCCESS); apr_thread_exit(thd, APR_SUCCESS);
return NULL; return NULL;
} }

View File

@@ -217,7 +217,7 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
char *pos, *last_char = *s; char *pos, *last_char = *s;
int do_alloc = (*s == NULL), saw_eos = 0; int do_alloc = (*s == NULL), saw_eos = 0;
b = apr_brigade_create(r->pool); b = apr_brigade_create(r->pool, r->connection->bucket_alloc);
rv = ap_get_brigade(r->input_filters, b, AP_MODE_GETLINE, rv = ap_get_brigade(r->input_filters, b, AP_MODE_GETLINE,
APR_BLOCK_READ, 0); APR_BLOCK_READ, 0);
@@ -405,7 +405,7 @@ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
char c; char c;
/* Create a brigade for this filter read. */ /* Create a brigade for this filter read. */
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
/* We only care about the first byte. */ /* We only care about the first byte. */
rv = ap_get_brigade(r->input_filters, bb, AP_MODE_SPECULATIVE, rv = ap_get_brigade(r->input_filters, bb, AP_MODE_SPECULATIVE,
@@ -984,11 +984,12 @@ void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r)
static void end_output_stream(request_rec *r) static void end_output_stream(request_rec *r)
{ {
conn_rec *c = r->connection;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_eos_create(); b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb); ap_pass_brigade(r->output_filters, bb);
} }
@@ -1269,12 +1270,13 @@ AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r,
apr_off_t offset, apr_size_t len, apr_off_t offset, apr_size_t len,
apr_size_t *nbytes) apr_size_t *nbytes)
{ {
conn_rec *c = r->connection;
apr_bucket_brigade *bb = NULL; apr_bucket_brigade *bb = NULL;
apr_bucket *b; apr_bucket *b;
apr_status_t rv; apr_status_t rv;
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_file_create(fd, offset, len, r->pool); b = apr_bucket_file_create(fd, offset, len, r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(r->output_filters, bb); rv = ap_pass_brigade(r->output_filters, bb);
@@ -1293,11 +1295,12 @@ AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r,
AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
size_t length) size_t length)
{ {
conn_rec *c = r->connection;
apr_bucket_brigade *bb = NULL; apr_bucket_brigade *bb = NULL;
apr_bucket *b; apr_bucket *b;
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_mmap_create(mm, offset, length); b = apr_bucket_mmap_create(mm, offset, length, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb); ap_pass_brigade(r->output_filters, bb);
@@ -1332,6 +1335,7 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(
static apr_status_t buffer_output(request_rec *r, static apr_status_t buffer_output(request_rec *r,
const char *str, apr_size_t len) const char *str, apr_size_t len)
{ {
conn_rec *c = r->connection;
ap_filter_t *f; ap_filter_t *f;
old_write_filter_ctx *ctx; old_write_filter_ctx *ctx;
@@ -1359,8 +1363,8 @@ static apr_status_t buffer_output(request_rec *r,
* deliver the content through the normal filter chain * deliver the content through the normal filter chain
*/ */
if (f != r->output_filters) { if (f != r->output_filters) {
apr_bucket_brigade *bb = apr_brigade_create(r->pool); apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
apr_bucket *b = apr_bucket_transient_create(str, len); apr_bucket *b = apr_bucket_transient_create(str, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
return ap_pass_brigade(r->output_filters, bb); return ap_pass_brigade(r->output_filters, bb);
@@ -1370,7 +1374,7 @@ static apr_status_t buffer_output(request_rec *r,
ctx = r->output_filters->ctx; ctx = r->output_filters->ctx;
if (ctx->bb == NULL) { if (ctx->bb == NULL) {
ctx->bb = apr_brigade_create(r->pool); ctx->bb = apr_brigade_create(r->pool, c->bucket_alloc);
} }
return ap_fwrite(f->next, ctx->bb, str, len); return ap_fwrite(f->next, ctx->bb, str, len);
@@ -1525,11 +1529,12 @@ AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r, ...)
AP_DECLARE(int) ap_rflush(request_rec *r) AP_DECLARE(int) ap_rflush(request_rec *r)
{ {
conn_rec *c = r->connection;
apr_bucket_brigade *bb; apr_bucket_brigade *bb;
apr_bucket *b; apr_bucket *b;
bb = apr_brigade_create(r->pool); bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS) if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
return -1; return -1;

View File

@@ -547,7 +547,7 @@ AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f,
* create an empty bucket brigade so that we can concat. * create an empty bucket brigade so that we can concat.
*/ */
if (!(*saveto)) { if (!(*saveto)) {
*saveto = apr_brigade_create(p); *saveto = apr_brigade_create(p, f->c->bucket_alloc);
} }
APR_RING_FOREACH(e, &(*b)->list, apr_bucket, link) { APR_RING_FOREACH(e, &(*b)->list, apr_bucket, link) {
@@ -575,7 +575,7 @@ AP_DECLARE(apr_status_t) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb)
{ {
apr_bucket *b; apr_bucket *b;
b = apr_bucket_flush_create(); b = apr_bucket_flush_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b); APR_BRIGADE_INSERT_TAIL(bb, b);
return ap_pass_brigade(f, bb); return ap_pass_brigade(f, bb);
} }