httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <trawi...@bellsouth.net>
Subject [PATCH] tweaks to bucket read retcode feedback
Date Wed, 13 Sep 2000 23:00:49 GMT
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...

Mime
View raw message