diff options
author | peter <peter@FreeBSD.org> | 2013-07-28 06:02:40 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2013-07-28 06:02:40 +0000 |
commit | 0aadc82afbae4dbc41da86cd4f9b2ceb8ddcb17d (patch) | |
tree | 6a96e078c28ea05d418b4e2722bc03b0b930a78b /contrib/apr-util/buckets | |
parent | 7594fa5c70305cda65deedc5cc7e08dc037727cd (diff) | |
parent | b910f82d487cf989800adbd1a65b3a7f71b46277 (diff) | |
download | FreeBSD-src-0aadc82afbae4dbc41da86cd4f9b2ceb8ddcb17d.zip FreeBSD-src-0aadc82afbae4dbc41da86cd4f9b2ceb8ddcb17d.tar.gz |
Update subversion-1.8.0 -> 1.8.1. Update supporting
components: apr-1.4.6 -> 1.4.8 and apr-util-1.4.1 -> 1.5.2.
This is a post point-zero bug-fix / fix-sharp-edges release, including
some workarounds for UTF-8 for people who haven't yet turned on WITH_ICONV.
Diffstat (limited to 'contrib/apr-util/buckets')
-rw-r--r-- | contrib/apr-util/buckets/apr_brigade.c | 57 | ||||
-rw-r--r-- | contrib/apr-util/buckets/apr_buckets_alloc.c | 11 |
2 files changed, 37 insertions, 31 deletions
diff --git a/contrib/apr-util/buckets/apr_brigade.c b/contrib/apr-util/buckets/apr_brigade.c index 3fd7e46..1f2ba17 100644 --- a/contrib/apr-util/buckets/apr_brigade.c +++ b/contrib/apr-util/buckets/apr_brigade.c @@ -391,17 +391,30 @@ APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b, void *ctx, va_list va) { +#define MAX_VECS 8 + struct iovec vec[MAX_VECS]; + apr_size_t i = 0; + for (;;) { - const char *str = va_arg(va, const char *); + char *str = va_arg(va, char *); apr_status_t rv; if (str == NULL) break; - rv = apr_brigade_write(b, flush, ctx, str, strlen(str)); - if (rv != APR_SUCCESS) - return rv; + vec[i].iov_base = str; + vec[i].iov_len = strlen(str); + i++; + + if (i == MAX_VECS) { + rv = apr_brigade_writev(b, flush, ctx, vec, i); + if (rv != APR_SUCCESS) + return rv; + i = 0; + } } + if (i != 0) + return apr_brigade_writev(b, flush, ctx, vec, i); return APR_SUCCESS; } @@ -422,7 +435,12 @@ APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b, apr_size_t remaining = APR_BUCKET_BUFF_SIZE; char *buf = NULL; - if (!APR_BRIGADE_EMPTY(b) && APR_BUCKET_IS_HEAP(e)) { + /* + * If the last bucket is a heap bucket and its buffer is not shared with + * another bucket, we may write into that bucket. + */ + if (!APR_BRIGADE_EMPTY(b) && APR_BUCKET_IS_HEAP(e) + && ((apr_bucket_heap *)(e->data))->refcount.refcount == 1) { apr_bucket_heap *h = e->data; /* HEAP bucket start offsets are always in-memory, safe to cast */ @@ -512,10 +530,11 @@ APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b, i = 0; /* If there is a heap bucket at the end of the brigade - * already, copy into the existing bucket. + * already, and its refcount is 1, copy into the existing bucket. */ e = APR_BRIGADE_LAST(b); - if (!APR_BRIGADE_EMPTY(b) && APR_BUCKET_IS_HEAP(e)) { + if (!APR_BRIGADE_EMPTY(b) && APR_BUCKET_IS_HEAP(e) + && ((apr_bucket_heap *)(e->data))->refcount.refcount == 1) { apr_bucket_heap *h = e->data; apr_size_t remaining = h->alloc_len - (e->length + (apr_size_t)e->start); @@ -591,29 +610,7 @@ APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb, apr_brigade_flush flush, void *ctx, const char *str) { - apr_size_t len = strlen(str); - apr_bucket *bkt = APR_BRIGADE_LAST(bb); - if (!APR_BRIGADE_EMPTY(bb) && APR_BUCKET_IS_HEAP(bkt)) { - /* If there is enough space available in a heap bucket - * at the end of the brigade, copy the string directly - * into the heap bucket - */ - apr_bucket_heap *h = bkt->data; - apr_size_t bytes_avail = h->alloc_len - bkt->length; - - if (bytes_avail >= len) { - char *buf = h->base + bkt->start + bkt->length; - memcpy(buf, str, len); - bkt->length += len; - return APR_SUCCESS; - } - } - - /* If the string could not be copied into an existing heap - * bucket, delegate the work to apr_brigade_write(), which - * knows how to grow the brigade - */ - return apr_brigade_write(bb, flush, ctx, str, len); + return apr_brigade_write(bb, flush, ctx, str, strlen(str)); } APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b, diff --git a/contrib/apr-util/buckets/apr_buckets_alloc.c b/contrib/apr-util/buckets/apr_buckets_alloc.c index 60f42de..15baa33 100644 --- a/contrib/apr-util/buckets/apr_buckets_alloc.c +++ b/contrib/apr-util/buckets/apr_buckets_alloc.c @@ -65,12 +65,20 @@ APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p) /* may be NULL for debug mode. */ if (allocator == NULL) { if (apr_allocator_create(&allocator) != APR_SUCCESS) { + apr_abortfunc_t fn = apr_pool_abort_get(p); + if (fn) + (fn)(APR_ENOMEM); abort(); } } #endif - list = apr_bucket_alloc_create_ex(allocator); + if (list == NULL) { + apr_abortfunc_t fn = apr_pool_abort_get(p); + if (fn) + (fn)(APR_ENOMEM); + abort(); + } list->pool = p; apr_pool_cleanup_register(list->pool, list, alloc_cleanup, apr_pool_cleanup_null); @@ -131,6 +139,7 @@ APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, if (endp >= active->endp) { list->blocks = apr_allocator_alloc(list->allocator, ALLOC_AMT); if (!list->blocks) { + list->blocks = active; return NULL; } list->blocks->next = active; |