You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@bellsouth.net> on 2000/09/14 01:00:49 UTC
[PATCH] tweaks to bucket read retcode feedback
Some code has cropped up lately (e.g., in chunk_filter) which gets
upset if a bucket read routine returns something other than
APR_SUCCESS. That seems pretty darn reasonable.
But...
eos_bucket->read() returns not a normal apr_status_t but instead
AP_END_OF_BRIGADE
pipe_bucket->read() returns APR_EOF when the pipe has no more data
The following patch makes
eos_bucket->read() returns APR_SUCCESS (but *len is set to
AP_END_OF_BRIGADE as before)
pipe_bucket->read() returns APR_SUCCESS when there is no more data
in the pipe (and *len is set to 0 as before)
chunk_filter() doesn't get messed up when some_bucket->read() says
len is 0
It might be nice to remove the pipe_bucket from the brigade and turn
pipe_bucket->read into next_bucket->read if there is no data left in
the pipe_bucket. I think there would be problems with this,
though... One ugliness would be that a single check in a filter for
e->type == AP_BUCKET_EOS is insufficient... other buckets could turn
into EOS while reading... Yuck.
Any complaints, or would you prefer to wait until after I commit :) ?
Index: ap/ap_buckets_eos.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/ap/ap_buckets_eos.c,v
retrieving revision 1.5
diff -u -r1.5 ap_buckets_eos.c
--- ap/ap_buckets_eos.c 2000/08/19 06:04:51 1.5
+++ ap/ap_buckets_eos.c 2000/09/13 22:26:25
@@ -61,7 +61,7 @@
{
*str = NULL;
*len = AP_END_OF_BRIGADE;
- return AP_END_OF_BRIGADE;
+ return APR_SUCCESS;
}
API_EXPORT(ap_bucket *) ap_bucket_make_eos(ap_bucket *b)
Index: ap/ap_buckets_pipe.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/ap/ap_buckets_pipe.c,v
retrieving revision 1.9
diff -u -r1.9 ap_buckets_pipe.c
--- ap/ap_buckets_pipe.c 2000/09/09 06:48:07 1.9
+++ ap/ap_buckets_pipe.c 2000/09/13 22:26:25
@@ -81,7 +81,8 @@
buf = malloc(IOBUFSIZE);
*str = buf;
*len = IOBUFSIZE;
- if ((rv = apr_read(d->thepipe, buf, len)) != APR_SUCCESS) {
+ rv = apr_read(d->thepipe, buf, len);
+ if (rv != APR_SUCCESS && rv != APR_EOF) {
free(buf);
return rv;
}
Index: main/http_core.c
===================================================================
RCS file: /home/cvspublic/apache-2.0/src/main/http_core.c,v
retrieving revision 1.118
diff -u -r1.118 http_core.c
--- main/http_core.c 2000/09/13 01:58:14 1.118
+++ main/http_core.c 2000/09/13 22:26:36
@@ -2942,6 +2942,11 @@
if (rv != APR_SUCCESS) {
return rv;
}
+
+ if (!len) { /* e.g., hit end of pipe */
+ continue;
+ }
+
bytes += len;
/*
--
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...
Re: [PATCH] tweaks to bucket read retcode feedback
Posted by Tony Finch <do...@dotat.at>.
Jeff Trawick <tr...@bellsouth.net> wrote:
>
> eos_bucket->read() returns not a normal apr_status_t but instead
> AP_END_OF_BRIGADE
>
> pipe_bucket->read() returns APR_EOF when the pipe has no more data
Good catch. There are actually some additional problems with pipe_read
which I will fix along with committing your patch. The pipe bucket
isn't quite doing the right thing with its read function at eof which
may not help -- I'll make it morph into an zero-length heap bucket
when it hits EOF which will avoid multiple reads from the empty pipe
as it passes down the filter chain. Filters have to allow for
zero-length buckets so this is OK. There's also a memory leak because
the old ap_bucket_pipe isn't free()d. In fact ap_bucket_pipes are
superfluous so I'll remove them entirely.
>It might be nice to remove the pipe_bucket from the brigade and turn
>pipe_bucket->read into next_bucket->read if there is no data left in
>the pipe_bucket. I think there would be problems with this,
>though... One ugliness would be that a single check in a filter for
>e->type == AP_BUCKET_EOS is insufficient... other buckets could turn
>into EOS while reading... Yuck.
Yes, it's bad in lots of ways. At the moment read may do something
similar to split, which is reasonably easy to understand. Changing it
so that it may also do something similar to AP_BUCKET_REMOVE is making
it even more hairy, plus note that what you would actually have to do
is morph the current bucket into a clone of the next one and then
remove the next one (rather than a regular AP_BUCKET_REMOVE) in order
to preserve the caller's bucket pointer.
Tony.
--
en oeccget g mtcaa f.a.n.finch
v spdlkishrhtewe y dot@dotat.at
eatp o v eiti i d. fanf@covalent.net