diff options
author | Ryan Bloom <rbb@apache.org> | 2000-07-12 22:00:08 +0000 |
---|---|---|
committer | Ryan Bloom <rbb@apache.org> | 2000-07-12 22:00:08 +0000 |
commit | a234aae48fcbb13ffdfe3e139cb13895f4237353 (patch) | |
tree | 542b0c4a7405485cde396e74e52e59dc90aa268f /buckets | |
parent | c5e6ad03bfd3702e571f4efc8de49e07ad3f13fa (diff) | |
download | apr-a234aae48fcbb13ffdfe3e139cb13895f4237353.tar.gz |
Add an End-Of-Stream bucket type. This also makes a couple of relatively
minor bug fixes in the buckets code. The bug fixes where found because
of the EOS bucket, so I am including them in this patch.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60338 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'buckets')
-rw-r--r-- | buckets/ap_buf.c | 16 | ||||
-rw-r--r-- | buckets/apr_buf.h | 5 |
2 files changed, 18 insertions, 3 deletions
diff --git a/buckets/ap_buf.c b/buckets/ap_buf.c index 7bf19a109..dbb68002d 100644 --- a/buckets/ap_buf.c +++ b/buckets/ap_buf.c @@ -84,6 +84,9 @@ APR_EXPORT(ap_bucket *) ap_bucket_new(ap_bucket_color_e color) newbuf->data = ap_rmem_create(); newbuf->free = NULL; break; + case AP_BUCKET_eos: + newbuf->data = NULL; + newbuf->free = NULL; case AP_BUCKET_file: case AP_BUCKET_filename: case AP_BUCKET_cached_entity: @@ -96,7 +99,7 @@ APR_EXPORT(ap_bucket *) ap_bucket_new(ap_bucket_color_e color) APR_EXPORT(ap_status_t) ap_bucket_destroy(ap_bucket *e) { - if (e->free) { + if (e->free != NULL) { e->free(e); } free(e); @@ -174,6 +177,7 @@ APR_EXPORT(void) ap_bucket_brigade_catenate(ap_bucket_brigade *a, if (a->tail) { a->tail->next = b->head; } + b->head->prev = a->tail; a->tail = b->tail; if (!a->head) { a->head = b->head; @@ -196,6 +200,9 @@ APR_EXPORT(ap_status_t) ap_bucket_brigade_to_iol(ap_ssize_t *total_bytes, do { iov_used = ap_bucket_brigade_to_iovec(b, vec, 16); status = iol_writev(iol, vec, iov_used, &bytes); + + ap_consume_buckets(b, 16); + if (status != APR_SUCCESS) { return status; } @@ -224,6 +231,8 @@ APR_EXPORT(const char *) ap_get_bucket_char_str(ap_bucket *b) return ap_mmap_get_char_str(b->data); case AP_BUCKET_rmem: return ap_rmem_get_char_str(b->data); + case AP_BUCKET_eos: + return NULL; case AP_BUCKET_file: case AP_BUCKET_filename: case AP_BUCKET_cached_entity: @@ -244,6 +253,8 @@ APR_EXPORT(int) ap_get_bucket_len(ap_bucket *b) return ap_mmap_get_len(b->data); case AP_BUCKET_rmem: return ap_rmem_get_len(b->data); + case AP_BUCKET_eos: + return 0; case AP_BUCKET_file: case AP_BUCKET_filename: case AP_BUCKET_cached_entity: @@ -297,7 +308,7 @@ APR_EXPORT(int) ap_brigade_vputstrs(ap_bucket_brigade *b, va_list va) } else { b->tail->next = ap_bucket_list_create(); - b->tail->next->prev = b->tail->next; + b->tail->next->prev = b->tail; b->tail = b->tail->next; b->tail->bucket = r; } @@ -305,3 +316,4 @@ APR_EXPORT(int) ap_brigade_vputstrs(ap_bucket_brigade *b, va_list va) return k; } + diff --git a/buckets/apr_buf.h b/buckets/apr_buf.h index cf009f9b0..1f8051c98 100644 --- a/buckets/apr_buf.h +++ b/buckets/apr_buf.h @@ -73,7 +73,10 @@ typedef enum { AP_BUCKET_mmap, AP_BUCKET_filename, AP_BUCKET_cached_entity, - AP_BUCKET_URI + AP_BUCKET_URI, + AP_BUCKET_eos /* End-of-stream bucket. Special case to say this is + * the end of the bucket so all data should be sent + * immediately. */ } ap_bucket_color_e; typedef struct ap_bucket ap_bucket; |