wrowe 01/07/24 13:36:03
Modified: . CHANGES
buckets apr_brigade.c apr_buckets.c apr_buckets_file.c
apr_buckets_pipe.c apr_buckets_refcount.c
apr_buckets_simple.c apr_buckets_socket.c
include apr_buckets.h
Log:
Consistently use apr_size_t for the bucket size, and apr_off_t to manipulate
brigades (which may consist of several buckets near MAX(apr_size_t) length.)
Revision Changes Path
1.23 +4 -0 apr-util/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr-util/CHANGES,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- CHANGES 2001/06/27 20:14:58 1.22
+++ CHANGES 2001/07/24 20:36:03 1.23
@@ -1,5 +1,9 @@
Changes with APR-util b1
+ *) The apr_bucket lengths are now consistently apr_size_t, while any
+ apr_brigade lengths (short of a read) are consistently apr_off_t.
+ This is required for APR_HAS_LARGE_FILES handling. [William Rowe]
+
*) apr_bucket_file_create() and apr_bucket_file_make() now take a pool
parameter which is the pool into which any needed data structures
should be created during file_read(). This is used for MMAPing the
1.19 +20 -9 apr-util/buckets/apr_brigade.c
Index: apr_brigade.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- apr_brigade.c 2001/06/20 01:17:28 1.18
+++ apr_brigade.c 2001/07/24 20:36:03 1.19
@@ -146,17 +146,28 @@
}
APR_BRIGADE_FOREACH(e, b) {
- if ((point < e->length) || (e->length == -1)) {
- /* try to split the bucket natively */
- if ((rv = apr_bucket_split(e, point)) != APR_ENOTIMPL) {
+ if ((point > (apr_size_t)(-1)) && (e->length == (apr_size_t)(-1))) {
+ /* XXX: point is too far out to simply split this bucket,
+ * we must fix this bucket's size and keep going... */
+ if ((rv = apr_bucket_read(e, &s, &len, APR_BLOCK_READ))
+ != APR_SUCCESS) {
+ return rv;
+ }
+ }
+ if ((point < e->length) || (e->length == (apr_size_t)(-1))) {
+ /* We already checked e->length -1 above, so we now
+ * trust e->length < MAX_APR_SIZE_T.
+ * First try to split the bucket natively... */
+ if ((rv = apr_bucket_split(e, (apr_size_t)point))
+ != APR_ENOTIMPL) {
*after_point = APR_BUCKET_NEXT(e);
return rv;
}
/* if the bucket cannot be split, we must read from it,
* changing its type to one that can be split */
- if ((rv = apr_bucket_read(e, &s, &len,
- APR_BLOCK_READ)) != APR_SUCCESS) {
+ if ((rv = apr_bucket_read(e, &s, &len, APR_BLOCK_READ))
+ != APR_SUCCESS) {
return rv;
}
@@ -164,7 +175,7 @@
* might have been morphed by the apr_bucket_read() above, but
* if it was, the length would have been adjusted appropriately
*/
if (point < e->length) {
- rv = apr_bucket_split(e, point);
+ rv = apr_bucket_split(e, (apr_size_t)point);
*after_point = APR_BUCKET_NEXT(e);
return rv;
}
@@ -179,13 +190,13 @@
}
APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
- int read_all, apr_ssize_t
*length)
+ int read_all, apr_off_t *length)
{
- apr_ssize_t total = 0;
+ apr_off_t total = 0;
apr_bucket *bkt;
APR_BRIGADE_FOREACH(bkt, bb) {
- if (bkt->length == -1) {
+ if (bkt->length == (apr_size_t)(-1)) {
const char *ignore;
apr_size_t len;
apr_status_t status;
1.52 +1 -1 apr-util/buckets/apr_buckets.c
Index: apr_buckets.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- apr_buckets.c 2001/06/13 19:16:05 1.51
+++ apr_buckets.c 2001/07/24 20:36:03 1.52
@@ -67,7 +67,7 @@
}
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data,
- apr_off_t point)
+ apr_size_t point)
{
return APR_ENOTIMPL;
}
1.51 +3 -3 apr-util/buckets/apr_buckets_file.c
Index: apr_buckets_file.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_file.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- apr_buckets_file.c 2001/07/19 12:35:44 1.50
+++ apr_buckets_file.c 2001/07/24 20:36:03 1.51
@@ -93,7 +93,7 @@
}
#if APR_HAS_MMAP
-static int file_make_mmap(apr_bucket *e, apr_off_t filelength,
+static int file_make_mmap(apr_bucket *e, apr_size_t filelength,
apr_off_t fileoffset, apr_pool_t *p)
{
apr_bucket_file *a = e->data;
@@ -130,7 +130,7 @@
apr_bucket *b = NULL;
char *buf;
apr_status_t rv;
- apr_off_t filelength = e->length; /* bytes remaining in file past
offset */
+ apr_size_t filelength = e->length; /* bytes remaining in file past
offset */
apr_off_t fileoffset = e->start;
#if APR_HAS_THREADS && !APR_HAS_XTHREAD_FILES
apr_int32_t flags;
@@ -237,7 +237,7 @@
apr_file_t *f = a->fd;
apr_pool_t *curpool = apr_file_pool_get(f);
#if APR_HAS_MMAP
- apr_off_t filelength = data->length; /* bytes remaining in file past
offset */
+ apr_size_t filelength = data->length; /* bytes remaining in file past
offset */
apr_off_t fileoffset = data->start;
#endif
1.37 +1 -1 apr-util/buckets/apr_buckets_pipe.c
Index: apr_buckets_pipe.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_pipe.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- apr_buckets_pipe.c 2001/06/19 18:48:29 1.36
+++ apr_buckets_pipe.c 2001/07/24 20:36:03 1.37
@@ -135,7 +135,7 @@
* buckets created by pipe_read() above.
*/
b->type = &apr_bucket_type_pipe;
- b->length = -1;
+ b->length = (apr_size_t)(-1);
b->start = -1;
b->data = p;
1.17 +2 -2 apr-util/buckets/apr_buckets_refcount.c
Index: apr_buckets_refcount.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_refcount.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- apr_buckets_refcount.c 2001/02/28 17:52:44 1.16
+++ apr_buckets_refcount.c 2001/07/24 20:36:03 1.17
@@ -55,7 +55,7 @@
#include "apr_buckets.h"
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *a,
- apr_off_t point)
+ apr_size_t point)
{
apr_bucket_refcount *r = a->data;
apr_status_t rv;
@@ -91,7 +91,7 @@
APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
apr_off_t start,
- apr_off_t length)
+ apr_size_t length)
{
apr_bucket_refcount *r = data;
1.30 +2 -2 apr-util/buckets/apr_buckets_simple.c
Index: apr_buckets_simple.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_simple.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- apr_buckets_simple.c 2001/06/19 18:48:32 1.29
+++ apr_buckets_simple.c 2001/07/24 20:36:03 1.30
@@ -67,12 +67,12 @@
}
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *a,
- apr_off_t point)
+ apr_size_t point)
{
apr_bucket *b;
apr_status_t rv;
- if (point < 0 || point > a->length) {
+ if ((point > a->length) || (a->length == (apr_size_t)(-1))) {
return APR_EINVAL;
}
1.26 +1 -1 apr-util/buckets/apr_buckets_socket.c
Index: apr_buckets_socket.c
===================================================================
RCS file: /home/cvs/apr-util/buckets/apr_buckets_socket.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- apr_buckets_socket.c 2001/06/19 18:48:33 1.25
+++ apr_buckets_socket.c 2001/07/24 20:36:03 1.26
@@ -130,7 +130,7 @@
* so it will disappear when the connection is finished.
*/
b->type = &apr_bucket_type_socket;
- b->length = -1;
+ b->length = (apr_size_t)(-1);
b->start = -1;
b->data = p;
1.103 +18 -18 apr-util/include/apr_buckets.h
Index: apr_buckets.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- apr_buckets.h 2001/07/24 18:54:48 1.102
+++ apr_buckets.h 2001/07/24 20:36:03 1.103
@@ -201,9 +201,9 @@
* as with pipe and socket buckets), then APR_ENOTIMPL is returned.
* @param e The bucket to split
* @param point The offset of the first byte in the new bucket
- * @deffunc apr_status_t split(apr_bucket *e, apr_off_t point)
+ * @deffunc apr_status_t split(apr_bucket *e, apr_size_t point)
*/
- apr_status_t (*split)(apr_bucket *e, apr_off_t point);
+ apr_status_t (*split)(apr_bucket *e, apr_size_t point);
/**
* Copy the bucket structure (not the data), assuming that this is
@@ -233,15 +233,15 @@
/** The length of the data in the bucket. This could have been
implemented
* with a function, but this is an optimization, because the most
* common thing to do will be to get the length. If the length is
unknown,
- * the value of this field will be -1.
+ * the value of this field will be (apr_size_t)(-1).
*/
- apr_off_t length;
+ apr_size_t length;
/** The start of the data in the bucket relative to the private base
* pointer. The vast majority of bucket types allow a fixed block of
* data to be referenced by multiple buckets, each bucket pointing to
* a different segment of the data. That segment starts at base+start
* and ends at base+start+length.
- * If the length == -1, then start == -1.
+ * If the length == (apr_size_t)(-1), then start == -1.
*/
apr_off_t start;
/** type-dependent data hangs off this pointer */
@@ -652,10 +652,10 @@
* appropriate, and/or modify start on last element
* @param b The brigade to consume data from
* @param nbytes The number of bytes to consume
- * @deffunc void apr_brigade_consume(apr_bucket_brigade *b, apr_size_t
nbytes)
+ * @deffunc void apr_brigade_consume(apr_bucket_brigade *b, apr_off_t nbytes)
*/
APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b,
- apr_size_t nbytes);
+ apr_off_t nbytes);
#endif
/**
@@ -663,11 +663,11 @@
* @param bb The brigade to compute the length of
* @param read_all Read unknown-length buckets to force a size
@ @param length Set to length of the brigade, or -1 if it has
unknown-length buckets
- * @deffunc apr_status_t apr_brigade_length(apr_bucket_brigade *bb, int
read_all, apr_ssize_t *length)
+ * @deffunc apr_status_t apr_brigade_length(apr_bucket_brigade *bb, int
read_all, apr_off_t *length)
*/
APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
int read_all,
- apr_ssize_t *length);
+ apr_off_t *length);
/**
* create an iovec of the elements in a bucket_brigade... return number
@@ -820,7 +820,7 @@
* Split one bucket in two.
* @param e The bucket to split
* @param point The offset to split the bucket at
- * @deffunc apr_status_t apr_bucket_split(apr_bucket *e, apr_off_t point)
+ * @deffunc apr_status_t apr_bucket_split(apr_bucket *e, apr_size_t point)
*/
#define apr_bucket_split(e,point) (e)->type->split(e, point)
@@ -864,10 +864,10 @@
* @param data The bucket to split
* @param point The location to split the bucket
* @return APR_ENOTIMPL
- * @deffunc apr_status_t apr_bucket_split_notimpl(apr_bucket *data,
apr_off_t point)
+ * @deffunc apr_status_t apr_bucket_split_notimpl(apr_bucket *data,
apr_size_t point)
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data,
- apr_off_t point);
+ apr_size_t point);
/**
* A place holder function that signifies that the copy function was not
@@ -969,10 +969,10 @@
* @return APR_EINVAL if the point is not within the bucket;
* APR_ENOMEM if allocation failed;
* or APR_SUCCESS
- * @deffunc apr_status_t apr_bucket_simple_split(apr_bucket *b, apr_off_t
point)
+ * @deffunc apr_status_t apr_bucket_simple_split(apr_bucket *b, apr_size_t
point)
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *b,
- apr_off_t point);
+ apr_size_t point);
/**
* Copy a simple bucket. Most non-reference-counting buckets that allow
@@ -1004,11 +1004,11 @@
* relative to the private base pointer
* @param length The length of the data in the bucket
* @return The new bucket, or NULL if allocation failed
- * @deffunc apr_bucket *apr_bucket_shared_make(apr_bucket_refcount *r, void
*data, apr_off_t start, apr_off_t length)
+ * @deffunc apr_bucket *apr_bucket_shared_make(apr_bucket_refcount *r, void
*data, apr_off_t start, apr_size_t length)
*/
APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
apr_off_t start,
- apr_off_t length);
+ apr_size_t length);
/**
* Decrement the refcount of the data in the bucket. This function
@@ -1031,10 +1031,10 @@
* @return APR_EINVAL if the point is not within the bucket;
* APR_ENOMEM if allocation failed;
* or APR_SUCCESS
- * @deffunc apr_status_t apr_bucket_shared_split(apr_bucket *b, apr_off_t
point)
+ * @deffunc apr_status_t apr_bucket_shared_split(apr_bucket *b, apr_size_t
point)
*/
APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *b,
- apr_off_t point);
+ apr_size_t point);
/**
* Copy a refcounted bucket, incrementing the reference count. Most