httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: bug in ap_get_client_block (wrong handling of EOS)
Date Wed, 14 May 2003 05:01:06 GMT
Jeff Trawick wrote:
> Stas Bekman wrote:
> 
>> ap_get_client_block API docs says:
>>
>>  * @return Number of bytes inserted into the buffer.  When done 
>> reading, 0
>>  *         if EOF, or -1 if there was an error
>>
>> but this is bogus. If the EOS bucket arrives in the same bucket 
>> brigade with real data, ap_get_client_block() will return the size of 
>> the read data, completely missing the fact that EOS went through. Next 
>> it'll be called again (because the caller wasn't signalled with EOF) 
>> and bad things happen because there are no rules for how filters 
>> should behave after they have processed EOS the last time they were 
>> called.
> 
> 
> teach ap_get_client_block() to look for EOS before calling 
> apr_brigade_flatten()...  the eos flag can probably be saved in 
> core_request_config...

Index: include/http_core.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/http_core.h,v
retrieving revision 1.70.2.2
diff -u -r1.70.2.2 http_core.h
--- include/http_core.h	8 May 2003 20:49:32 -0000	1.70.2.2
+++ include/http_core.h	14 May 2003 04:57:41 -0000
@@ -353,6 +353,9 @@
       * won't actually be delivered as the response for the non-GET method.
       */
      int deliver_script;
+
+    /* a flag indicating whether the EOS bucket was seen */
+    int seen_eos;
  } core_request_config;

  /* Standard entries that are guaranteed to be accessible via
Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.463.2.3
diff -u -r1.463.2.3 http_protocol.c
--- modules/http/http_protocol.c	17 Apr 2003 11:31:27 -0000	1.463.2.3
+++ modules/http/http_protocol.c	14 May 2003 04:57:42 -0000
@@ -1886,7 +1886,16 @@
  {
      apr_status_t rv;
      apr_bucket_brigade *bb;
+    apr_bucket *e;
+    core_request_config *req_cfg =
+        (core_request_config *)ap_get_module_config(r->request_config,
+                                                    &core_module);

+    if (req_cfg->seen_eos) {
+        /* indicate EOF */
+        return 0;
+    }
+
      bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
      if (bb == NULL) {
          r->connection->keepalive = AP_CONN_CLOSE;
@@ -1913,7 +1922,15 @@
       * returning data when requested.
       */
      AP_DEBUG_ASSERT(!APR_BRIGADE_EMPTY(bb));
-
+
+    /* search for EOS */
+    APR_BRIGADE_FOREACH(e, bb) {
+        if (APR_BUCKET_IS_EOS(e)) {
+            req_cfg->seen_eos = 1;
+            break;
+        }
+    }
+
      rv = apr_brigade_flatten(bb, buffer, &bufsiz);
      if (rv != APR_SUCCESS) {
          apr_brigade_destroy(bb);



__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message