brianp 2002/12/17 11:16:40
Modified: . CHANGES
buckets apr_brigade.c
Log:
Allocate brigades from a bucket_allocator rather than a pool.
There are two reasons for this:
1. Make the implementation of apr_brigade_create() match the
documentation in apr_buckets.h, which says that we don't
allocate from the pool.
2. Allow brigades to be used in situations where it may be
infeasible to tie a brigade's lifetime to that of a
pool--e.g., an async web server.
Revision Changes Path
1.88 +3 -0 apr-util/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr-util/CHANGES,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- CHANGES 30 Nov 2002 16:33:11 -0000 1.87
+++ CHANGES 17 Dec 2002 19:16:39 -0000 1.88
@@ -1,4 +1,7 @@
Changes with APR-util 0.9.2
+
+ *) Allocate brigades from a bucket allocator rather than a pool. [Brian
Pane]
+
*) Update with the latest APR renames [Thom May]
*) Update doxygen tags. [Justin Erenkrantz]
1.55 +12 -7 apr-util/buckets/apr_brigade.c
Index: apr_brigade.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- apr_brigade.c 30 Sep 2002 01:57:55 -0000 1.54
+++ apr_brigade.c 17 Dec 2002 19:16:39 -0000 1.55
@@ -85,16 +85,18 @@
e = APR_BRIGADE_FIRST(b);
apr_bucket_delete(e);
}
- /*
- * We don't need to free(bb) because it's allocated from a pool.
- */
return APR_SUCCESS;
}
APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b)
{
- apr_pool_cleanup_kill(b->p, b, brigade_cleanup);
- return apr_brigade_cleanup(b);
+ apr_status_t rv;
+ if (b->p) {
+ apr_pool_cleanup_kill(b->p, b, brigade_cleanup);
+ }
+ rv = apr_brigade_cleanup(b);
+ apr_bucket_free(b);
+ return rv;
}
APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p,
@@ -102,13 +104,16 @@
{
apr_bucket_brigade *b;
- b = apr_palloc(p, sizeof(*b));
+ b = apr_bucket_alloc(sizeof(*b), list);
b->p = p;
b->bucket_alloc = list;
APR_RING_INIT(&b->list, apr_bucket, link);
- apr_pool_cleanup_register(b->p, b, brigade_cleanup,
apr_pool_cleanup_null);
+ if (p) {
+ apr_pool_cleanup_register(b->p, b, brigade_cleanup,
+ apr_pool_cleanup_null);
+ }
return b;
}