httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_core.c http_protocol.c
Date Sat, 04 Nov 2000 01:30:39 GMT
rbb         00/11/03 17:30:38

  Modified:    src/ap   ap_buckets.c ap_buckets_eos.c ap_buckets_file.c
                        ap_buckets_flush.c ap_buckets_heap.c
                        ap_buckets_mmap.c ap_buckets_pipe.c
                        ap_buckets_pool.c ap_buckets_simple.c
                        ap_buckets_socket.c
               src/include ap_buckets.h
               src/main http_core.c http_protocol.c
  Log:
  Clean up blocking and non-blocking reads from buckets.  The only bucket
  that works correctly right now is sockets, but pipes are coming next.
  This also makes the http_header_filter do AP_MODE_PEEK correctly.
  
  Revision  Changes    Path
  1.29      +1 -1      apache-2.0/src/ap/ap_buckets.c
  
  Index: ap_buckets.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ap_buckets.c	2000/10/23 19:21:47	1.28
  +++ ap_buckets.c	2000/11/04 01:30:26	1.29
  @@ -130,7 +130,7 @@
       AP_BRIGADE_FOREACH(e, b) {
   	if (nvec-- == 0)
               break;
  -	ap_bucket_read(e, (const char **)&vec->iov_base, &iov_len, 0);
  +	ap_bucket_read(e, (const char **)&vec->iov_base, &iov_len, AP_NONBLOCK_READ);
           vec->iov_len = iov_len; /* set indirectly in case size differs */
   	++vec;
       }
  
  
  
  1.11      +1 -1      apache-2.0/src/ap/ap_buckets_eos.c
  
  Index: ap_buckets_eos.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_eos.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ap_buckets_eos.c	2000/10/16 06:04:28	1.10
  +++ ap_buckets_eos.c	2000/11/04 01:30:26	1.11
  @@ -57,7 +57,7 @@
   #include <stdlib.h>
   
   static apr_status_t eos_read(ap_bucket *b, const char **str, 
  -                                apr_ssize_t *len, int block)
  +                                apr_ssize_t *len, ap_read_type block)
   {
       *str = NULL;
       *len = AP_END_OF_BRIGADE;
  
  
  
  1.7       +1 -2      apache-2.0/src/ap/ap_buckets_file.c
  
  Index: ap_buckets_file.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_file.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ap_buckets_file.c	2000/10/16 06:04:28	1.6
  +++ ap_buckets_file.c	2000/11/04 01:30:27	1.7
  @@ -59,7 +59,7 @@
   
   /* XXX: We should obey the block flag */
   static apr_status_t file_read(ap_bucket *e, const char **str,
  -			      apr_ssize_t *len, int block)
  +			      apr_ssize_t *len, ap_read_type block)
   {
       ap_bucket_file *a = (ap_bucket_file *)e->data;
       apr_file_t *f = (apr_file_t *) a->fd;
  @@ -87,7 +87,6 @@
           /* Only need to do seek the first time through */
           a->offset = 0;
       }
  -
       rv = apr_read(f, buf, len);
       if (rv != APR_SUCCESS && rv != APR_EOF) {
   	free(buf);
  
  
  
  1.3       +1 -1      apache-2.0/src/ap/ap_buckets_flush.c
  
  Index: ap_buckets_flush.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_flush.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ap_buckets_flush.c	2000/10/17 14:33:32	1.2
  +++ ap_buckets_flush.c	2000/11/04 01:30:27	1.3
  @@ -57,7 +57,7 @@
   #include <stdlib.h>
   
   static apr_status_t flush_read(ap_bucket *b, const char **str, 
  -                                apr_ssize_t *len, int block)
  +                                apr_ssize_t *len, ap_read_type block)
   {
       *str = NULL;
       *len = b->length;
  
  
  
  1.15      +1 -1      apache-2.0/src/ap/ap_buckets_heap.c
  
  Index: ap_buckets_heap.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_heap.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ap_buckets_heap.c	2000/10/16 06:04:28	1.14
  +++ ap_buckets_heap.c	2000/11/04 01:30:27	1.15
  @@ -66,7 +66,7 @@
   #endif
   
   static apr_status_t heap_read(ap_bucket *b, const char **str, 
  -			      apr_ssize_t *len, int block)
  +			      apr_ssize_t *len, ap_read_type block)
   {
       ap_bucket_shared *s = b->data;
       ap_bucket_heap *h = s->data;
  
  
  
  1.19      +1 -1      apache-2.0/src/ap/ap_buckets_mmap.c
  
  Index: ap_buckets_mmap.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_mmap.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ap_buckets_mmap.c	2000/10/23 19:21:48	1.18
  +++ ap_buckets_mmap.c	2000/11/04 01:30:28	1.19
  @@ -57,7 +57,7 @@
   #include <stdlib.h>
   
   static apr_status_t mmap_read(ap_bucket *b, const char **str, 
  -			      apr_ssize_t *length, int block)
  +			      apr_ssize_t *length, ap_read_type block)
   {
       ap_bucket_shared *s = b->data;
       ap_bucket_mmap *m = s->data;
  
  
  
  1.17      +2 -1      apache-2.0/src/ap/ap_buckets_pipe.c
  
  Index: ap_buckets_pipe.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_pipe.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ap_buckets_pipe.c	2000/10/19 10:51:42	1.16
  +++ ap_buckets_pipe.c	2000/11/04 01:30:28	1.17
  @@ -59,7 +59,7 @@
   
   /* XXX: We should obey the block flag */
   static apr_status_t pipe_read(ap_bucket *a, const char **str,
  -			      apr_ssize_t *len, int block)
  +			      apr_ssize_t *len, ap_read_type block)
   {
       apr_file_t *p = a->data;
       ap_bucket *b;
  @@ -70,6 +70,7 @@
       *str = buf;
       *len = IOBUFSIZE;
       rv = apr_read(p, buf, len);
  +
       if (rv != APR_SUCCESS && rv != APR_EOF) {
           *str = NULL;
   	free(buf);
  
  
  
  1.3       +1 -1      apache-2.0/src/ap/ap_buckets_pool.c
  
  Index: ap_buckets_pool.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_pool.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ap_buckets_pool.c	2000/10/17 22:48:23	1.2
  +++ ap_buckets_pool.c	2000/11/04 01:30:29	1.3
  @@ -75,7 +75,7 @@
   }
   
   static apr_status_t pool_read(ap_bucket *b, const char **str, 
  -			      apr_ssize_t *len, int block)
  +			      apr_ssize_t *len, ap_read_type block)
   {
       ap_bucket_shared *s = b->data;
       ap_bucket_pool *h = s->data;
  
  
  
  1.11      +1 -1      apache-2.0/src/ap/ap_buckets_simple.c
  
  Index: ap_buckets_simple.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_simple.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ap_buckets_simple.c	2000/10/16 06:04:29	1.10
  +++ ap_buckets_simple.c	2000/11/04 01:30:29	1.11
  @@ -95,7 +95,7 @@
   }
   
   static apr_status_t simple_read(ap_bucket *b, const char **str, 
  -				apr_ssize_t *len, int block)
  +				apr_ssize_t *len, ap_read_type block)
   {
       ap_bucket_simple *bd = b->data;
       *str = bd->start;
  
  
  
  1.7       +12 -1     apache-2.0/src/ap/ap_buckets_socket.c
  
  Index: ap_buckets_socket.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/ap/ap_buckets_socket.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ap_buckets_socket.c	2000/10/19 10:51:43	1.6
  +++ ap_buckets_socket.c	2000/11/04 01:30:30	1.7
  @@ -59,17 +59,28 @@
   
   /* XXX: We should obey the block flag */
   static apr_status_t socket_read(ap_bucket *a, const char **str,
  -			      apr_ssize_t *len, int block)
  +			      apr_ssize_t *len, ap_read_type block)
   {
       apr_socket_t *p = a->data;
       ap_bucket *b;
       char *buf;
       apr_status_t rv;
  +    apr_int32_t timeout;
   
  +    if (block == AP_NONBLOCK_READ) {
  +        apr_getsocketopt(p, APR_SO_TIMEOUT, &timeout);
  +        apr_setsocketopt(p, APR_SO_TIMEOUT, 0);
  +    }
  +
       buf = malloc(IOBUFSIZE); /* XXX: check for failure? */
       *str = buf;
       *len = IOBUFSIZE;
       rv = apr_recv(p, buf, len);
  +
  +    if (block == AP_NONBLOCK_READ) {
  +        apr_setsocketopt(p, APR_SO_TIMEOUT, timeout);
  +    }
  +
       if (rv != APR_SUCCESS && rv != APR_EOF) {
           *str = NULL;
   	free(buf);
  
  
  
  1.47      +5 -3      apache-2.0/src/include/ap_buckets.h
  
  Index: ap_buckets.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/ap_buckets.h,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- ap_buckets.h	2000/11/01 19:36:40	1.46
  +++ ap_buckets.h	2000/11/04 01:30:35	1.47
  @@ -71,6 +71,8 @@
    * @package Bucket Brigades
    */
   
  +typedef enum {AP_NONBLOCK_READ, AP_BLOCK_READ} ap_read_type;
  +
   /*
    * The one-sentence buzzword-laden overview: Bucket brigades represent
    * a complex data stream that can be passed through a layered IO
  @@ -157,9 +159,9 @@
        *            or -1 (AP_END_OF_BRIGADE) if there is no more data
        * @param block Should this read function block if there is more data that
        *              cannot be read immediately.
  -     * @deffunc apr_status_t read(ap_bucket *b, const char **str, apr_ssize_t *len, int
block)
  +     * @deffunc apr_status_t read(ap_bucket *b, const char **str, apr_ssize_t *len, ap_read_type
block)
        */
  -    apr_status_t (*read)(ap_bucket *b, const char **str, apr_ssize_t *len, int block);
  +    apr_status_t (*read)(ap_bucket *b, const char **str, apr_ssize_t *len, ap_read_type
block);
       
       /** Make it possible to set aside the data. For most bucket types this is
        *  a no-op; buckets containing data that dies when the stack is un-wound
  @@ -508,7 +510,7 @@
    * @param str The location to store the data in
    * @param len The amount of data read
    * @param block Whether the read function blocks
  - * @deffunc apr_status_t ap_bucket_read(ap_bucket *e, const char **str, apr_ssize_t *len,
int block)
  + * @deffunc apr_status_t ap_bucket_read(ap_bucket *e, const char **str, apr_ssize_t *len,
ap_read_type block)
    */
   #define ap_bucket_read(e,str,len,block) e->type->read(e, str, len, block)
   
  
  
  
  1.201     +3 -3      apache-2.0/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_core.c,v
  retrieving revision 1.200
  retrieving revision 1.201
  diff -u -r1.200 -r1.201
  --- http_core.c	2000/11/03 17:34:58	1.200
  +++ http_core.c	2000/11/04 01:30:37	1.201
  @@ -3108,7 +3108,7 @@
           else {
               const char *str;
               apr_ssize_t n;
  -            rv = ap_bucket_read(e, &str, &n, 0);
  +            rv = ap_bucket_read(e, &str, &n, AP_BLOCK_READ);
               if (rv != APR_SUCCESS) {
                   /* XXX: log error */
                   return rv;
  @@ -3222,7 +3222,7 @@
   		const char *data;
   		apr_ssize_t len;
   
  -		rv = ap_bucket_read(e, &data, &len, 1);
  +		rv = ap_bucket_read(e, &data, &len, AP_BLOCK_READ);
   		if (rv != APR_SUCCESS) {
   		    return rv;
   		}
  @@ -3385,7 +3385,7 @@
               else {
                   const char *str;
                   apr_ssize_t n;
  -                rv = ap_bucket_read(e, &str, &n, 0);
  +                rv = ap_bucket_read(e, &str, &n, AP_BLOCK_READ);
                   if (n) {
                       nbytes += n;
                       if (!fd) {
  
  
  
  1.226     +23 -10    apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.225
  retrieving revision 1.226
  diff -u -r1.225 -r1.226
  --- http_protocol.c	2000/11/03 22:35:52	1.225
  +++ http_protocol.c	2000/11/04 01:30:37	1.226
  @@ -886,7 +886,7 @@
            */
           b = AP_BRIGADE_FIRST(bb);
           while (b != AP_BRIGADE_SENTINEL(bb) && !AP_BUCKET_IS_EOS(b)) {
  -            ap_bucket_read(b, &buf, &len, 1);
  +            ap_bucket_read(b, &buf, &len, AP_BLOCK_READ);
               AP_DEBUG_ASSERT(len <= ctx->chunk_size - ctx->bytes_delivered);
               ctx->bytes_delivered += len;
               b = AP_BUCKET_NEXT(b);
  @@ -927,12 +927,25 @@
       if (mode == AP_MODE_PEEK) {
           /* XXX make me *try* to read from the network if AP_BRIGADE_EMPTY().
            * For now, we can't do a non-blocking read so we bypass this.
  -         *
  -         * Also, note that in the cases where another request can be read now
  -         * without blocking, it is likely already in our brigade, so this hack 
  -         * isn't so bad after all.
            */
  +        ap_bucket *e;
  +        const char *str;
  +        apr_size_t length;
  +
  +        e = AP_BRIGADE_FIRST(ctx->b);
  +        while (e->length == 0) {
  +            AP_BUCKET_REMOVE(e);
  +            ap_bucket_destroy(e);
  +
           if (AP_BRIGADE_EMPTY(ctx->b)) {
  +                e = NULL;
  +                break;
  +            }
  +
  +            e = AP_BRIGADE_FIRST(ctx->b);
  +        }    
  +
  +        if (!e || ap_bucket_read(e, &str, &length, AP_NONBLOCK_READ) != APR_SUCCESS)
{
               return APR_EOF;
           }
           else {
  @@ -951,7 +964,7 @@
           while (e != AP_BRIGADE_SENTINEL(ctx->b)) {
               const char *ignore;
   
  -            if ((rv = ap_bucket_read(e, &ignore, &len, 0)) != APR_SUCCESS) {
  +            if ((rv = ap_bucket_read(e, &ignore, &len, AP_BLOCK_READ)) != APR_SUCCESS)
{
                   /* probably APR_IS_EAGAIN(rv); socket state isn't correct;
                    * remove log once we get this squared away */
                   ap_log_error(APLOG_MARK, APLOG_ERR, rv, f->c->base_server, 
  @@ -987,7 +1000,7 @@
   
       while (!AP_BRIGADE_EMPTY(ctx->b)) {
           e = AP_BRIGADE_FIRST(ctx->b);
  -        if ((rv = ap_bucket_read(e, (const char **)&buff, &len, 0)) != APR_SUCCESS)
{
  +        if ((rv = ap_bucket_read(e, (const char **)&buff, &len, AP_BLOCK_READ))
!= APR_SUCCESS) {
               return rv;
           }
   
  @@ -1050,7 +1063,7 @@
               ap_bucket_destroy(e);
               continue;
           }
  -        retval = ap_bucket_read(e, &temp, &length, 0);
  +        retval = ap_bucket_read(e, &temp, &length, AP_BLOCK_READ);
   
           if (retval != APR_SUCCESS) {
               total = ((length < 0) && (total == 0)) ? -1 : total;
  @@ -2283,7 +2296,7 @@
                       const char *ignored;
                       apr_ssize_t length;
                       
  -                    rv = ap_bucket_read(e, &ignored, &length, 1);
  +                    rv = ap_bucket_read(e, &ignored, &length, AP_BLOCK_READ);
                       if (rv != APR_SUCCESS) {
                           return rv;
                       }
  @@ -2669,7 +2682,7 @@
   
       total = 0;
       while (total < bufsiz &&  b != AP_BRIGADE_SENTINEL(bb) && !AP_BUCKET_IS_EOS(b))
{
  -        if ((rv = ap_bucket_read(b, &tempbuf, &len_read, 0)) != APR_SUCCESS) {
  +        if ((rv = ap_bucket_read(b, &tempbuf, &len_read, AP_BLOCK_READ)) != APR_SUCCESS)
{
               return -1;
           }
           if (total + len_read > bufsiz) {
  
  
  

Mime
View raw message