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
<!--#echo--> and <!--#set--> directives [Brian Pane]
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:
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
scripts or generated-configs. (i.e. if sysconfdir is etc,
httpd-std.conf points to conf.)
bands, double free detection, etc. would be cool but certainly
not a hard requirement.
- Status: Cliff started to implement this using SMS as has
- been discussed at length for months, but since
- 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.
+ Status: The necessary API changes are in... apr_buckets_alloc.c
+ just needs to be fleshed out.
* Eliminate unnecessary creation of pipes in mod_cgid
* 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
* 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" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20020327
+#define MODULE_MAGIC_NUMBER_MAJOR 20020329
#endif
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */
#include "apr_hooks.h"
#include "apr_network_io.h"
+#include "apr_buckets.h"
#ifdef __cplusplus
extern "C" {
* @return An allocated connection record or NULL.
*/
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
* Create a bucket referring to an HTTP error.
* @param error The HTTP error code 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
- * @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,
- const char *buf, apr_pool_t *p);
+AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
+ 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_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b);
struct ap_filter_t *output_filters;
/** handle to scoreboard information for this connection */
void *sbh;
+ /** The bucket allocator to use for all bucket/brigade creations */
+ struct apr_bucket_alloc_t *bucket_alloc;
};
/* Per-vhost config... */
DWORD dwReserved)
{
request_rec *r = ((isapi_cid *)ConnID)->r;
+ conn_rec *c = r->connection;
apr_bucket_brigade *bb;
apr_bucket *b;
if (dwReserved == HSE_IO_SYNC)
; /* XXX: Fake it */
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_transient_create(Buffer, *lpdwBytes);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_transient_create(Buffer, *lpdwBytes, c->bucket_alloc);
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);
ap_pass_brigade(r->output_filters, bb);
{
isapi_cid *cid = (isapi_cid *)hConn;
request_rec *r = cid->r;
+ conn_rec *c = r->connection;
request_rec *subreq;
switch (dwHSERequest) {
else if ((apr_size_t)ate < headlen) {
apr_bucket_brigade *bb;
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,
- headlen - ate);
+ headlen - ate, c->bucket_alloc);
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);
ap_pass_brigade(cid->r->output_filters, bb);
}
}
/* 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 ((apr_size_t)ate < tf->HeadLength)
{
b = apr_bucket_transient_create((char*)tf->pHead + ate,
- tf->HeadLength - ate);
+ tf->HeadLength - ate,
+ c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
}
}
else if (tf->pHead && tf->HeadLength) {
b = apr_bucket_transient_create((char*)tf->pHead,
- tf->HeadLength);
+ tf->HeadLength,
+ c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
}
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);
if (tf->pTail && tf->TailLength) {
b = apr_bucket_transient_create((char*)tf->pTail,
- tf->TailLength);
+ tf->TailLength, c->bucket_alloc);
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);
ap_pass_brigade(r->output_filters, bb);
else if ((apr_size_t)ate < shi->cchHeader) {
apr_bucket_brigade *bb;
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,
- shi->cchHeader - ate);
+ shi->cchHeader - ate,
+ c->bucket_alloc);
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);
ap_pass_brigade(cid->r->output_filters, bb);
}
static int mmap_handler(request_rec *r, a_file *file)
{
#if APR_HAS_MMAP
+ conn_rec *c = r->connection;
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);
- b = apr_bucket_eos_create();
+ b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
static int sendfile_handler(request_rec *r, a_file *file)
{
#if APR_HAS_SENDFILE
+ conn_rec *c = r->connection;
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,
- (apr_size_t)file->finfo.size, r->pool);
+ b = apr_bucket_file_create(file->file, 0, (apr_size_t)file->finfo.size,
+ r->pool, c->bucket_alloc);
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);
if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
#include "apr.h"
#include "apr_file_io.h"
#include "apr_strings.h"
+#include "apr_buckets.h"
#if APR_HAVE_STDIO_H
#include <stdio.h> /* for sprintf() */
"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 */
bkt = apr_bucket_file_create(fd, 0,
(apr_size_t)resource->info->finfo.size,
- pool);
+ pool, output->c->bucket_alloc);
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);
if ((status = ap_pass_brigade(output, bb)) != APR_SUCCESS) {
return DECLINED;
}
- bb = apr_brigade_create(c->pool);
+ bb = apr_brigade_create(c->pool, c->bucket_alloc);
for ( ; ; ) {
/* Get a single line of input from 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);
ap_pass_brigade(c->output_filters, bb);
}
/* cache file exists */
if (cache->fresh) {
apr_bucket_brigade *out;
+ conn_rec *c = r->connection;
/* fresh data available */
if (lookup) {
ap_add_output_filter("CACHE_OUT", NULL, r, r->connection);
/* 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))) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
"cache: error returned while trying to return %s "
static apr_status_t CaseFilterOutFilter(ap_filter_t *f,
apr_bucket_brigade *pbbIn)
{
+ request_rec *r = f->r;
+ conn_rec *c = r->connection;
apr_bucket *pbktIn;
apr_bucket_brigade *pbbOut;
- /* XXX: is this the most appropriate pool? */
- pbbOut=apr_brigade_create(f->r->pool);
+ pbbOut=apr_brigade_create(r->pool, c->bucket_alloc);
APR_BRIGADE_FOREACH(pbktIn,pbbIn)
{
const char *data;
if(APR_BUCKET_IS_EOS(pbktIn))
{
- /* XXX: why can't I reuse pbktIn??? */
- apr_bucket *pbktEOS=apr_bucket_eos_create();
+ apr_bucket *pbktEOS=apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
continue;
}
apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
/* write */
- buf=malloc(len);
+ buf = apr_bucket_alloc(len, c->bucket_alloc);
for(n=0 ; n < len ; ++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_off_t nBytes)
{
request_rec *r = f->r;
+ conn_rec *c = r->connection;
CaseFilterInContext *pCtx;
apr_status_t ret;
if (!(pCtx = f->ctx)) {
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)) {
for(n=0 ; n < len ; ++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_bucket_delete(pbktIn);
}
* of it.
*/
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->dc = dc;
reqinfo->input_ctx = input_ctx;
*/
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 *b;
charset_filter_ctx_t *ctx = f->ctx;
apr_status_t rv;
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_transient_create(tmp, len);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_transient_create(tmp, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(f->next, bb);
if (rv != APR_SUCCESS) {
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 *b;
charset_filter_ctx_t *ctx = f->ctx;
apr_status_t rv;
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_eos_create();
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(f->next, bb);
if (rv != APR_SUCCESS) {
apr_bucket *e;
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
* an eos bucket already there, and the eos bucket should
* come after the data
}
/* We're cool with filtering this. */
- ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(*ctx));
- ctx->bb = apr_brigade_create(f->r->pool);
+ ctx = f->ctx = apr_pcalloc(r->pool, sizeof(*ctx));
+ ctx->bb = apr_brigade_create(r->pool, f->c->bucket_alloc);
/*
ctx->stream.zalloc = (alloc_func) 0;
ctx->stream.zfree = (free_func) 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,
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_table_setn(r->headers_out, "Content-Encoding", "gzip");
if (deflate_len != 0) {
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);
ctx->stream.next_out = ctx->buffer;
ctx->stream.avail_out = FILTER_BUFSIZE;
*p++ = len_array[2];
*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);
ap_log_rerror(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r,
"Zlib: Compressed %ld to %ld : URL %s",
ctx->stream.next_out = ctx->buffer;
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);
ctx->stream.avail_out = FILTER_BUFSIZE;
}
apr_bucket *e;
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);
- e = apr_bucket_eos_create();
+ e = apr_bucket_eos_create(bb->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
return APR_SUCCESS;
*/
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_dir_t *dc = ctx->dc;
apr_size_t len;
&len);
if ((rv && !APR_STATUS_IS_EAGAIN(rv)) ||
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,
!rv ? len : -1);
}
if (rv != APR_SUCCESS) {
return rv;
}
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_transient_create(buf, len);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_transient_create(buf, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
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()");
return rv;
}
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;
apr_bucket *b;
ef_dir_t *dc;
rv = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
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;
}
* that will cause the child to finish generating output
*/
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)");
return rv;
}
* 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,
- f->r->server->timeout * APR_USEC_PER_SEC);
+ r->server->timeout * APR_USEC_PER_SEC);
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)");
return rv;
}
&len);
if ((rv && !APR_STATUS_IS_EOF(rv) && !APR_STATUS_IS_EAGAIN(rv)) ||
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,
!rv ? len : -1);
}
}
if (rv == APR_SUCCESS) {
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_transient_create(buf, len);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_transient_create(buf, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
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");
return rv;
}
if (eos) {
/* pass down eos */
- bb = apr_brigade_create(f->r->pool);
- b = apr_bucket_eos_create();
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
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");
return rv;
}
/* CACHE_TYPE_FILE */
apr_file_t *file;
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 {
/* 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);
- b = apr_bucket_eos_create();
+ b = apr_bucket_eos_create(bb->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
return APR_SUCCESS;
}
}
if (!strcmp(tag, "var")) {
+ conn_rec *c = r->connection;
const char *val =
get_include_var(r, ctx,
ap_ssi_parse_string(r, ctx, tag_val, NULL,
e_len = strlen(echo_text);
tmp_buck = apr_bucket_pool_create(echo_text, e_len,
- r->pool);
+ r->pool, c->bucket_alloc);
}
else {
include_server_config *sconf=
&include_module);
tmp_buck = apr_bucket_pool_create(sconf->undefinedEcho,
sconf->undefinedEchoLen,
- r->pool);
+ r->pool, c->bucket_alloc);
}
APR_BUCKET_INSERT_BEFORE(head_ptr, tmp_buck);
if (*inserted_head == NULL) {
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);
if (*inserted_head == NULL) {
*inserted_head = tmp_buck;
t_val = ap_ht_time(r->pool, finfo.mtime, ctx->time_str, 0);
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);
if (*inserted_head == NULL) {
*inserted_head = tmp_buck;
if (cntx->flags & FLAG_COND_TRUE) { \
cond_txt[31] = '1'; \
} \
- memcpy(&cond_txt[5], tag_text, sizeof(tag_text)); \
- t_buck = apr_bucket_heap_create(cond_txt, sizeof(cond_txt), 1); \
+ memcpy(&cond_txt[5], tag_text, sizeof(tag_text)-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); \
\
if (ins_head == NULL) { \
#define DUMP_PARSE_EXPR_DEBUG(t_buck, h_ptr, d_buf, ins_head) \
{ \
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); \
\
if (ins_head == NULL) { \
if (1) {
apr_size_t d_len = 0;
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);
if (*inserted_head == NULL) {
if (1) {
apr_size_t d_len = 0;
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);
if (*inserted_head == NULL) {
*next++ = '\n';
*next = 0;
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);
if (*inserted_head == NULL) {
*inserted_head = tmp_buck;
apr_bucket *tmp_bkt;
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_cleanup(ctx->ssi_tag_brigade);
}
/* Send the large chunk of pre-tag bytes... */
tag_and_after = apr_brigade_split(*bb, tmp_dptr);
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);
if (ap_allow_options(r) & OPT_INCNOEXEC) {
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->error_str = conf->default_error_msg;
{ \
/* XXX: it'd probably be nice to use a pool bucket here */ \
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); \
\
if (ins_head == NULL) { \
\
tag_plus = apr_brigade_split((brgd), (cntxt)->head_start_bucket); \
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)); \
(cntxt)->bytes_parsed = 0; \
static int asis_handler(request_rec *r)
{
+ conn_rec *c = r->connection;
apr_file_t *f = NULL;
apr_status_t rv;
const char *location;
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 (r->finfo.size - pos > AP_MAX_SENDFILE) {
/* APR_HAS_LARGE_FILES issue; must split into mutiple buckets,
* in case the brigade code/filters attempt to read it directly.
*/
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) {
APR_BRIGADE_INSERT_TAIL(bb, b);
apr_bucket_copy(b, &b);
}
else
#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);
- b = apr_bucket_eos_create();
+ b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(r->output_filters, bb);
if (rv != APR_SUCCESS) {
/* Handle script return... */
if (script_in && !nph) {
+ conn_rec *c = r->connection;
const char *location;
char sbuf[MAX_STRING_LEN];
int ret;
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_pipe_create(script_in);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
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);
if ((ret = ap_scan_script_header_err_brigade(r, bb, sbuf))) {
}
if (script_in && nph) {
+ conn_rec *c = r->connection;
struct ap_filter_t *cur;
/* get rid of all filters up through protocol... since we
}
r->output_filters = r->proto_output_filters = cur;
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_pipe_create(script_in);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
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);
ap_pass_brigade(r->output_filters, bb);
}
if (ap_is_HTTP_REDIRECT(rr_status)) {
apr_size_t len_loc;
const char *location = apr_table_get(rr->headers_out, "Location");
+ conn_rec *c = r->connection;
location = ap_escape_html(rr->pool, location);
len_loc = strlen(location);
* and a single pool bucket */
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);
- 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);
- 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);
- 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);
- 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);
if (*inserted_head == NULL) {
return HTTP_INTERNAL_SERVER_ERROR;
}
- bcgi = apr_brigade_create(r->pool);
- b = apr_bucket_pipe_create(script_in);
+ bcgi = apr_brigade_create(r->pool, f->c->bucket_alloc);
+ b = apr_bucket_pipe_create(script_in, f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bcgi, b);
ap_pass_brigade(f->next, bcgi);
*/
static int cgid_handler(request_rec *r)
{
+ conn_rec *c = r->connection;
int retval, nph, dbpos = 0;
char *argv0, *dbuf = NULL;
apr_bucket_brigade *bb;
*/
apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket);
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_pipe_create(tempsock);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_pipe_create(tempsock, c->bucket_alloc);
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);
ap_pass_brigade(r->output_filters, bb);
}
}
r->output_filters = r->proto_output_filters = cur;
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_pipe_create(tempsock);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_pipe_create(tempsock, c->bucket_alloc);
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);
ap_pass_brigade(r->output_filters, bb);
}
if (ap_is_HTTP_REDIRECT(rr_status)) {
apr_size_t len_loc;
const char *location = apr_table_get(rr->headers_out, "Location");
+ conn_rec *c = r->connection;
location = ap_escape_html(rr->pool, location);
len_loc = strlen(location);
* and a single pool bucket */
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);
- 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);
- 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);
- 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);
- 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);
if (*inserted_head == NULL) {
*/
apr_pool_cleanup_kill(r->pool, (void *)sd, close_unix_socket);
- bcgi = apr_brigade_create(r->pool);
- b = apr_bucket_pipe_create(tempsock);
+ bcgi = apr_brigade_create(r->pool, r->connection->bucket_alloc);
+ b = apr_bucket_pipe_create(tempsock, r->connection->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bcgi, b);
ap_pass_brigade(f->next, bcgi);
}
{
#define ASCII_CRLF "\015\012"
#define ASCII_ZERO "\060"
+ conn_rec *c = f->r->connection;
apr_bucket_brigade *more;
apr_bucket *e;
apr_status_t rv;
hdr_len = apr_snprintf(chunk_hdr, sizeof(chunk_hdr),
"%qx" CRLF, (apr_uint64_t)bytes);
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);
/*
* Insert the end-of-chunk CRLF before an EOS or
* 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) {
APR_BUCKET_INSERT_BEFORE(eos, e);
}
*/
if (eos != NULL) {
/* 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);
}
}
if (!ctx->remaining) {
+ conn_rec *c = f->r->connection;
switch (ctx->state) {
case BODY_NONE:
break;
case BODY_LENGTH:
- e = apr_bucket_eos_create();
+ e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS;
case BODY_CHUNK:
if (!ctx->remaining) {
/* 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);
return APR_SUCCESS;
}
/* 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);
h.pool = r->pool;
h.bb = b;
{
int i;
request_rec *r = f->r;
+ conn_rec *c = r->connection;
const char *clheader;
const char *protocol;
apr_bucket *e;
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);
h.pool = r->pool;
}
if (r->expecting_100 && r->proto_num >= HTTP_VERSION(1,1)) {
+ conn_rec *c = r->connection;
char *tmp;
apr_bucket *e;
apr_bucket_brigade *bb;
/* sending 100 Continue interim response */
tmp = apr_pstrcat(r->pool, AP_SERVER_PROTOCOL, " ", status_lines[0],
CRLF CRLF, NULL);
- bb = apr_brigade_create(r->pool);
- e = apr_bucket_pool_create(tmp, strlen(tmp), r->pool);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ e = apr_bucket_pool_create(tmp, strlen(tmp), r->pool, c->bucket_alloc);
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);
ap_pass_brigade(r->connection->output_filters, bb);
{
#define MIN_LENGTH(len1, len2) ((len1 > len2) ? len2 : len1)
request_rec *r = f->r;
+ conn_rec *c = r->connection;
byterange_ctx *ctx = f->ctx;
apr_bucket *e;
apr_bucket_brigade *bsend;
if (num_ranges == -1) {
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,
- r->pool);
+ r->pool, c->bucket_alloc);
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);
return ap_pass_brigade(f->next, bsend);
}
}
/* 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
clength = (apr_off_t)bb_length;
/* 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, ','))
&& (rv = parse_byterange(current, clength, &range_start,
if (ctx->num_ranges > 1) {
char *ts;
- e = apr_bucket_pool_create(bound_head,
- strlen(bound_head), r->pool);
+ e = apr_bucket_pool_create(bound_head, strlen(bound_head),
+ r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e);
ts = apr_psprintf(r->pool, BYTERANGE_FMT CRLF CRLF,
range_start, range_end, clength);
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);
}
/* add the final boundary */
end = apr_pstrcat(r->pool, CRLF "--", r->boundary, "--" CRLF, NULL);
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);
}
- e = apr_bucket_eos_create();
+ e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bsend, e);
/* we're done with the original content */
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
### allow us to defer creation of the brigade to when we actually
### 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:
*
if (!r->connection->keepalive ||
ap_get_brigade(r->input_filters, bb, AP_MODE_EATCRLF,
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
* this point, we know that we have seen all of the data
if (best->body)
{
+ conn_rec *c = r->connection;
apr_bucket_brigade *bb;
apr_bucket *e;
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,
- (apr_size_t)best->bytes, r->pool);
+ (apr_size_t)best->bytes, r->pool,
+ c->bucket_alloc);
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);
return ap_pass_brigade(r->output_filters, bb);
apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f, apr_bucket_brigade *in)
{
request_rec *r = f->r;
+ conn_rec *c = r->connection;
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;
register int n;
if (!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->state = HEADER;
}
site, basedir, ap_escape_uri(p, path),
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; )
{
*dir = '/';
while (*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) {
- 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 */
str = apr_psprintf(p, "</h2>\n\n(%s)\n\n <hr />\n\n<pre>",
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 */
if (readme) {
str = apr_psprintf(p, "%s\n</pre>\n\n<hr />\n\n<pre>\n",
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 */
- 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))) {
return rv;
}
/* erase buffer for next time around */
ctx->buffer[0] = 0;
- APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p));
- APR_BRIGADE_INSERT_TAIL(out, apr_bucket_flush_create());
+ APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p,
+ 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))) {
return rv;
}
if (FOOTER == ctx->state) {
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_flush_create());
- APR_BRIGADE_INSERT_TAIL(out, apr_bucket_eos_create());
+ APR_BRIGADE_INSERT_TAIL(out, apr_bucket_pool_create(str, strlen(str), p,
+ c->bucket_alloc));
+ 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))) {
return rv;
}
/* If cmd == NULL, we retrieve the next ftp response line */
if (cmd != NULL) {
-
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_pool_create(cmd, strlen(cmd), r->pool));
- APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_flush_create());
+ conn_rec *c = r->connection;
+ 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(c->bucket_alloc));
ap_pass_brigade(ftp_ctrl->output_filters, bb);
/* strip off the CRLF for logging */
apr_status_t rv;
conn_rec *origin, *data = NULL;
int err;
- apr_bucket_brigade *bb = apr_brigade_create(p);
+ apr_bucket_brigade *bb = apr_brigade_create(p, c->bucket_alloc);
char *buf, *connectname;
apr_port_t connectport;
char buffer[MAX_STRING_LEN];
}
/* 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) {
/*
* the peer reset the connection already; ap_run_create_connection() closed
return ap_proxyerror(r, HTTP_BAD_GATEWAY, ftpmessage);
}
-
rc = proxy_ftp_command(apr_pstrcat(p, "USER ", user, CRLF, NULL),
r, origin, bb, &ftpmessage);
/* possible results; 230, 331, 332, 421, 500, 501, 530 */
}
/* 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) {
/*
* the peer reset the connection already; ap_run_create_connection() closed
/* if no EOS yet, then we must flush */
if (FALSE == finish) {
- e = apr_bucket_flush_create();
+ e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
}
/* the socket is now open, create a new backend server connection */
*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) {
/* the peer reset the connection already; ap_run_create_connection()
* closed the socket
apr_uri_t *uri,
char *url, apr_bucket_brigade *bb,
char *server_portstr) {
+ conn_rec *c = r->connection;
char buffer[HUGE_STRING_LEN];
char *buf;
apr_bucket *e;
}
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);
if ( conf->preserve_host == 0 ) {
if (uri->port_str && uri->port != DEFAULT_HTTP_PORT) {
}
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);
/* handle Via */
buf = apr_pstrcat(p, headers_in[counter].key, ": ",
headers_in[counter].val, 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);
}
/* 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);
- e = apr_bucket_flush_create();
+ e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(origin->output_filters, bb);
/* send the request data, if any. */
if (ap_should_client_block(r)) {
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);
- e = apr_bucket_flush_create();
+ e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
ap_pass_brigade(origin->output_filters, bb);
apr_brigade_cleanup(bb);
proxy_server_conf *conf,
apr_bucket_brigade *bb,
char *server_portstr) {
+ conn_rec *c = r->connection;
char buffer[HUGE_STRING_LEN];
request_rec *rp;
apr_bucket *e;
/* Is it an HTTP/0.9 response? If so, send the extra data */
if (backasswards) {
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);
}
/* if no EOS yet, then we must flush */
if (FALSE == finish) {
- e = apr_bucket_flush_create();
+ e = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
}
*/
apr_pool_t *p = r->connection->pool;
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));
proxy_http_conn_t *p_conn = apr_pcalloc(r->connection->pool,
sizeof(*p_conn));
b->frec = frec;
b->c = c;
- b->bb = apr_brigade_create(c->pool);
+ b->bb = apr_brigade_create(c->pool, c->bucket_alloc);
b->blen = 0;
b->length = 0;
static int BIO_bucket_flush(BIO *bio)
{
BIO_bucket_t *b = BIO_bucket_ptr(bio);
+ apr_bucket *e;
if (!(b->blen || b->length)) {
return APR_SUCCESS;
}
if (b->blen) {
- apr_bucket *bucket =
- apr_bucket_transient_create(b->buffer,
- b->blen);
+ e = apr_bucket_transient_create(b->buffer, b->blen,
+ b->bb->bucket_alloc);
/* we filled this buffer first so add it to the
* head of the brigade
*/
- APR_BRIGADE_INSERT_HEAD(b->bb, bucket);
+ APR_BRIGADE_INSERT_HEAD(b->bb, e);
b->blen = 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);
}
* need to flush since we're using SSL's malloc-ed buffer
* 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;
APR_BRIGADE_INSERT_TAIL(b->bb, bucket);
#define HTTP_ON_HTTPS_PORT \
"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, \
- 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,
apr_bucket_brigade *bb,
"trying to send HTML error page");
/* fake the request line */
- bucket = HTTP_ON_HTTPS_PORT_BUCKET();
+ bucket = HTTP_ON_HTTPS_PORT_BUCKET(f->c->bucket_alloc);
break;
default:
if (len > 0) {
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);
}
ctx->inbio.ssl = ssl;
ctx->inbio.wbio = frec->pbioWrite;
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.cbuf.length = 0;
/* We're cool with filtering this. */
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");
}
p = apr_bucket_pool_create(apr_pmemdup( f->r->pool,
&data[lastpos],
i-lastpos),
- i-lastpos,
- f->r->pool);
+ i-lastpos, f->r->pool,
+ f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(ctx->bb,p);
}
lastpos=i+1;
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);
}
if ( data[i] == c->flushdelimiter || data[i] == c->passdelimiter ) {
/* XXX: really should append this to the next 'real' bucket */
if ( lastpos < i ) {
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;
APR_BRIGADE_INSERT_TAIL(ctx->bb,p);
}
APR_HOOK_LINK(pre_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),
- (p, server, csd, conn_id, sbh), NULL)
+ (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, alloc), NULL)
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)
/*
apr_bucket_brigade *bb;
apr_bucket *b;
- bb = apr_brigade_create(c->pool);
- b = apr_bucket_flush_create();
+ bb = apr_brigade_create(c->pool, c->bucket_alloc);
+ b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(c->output_filters, bb);
}
static int default_handler(request_rec *r)
{
+ conn_rec *c = r->connection;
apr_bucket_brigade *bb;
apr_bucket *e;
core_dir_config *d;
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 (r->finfo.size > AP_MAX_SENDFILE) {
/* APR_HAS_LARGE_FILES issue; must split into mutiple buckets,
* in case the brigade code/filters attempt to read it directly.
*/
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) {
apr_bucket *ce;
apr_bucket_copy(e, &ce);
}
else
#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);
- e = apr_bucket_eos_create();
+ e = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, e);
return ap_pass_brigade(r->output_filters, bb);
if (!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. */
- 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);
net->in_ctx = ctx;
}
* so tack on an EOS too. */
/* We have read until the brigade was empty, so we know that we
* must be EOS. */
- e = apr_bucket_eos_create();
+ e = apr_bucket_eos_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS;
}
apr_bucket_delete(e);
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);
}
return APR_SUCCESS;
b = bb;
}
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);
* after the request_pool is cleared.
*/
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) {
req_cfg->bb = main_req_cfg->bb;
}
else {
- req_cfg->bb = apr_brigade_create(r->pool);
+ req_cfg->bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
if (!r->prev) {
ap_add_input_filter_handle(ap_net_time_filter_handle,
NULL, r, r->connection);
}
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;
conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
c->base_server = server;
c->id = id;
+ c->bucket_alloc = alloc;
+
return c;
}
#include "http_protocol.h"
#include "apr_buckets.h"
#include "apr_strings.h"
-#include <stdlib.h>
#if APR_HAVE_STRINGS_H
#include <strings.h>
#endif
{
ap_bucket_error *h;
- h = malloc(sizeof(*h));
- if (h == NULL) {
- return NULL;
- }
+ h = apr_bucket_alloc(sizeof(*h), b->list);
h->status = error;
h->data = (buf) ? apr_pstrdup(p, buf) : NULL;
return b;
}
-AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error,
- const char *buf, apr_pool_t *p)
+AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf,
+ 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);
- b->free = free;
+ b->free = apr_bucket_free;
+ b->list = list;
return ap_bucket_error_make(b, error, buf, p);
}
AP_DECLARE_DATA const apr_bucket_type_t ap_bucket_type_error = {
"ERROR", 5,
- free,
+ apr_bucket_free,
error_read,
apr_bucket_setaside_notimpl,
apr_bucket_split_notimpl,
* 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;
long conn_id = my_child_num;
apr_allocator_t *allocator;
apr_socket_t *csd = NULL;
apr_pool_t *ptrans; /* Pool for per-transaction stuff */
+ apr_bucket_alloc_t *bucket_alloc;
apr_socket_t *sd = NULL;
apr_status_t rv = APR_EINIT;
int srv , n;
for(n=0 ; n <= num_listening_sockets ; n++)
apr_poll_socket_add(pollset, listening_sockets[n], APR_POLLIN);
+ bucket_alloc = apr_bucket_alloc_create(tpool);
+
while (1) {
/* 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
ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
"apr_accept");
} else {
- process_socket(ptrans, csd, child_slot);
+ process_socket(ptrans, csd, child_slot, bucket_alloc);
requests_this_child--;
}
}
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,
"worker_thread %ld exiting", find_thread(NULL));
struct cmsghdr *cmsg;
int sfd;
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 *)
ap_get_module_config(r->server->module_config,
&mpm_perchild_module);
char *foo;
apr_size_t len;
- apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER",
- r->connection->pool);
+ apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", c->pool);
len = strlen(foo);
apr_pool_userdata_set(NULL, "PERCHILD_BUFFER", apr_pool_cleanup_null,
- r->connection->pool);
+ c->pool);
apr_os_sock_get(&sfd, thesock);
long conn_id;
conn_rec *current_conn;
apr_pool_t *pconn;
+ apr_bucket_alloc_t *bucket_alloc;
worker_args_t *worker_args;
HQUEUE workq;
PID owner;
while (rc = DosReadQueue(workq, &rd, &len, (PPVOID)&worker_args, 0, DCWW_WAIT, &priority, NULLHANDLE),
rc == 0 && rd.ulData != WORKTYPE_EXIT) {
pconn = worker_args->pconn;
+ bucket_alloc = apr_bucket_alloc_create(pconn);
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) {
ap_process_connection(current_conn, worker_args->conn_sd);
ap_lingering_close(current_conn);
}
+ apr_bucket_alloc_destroy(bucket_alloc);
apr_pool_destroy(pconn);
ap_update_child_status_from_indexes(child_slot, thread_slot,
SERVER_READY, NULL);
ap_listen_rec *last_lr = NULL;
apr_pool_t *ptrans;
apr_allocator_t *allocator;
+ apr_bucket_alloc_t *bucket_alloc;
conn_rec *current_conn;
apr_status_t stat = APR_EINIT;
int worker_num_arg = (int)arg;
apr_pool_create_ex(&ptrans, NULL, NULL, allocator);
apr_allocator_set_owner(allocator, ptrans);
+ bucket_alloc = apr_bucket_alloc_create(ptrans);
+
apr_pool_tag(ptrans, "transaction");
apr_thread_mutex_lock(worker_thread_count_mutex);
* socket options, file descriptors, and read/write buffers.
*/
current_conn = ap_run_create_connection(ptrans, ap_server_conf, csd,
- my_worker_num, sbh);
+ my_worker_num, sbh,
+ bucket_alloc);
if (current_conn) {
ap_process_connection(current_conn, csd);
ap_lingering_close(current_conn);
struct cmsghdr *cmsg;
int sfd;
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 *)
ap_get_module_config(r->server->module_config,
&mpm_perchild_module);
char *foo;
apr_size_t len;
- apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER",
- r->connection->pool);
+ apr_pool_userdata_get((void **)&foo, "PERCHILD_BUFFER", c->pool);
len = strlen(foo);
apr_pool_userdata_set(NULL, "PERCHILD_BUFFER", apr_pool_cleanup_null,
- r->connection->pool);
+ c->pool);
apr_os_sock_get(&sfd, thesock);
void *csd;
ap_sb_handle_t *sbh;
apr_status_t rv;
+ apr_bucket_alloc_t *bucket_alloc;
my_child_num = child_num_arg;
ap_my_pid = getpid();
for (i = 0; i < num_listensocks; i++)
apr_poll_socket_add(pollset, listensocks[i].sd, APR_POLLIN);
+ bucket_alloc = apr_bucket_alloc_create(pchild);
+
while (!die_now) {
/*
* (Re)initialize this child to a pre-connection state.
* 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) {
ap_process_connection(current_conn, csd);
ap_lingering_close(current_conn);
{
static int requests_this_child = 0;
PCOMP_CONTEXT context = NULL;
+ apr_bucket_alloc_t *bucket_alloc;
apr_os_sock_info_t sockinfo;
ap_sb_handle_t *sbh;
break;
}
+ /* XXX: where does this go? */
+ bucket_alloc = apr_bucket_alloc_create(context->ptrans);
+
/* Have we hit MaxRequestPerChild connections? */
if (ap_max_requests_per_child) {
requests_this_child++;
apr_os_sock_make(&context->sock, &sockinfo, context->ptrans);
ap_create_sb_handle(&sbh, context->ptrans, 0, thread_num);
- c = ap_run_create_connection(context->ptrans, ap_server_conf, context->sock,
- thread_num, sbh);
+ c = ap_run_create_connection(context->ptrans, ap_server_conf,
+ context->sock, thread_num, sbh,
+ bucket_alloc);
if (c) {
ap_process_connection(c, context->sock);
*/
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;
long conn_id = ID_FROM_CHILD_THREAD(my_child_num, my_thread_num);
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) {
ap_process_connection(current_conn, sock);
ap_lingering_close(current_conn);
int process_slot = ti->pid;
int thread_slot = ti->tid;
apr_socket_t *csd = NULL;
+ apr_bucket_alloc_t *bucket_alloc;
apr_pool_t *last_ptrans = NULL;
apr_pool_t *ptrans; /* Pool for per-transaction stuff */
apr_status_t rv;
free(ti);
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) {
ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_READY, NULL);
rv = ap_queue_pop(worker_queue, &csd, &ptrans, last_ptrans);
}
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 */
apr_pool_clear(ptrans);
last_ptrans = ptrans;
ap_update_child_status_from_indexes(process_slot, thread_slot,
(dying) ? SERVER_DEAD : SERVER_GRACEFUL, (request_rec *) NULL);
+ apr_bucket_alloc_destroy(bucket_alloc);
+
apr_thread_exit(thd, APR_SUCCESS);
return NULL;
}
char *pos, *last_char = *s;
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,
APR_BLOCK_READ, 0);
char c;
/* 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. */
rv = ap_get_brigade(r->input_filters, bb, AP_MODE_SPECULATIVE,
static void end_output_stream(request_rec *r)
{
+ conn_rec *c = r->connection;
apr_bucket_brigade *bb;
apr_bucket *b;
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_eos_create();
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb);
}
apr_off_t offset, apr_size_t len,
apr_size_t *nbytes)
{
+ conn_rec *c = r->connection;
apr_bucket_brigade *bb = NULL;
apr_bucket *b;
apr_status_t rv;
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_file_create(fd, offset, len, r->pool);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_file_create(fd, offset, len, r->pool, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(r->output_filters, bb);
AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
size_t length)
{
+ conn_rec *c = r->connection;
apr_bucket_brigade *bb = NULL;
apr_bucket *b;
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_mmap_create(mm, offset, length);
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_mmap_create(mm, offset, length, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
ap_pass_brigade(r->output_filters, bb);
static apr_status_t buffer_output(request_rec *r,
const char *str, apr_size_t len)
{
+ conn_rec *c = r->connection;
ap_filter_t *f;
old_write_filter_ctx *ctx;
* deliver the content through the normal filter chain
*/
if (f != r->output_filters) {
- apr_bucket_brigade *bb = apr_brigade_create(r->pool);
- apr_bucket *b = apr_bucket_transient_create(str, len);
+ apr_bucket_brigade *bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ apr_bucket *b = apr_bucket_transient_create(str, len, c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
return ap_pass_brigade(r->output_filters, bb);
ctx = r->output_filters->ctx;
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);
AP_DECLARE(int) ap_rflush(request_rec *r)
{
+ conn_rec *c = r->connection;
apr_bucket_brigade *bb;
apr_bucket *b;
- bb = apr_brigade_create(r->pool);
- b = apr_bucket_flush_create();
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_flush_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS)
return -1;
* create an empty bucket brigade so that we can concat.
*/
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_bucket *b;
- b = apr_bucket_flush_create();
+ b = apr_bucket_flush_create(f->c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
return ap_pass_brigade(f, bb);
}