You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@apache.org on 2001/07/05 16:58:04 UTC

cvs commit: httpd-2.0/server protocol.c

stoddard    01/07/05 07:58:03

  Modified:    .        CHANGES
               server   protocol.c
  Log:
  Do non-blocking reads from pipes in the content-length filter.
  
  Revision  Changes    Path
  1.239     +2 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.238
  retrieving revision 1.239
  diff -u -r1.238 -r1.239
  --- CHANGES	2001/07/02 14:38:43	1.238
  +++ CHANGES	2001/07/05 14:58:02	1.239
  @@ -1,4 +1,6 @@
   Changes with Apache 2.0.20-dev
  +  *) Get non-blocking CGI pipe reads working with the bucket brigades.
  +     [Bill Stoddard]
   
     *) Fix seg fault on Windows when serving files cached with mod_file_cache.
        [Bill Stoddard]
  
  
  
  1.29      +24 -5     httpd-2.0/server/protocol.c
  
  Index: protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- protocol.c	2001/06/27 20:18:09	1.28
  +++ protocol.c	2001/07/05 14:58:03	1.29
  @@ -862,22 +862,41 @@
   
       APR_BRIGADE_FOREACH(e, b) {
           const char *ignored;
  -        apr_size_t length;
  +        apr_size_t len;
   
           if (APR_BUCKET_IS_EOS(e) || APR_BUCKET_IS_FLUSH(e)) {
               send_it = 1;
           }
           if (e->length == -1) { /* if length unknown */
  -            rv = apr_bucket_read(e, &ignored, &length, APR_BLOCK_READ);
  +            rv = apr_bucket_read(e, &ignored, &len, APR_NONBLOCK_READ);
  +            if (rv == APR_EAGAIN) {
  +                /* If the protocol level implies support for chunked encoding, 
  +                 * flush the filter chain to the network then do a blocking 
  +                 * read. This is replicating the behaviour of ap_send_fb
  +                 * in Apache 1.3.
  +                 */
  +                if (r->proto_num >= HTTP_VERSION(1,1)) {
  +                    apr_bucket_brigade *split;
  +                    split = apr_brigade_split(b, e);
  +                    rv = ap_fflush(f, b);
  +                    if (rv != APR_SUCCESS)
  +                        return rv;
  +                    b = split;
  +                    ctx->curr_len = 0;
  +                }
  +                rv = apr_bucket_read(e, &ignored, &len, APR_BLOCK_READ);
  +            }
               if (rv != APR_SUCCESS) {
  +                ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "ap_content_length_filter: "
  +                              "apr_bucket_read() failed");
                   return rv;
               }
           }
           else {
  -            length = e->length;
  +            len = e->length;
           }
  -        ctx->curr_len += length;
  -        r->bytes_sent += length;
  +        ctx->curr_len += len;
  +        r->bytes_sent += len;
       }
   
       if ((ctx->curr_len < AP_MIN_BYTES_TO_WRITE) && !send_it) {