You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2001/04/23 00:19:33 UTC

cvs commit: httpd-2.0/server core.c protocol.c util_filter.c

rbb         01/04/22 15:19:33

  Modified:    .        CHANGES
               include  httpd.h util_filter.h
               modules/experimental mod_charset_lite.c mod_ext_filter.c
               modules/http http_protocol.c http_request.c mod_core.h
               modules/tls mod_tls.c
               server   core.c protocol.c util_filter.c
  Log:
  At the hack-athon we decided to change the way that input filters
  determine how much data is returned to the previous filter.  Prior to this
  change, we used a field in the conn_rec to determine how much to return.
  After this change, we use an argument to ap_get_brigade.  This makes it
  much more obvious how things work at all levels, so that module authors
  can easily determine how much data is supposed to be returned to them.
  
  Revision  Changes    Path
  1.181     +6 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.180
  retrieving revision 1.181
  diff -u -d -b -w -u -r1.180 -r1.181
  --- CHANGES	2001/04/20 17:59:01	1.180
  +++ CHANGES	2001/04/22 22:19:26	1.181
  @@ -1,4 +1,10 @@
   Changes with Apache 2.0.18-dev
  +
  +  *) Change how input filters decide how much data is returned to the
  +     higher filter.  We used to use a field in the conn_rec, with this
  +     change, we use an argument to ap_get_brigade to determine how much
  +     data is retrieved. [Ryan Bloom]
  +
     *) Fix seg fault at start-up introduced by Ryan's change to enable
        modules to specify their own logging tags. mod_log_config
        registers an optional function, ap_register_log_handler().
  
  
  
  1.149     +1 -4      httpd-2.0/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
  retrieving revision 1.148
  retrieving revision 1.149
  diff -u -d -b -w -u -r1.148 -r1.149
  --- httpd.h	2001/04/21 12:23:33	1.148
  +++ httpd.h	2001/04/22 22:19:27	1.149
  @@ -697,7 +697,7 @@
       apr_off_t clength;
   
       /** bytes left to read */
  -    long remaining;
  +    apr_size_t remaining;
       /** bytes that have been read */
       long read_length;
       /** how the request body should be read */
  @@ -887,9 +887,6 @@
       /** A list of output filters to be used for this connection
        *  @defvar ap_filter_t *filters */
       struct ap_filter_t *output_filters;
  -    /** The length of the current request body
  -     *  @defvar long remain */
  -    long remain;
   };
   
   /* Per-vhost config... */
  
  
  
  1.50      +3 -2      httpd-2.0/include/util_filter.h
  
  Index: util_filter.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/util_filter.h,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -d -b -w -u -r1.49 -r1.50
  --- util_filter.h	2001/04/12 20:06:49	1.49
  +++ util_filter.h	2001/04/22 22:19:27	1.50
  @@ -155,7 +155,8 @@
    */
   typedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f, apr_bucket_brigade *b);
   typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f, apr_bucket_brigade *b, 
  -                                          ap_input_mode_t mode);
  +                                          ap_input_mode_t mode, apr_size_t *readbytes);
  +
   typedef union ap_filter_func {
       ap_out_filter_func out_func;
       ap_in_filter_func in_func;
  @@ -273,7 +274,7 @@
    * @param mode   ::AP_MODE_BLOCKING, ::AP_MODE_NONBLOCKING, or ::AP_MODE_PEEK
    */
   AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket, 
  -                                        ap_input_mode_t mode);
  +                                        ap_input_mode_t mode, apr_size_t *readbytes);
   
   /**
    * Pass the current bucket brigade down to the next filter on the filter
  
  
  
  1.45      +3 -3      httpd-2.0/modules/experimental/mod_charset_lite.c
  
  Index: mod_charset_lite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_charset_lite.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -d -b -w -u -r1.44 -r1.45
  --- mod_charset_lite.c	2001/03/02 21:36:13	1.44
  +++ mod_charset_lite.c	2001/04/22 22:19:28	1.45
  @@ -1005,7 +1005,7 @@
   }
   
   static int xlate_in_filter(ap_filter_t *f, apr_bucket_brigade *bb, 
  -                           ap_input_mode_t mode)
  +                           ap_input_mode_t mode, apr_size_t *readbytes)
   {
       apr_status_t rv;
       charset_req_t *reqinfo = ap_get_module_config(f->r->request_config,
  @@ -1049,11 +1049,11 @@
       }
   
       if (ctx->noop) {
  -        return ap_get_brigade(f->next, bb, mode);
  +        return ap_get_brigade(f->next, bb, mode, readbytes);
       }
   
       if (APR_BRIGADE_EMPTY(ctx->bb)) {
  -        if ((rv = ap_get_brigade(f->next, bb, mode)) != APR_SUCCESS) {
  +        if ((rv = ap_get_brigade(f->next, bb, mode, readbytes)) != APR_SUCCESS) {
               return rv;
           }
       }
  
  
  
  1.14      +2 -2      httpd-2.0/modules/experimental/mod_ext_filter.c
  
  Index: mod_ext_filter.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_ext_filter.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -d -b -w -u -r1.13 -r1.14
  --- mod_ext_filter.c	2001/04/12 13:35:04	1.13
  +++ mod_ext_filter.c	2001/04/22 22:19:29	1.14
  @@ -749,7 +749,7 @@
   
   #if 0
   static int ef_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, 
  -                           ap_input_mode_t mode)
  +                           ap_input_mode_t mode, apr_size_t *readbytes)
   {
       apr_status_t rv;
       apr_bucket *b;
  @@ -757,7 +757,7 @@
       apr_ssize_t len;
       char *zero;
   
  -    rv = ap_get_brigade(f->next, bb, mode);
  +    rv = ap_get_brigade(f->next, bb, mode, readbytes);
       if (rv != APR_SUCCESS) {
           return rv;
       }
  
  
  
  1.317     +13 -13    httpd-2.0/modules/http/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
  retrieving revision 1.316
  retrieving revision 1.317
  diff -u -d -b -w -u -r1.316 -r1.317
  --- http_protocol.c	2001/04/22 15:46:19	1.316
  +++ http_protocol.c	2001/04/22 22:19:29	1.317
  @@ -420,7 +420,7 @@
   static long get_chunk_size(char *);
   
   apr_status_t ap_dechunk_filter(ap_filter_t *f, apr_bucket_brigade *bb,
  -                               ap_input_mode_t mode)
  +                               ap_input_mode_t mode, apr_size_t *readbytes)
   {
       apr_status_t rv;
       struct dechunk_ctx *ctx = f->ctx;
  @@ -475,8 +475,8 @@
   
       if (ctx->state == WANT_BODY) {
           /* Tell ap_http_filter() how many bytes to deliver. */
  -        f->c->remain = ctx->chunk_size - ctx->bytes_delivered;
  -        if ((rv = ap_get_brigade(f->next, bb, mode)) != APR_SUCCESS) {
  +        apr_size_t readbytes = ctx->chunk_size - ctx->bytes_delivered;
  +        if ((rv = ap_get_brigade(f->next, bb, mode, &readbytes)) != APR_SUCCESS) {
               return rv;
           }
           /* Walk through the body, accounting for bytes, and removing an eos bucket if
  @@ -503,7 +503,7 @@
       apr_bucket_brigade *b;
   } http_ctx_t;
   
  -apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode)
  +apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t *readbytes)
   {
       apr_bucket *e;
       char *buff;
  @@ -556,12 +556,12 @@
       }
   
       if (APR_BRIGADE_EMPTY(ctx->b)) {
  -        if ((rv = ap_get_brigade(f->next, ctx->b, mode)) != APR_SUCCESS) {
  +        if ((rv = ap_get_brigade(f->next, ctx->b, mode, readbytes)) != APR_SUCCESS) {
               return rv;
           }
       }
   
  -    if (f->c->remain) {
  +    if (*readbytes) {
           while (!APR_BRIGADE_EMPTY(ctx->b)) {
               const char *ignore;
   
  @@ -580,12 +580,12 @@
                    * a time - don't assume that one call to apr_bucket_read()
                    * will return the full string.
                    */
  -                if (f->c->remain < len) {
  -                    apr_bucket_split(e, f->c->remain);
  -                    f->c->remain = 0;
  +                if (*readbytes < len) {
  +                    apr_bucket_split(e, *readbytes);
  +                    *readbytes = 0;
                   }
                   else {
  -                    f->c->remain -= len;
  +                    *readbytes -= len;
                   }
                   APR_BUCKET_REMOVE(e);
                   APR_BRIGADE_INSERT_TAIL(b, e);
  @@ -593,7 +593,7 @@
               }
               apr_bucket_delete(e);
           }
  -        if (f->c->remain == 0) {
  +        if (*readbytes == 0) {
               apr_bucket *eos = apr_bucket_eos_create();
                   
               APR_BRIGADE_INSERT_TAIL(b, eos);
  @@ -1258,7 +1258,7 @@
               return HTTP_BAD_REQUEST;
           }
   
  -        r->connection->remain = r->remaining = atol(lenp);
  +        r->remaining = atol(lenp);
       }
   
       if ((r->read_body == REQUEST_NO_BODY) &&
  @@ -1366,7 +1366,7 @@
   
       do {
           if (APR_BRIGADE_EMPTY(bb)) {
  -            if (ap_get_brigade(r->input_filters, bb, AP_MODE_BLOCKING) != APR_SUCCESS) {
  +            if (ap_get_brigade(r->input_filters, bb, AP_MODE_BLOCKING, &r->remaining) != APR_SUCCESS) {
                   /* if we actually fail here, we want to just return and
                    * stop trying to read data from the client.
                    */
  
  
  
  1.95      +2 -1      httpd-2.0/modules/http/http_request.c
  
  Index: http_request.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_request.c,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -d -b -w -u -r1.94 -r1.95
  --- http_request.c	2001/03/27 19:19:07	1.94
  +++ http_request.c	2001/04/22 22:19:30	1.95
  @@ -367,6 +367,7 @@
          ### allow us to defer creation of the brigade to when we actually
          ### need to send a FLUSH. */
       apr_bucket_brigade *bb = apr_brigade_create(r->pool);
  +    apr_size_t zero = 0;
   
       /* Flush the filter contents if:
        *
  @@ -375,7 +376,7 @@
        */
       /* ### shouldn't this read from the connection input filters? */
       if (!r->connection->keepalive || 
  -        ap_get_brigade(r->input_filters, bb, AP_MODE_PEEK) != APR_SUCCESS) {
  +        ap_get_brigade(r->input_filters, bb, AP_MODE_PEEK, &zero) != APR_SUCCESS) {
           apr_bucket *e = apr_bucket_flush_create();
   
           /* We just send directly to the connection based filters.  At
  
  
  
  1.10      +2 -2      httpd-2.0/modules/http/mod_core.h
  
  Index: mod_core.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/mod_core.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -d -b -w -u -r1.9 -r1.10
  --- mod_core.h	2001/04/21 12:23:35	1.9
  +++ mod_core.h	2001/04/22 22:19:30	1.10
  @@ -73,8 +73,8 @@
   /*
    * These (input) filters are internal to the mod_core operation.
    */
  -apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode);
  -apr_status_t ap_dechunk_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode);
  +apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t *readbytes);
  +apr_status_t ap_dechunk_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t *readbytes);
   
   char *ap_response_code_string(request_rec *r, int error_index);
   
  
  
  
  1.5       +4 -4      httpd-2.0/modules/tls/mod_tls.c
  
  Index: mod_tls.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/tls/mod_tls.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -d -b -w -u -r1.4 -r1.5
  --- mod_tls.c	2001/02/18 02:10:26	1.4
  +++ mod_tls.c	2001/04/22 22:19:31	1.5
  @@ -186,14 +186,14 @@
       return APR_SUCCESS;
   }
   
  -static apr_status_t churn(TLSFilterCtx *pCtx,apr_read_type_e eReadType)
  +static apr_status_t churn(TLSFilterCtx *pCtx,apr_read_type_e eReadType,apr_size_t *readbytes)
   {
       ap_input_mode_t eMode=eReadType == APR_BLOCK_READ ? AP_MODE_BLOCKING
         : AP_MODE_NONBLOCKING;
       apr_bucket *pbktIn;
   
       if(APR_BRIGADE_EMPTY(pCtx->pbbInput)) {
  -	ap_get_brigade(pCtx->pInputFilter->next,pCtx->pbbInput,eMode);
  +	ap_get_brigade(pCtx->pInputFilter->next,pCtx->pbbInput,eMode,readbytes);
   	if(APR_BRIGADE_EMPTY(pCtx->pbbInput))
   	    return APR_EOF;
       }
  @@ -329,7 +329,7 @@
   }
   
   static apr_status_t tls_in_filter(ap_filter_t *f,apr_bucket_brigade *pbbOut,
  -				  ap_input_mode_t eMode)
  +				  ap_input_mode_t eMode, apr_size_t *readbytes)
   {
       TLSFilterCtx *pCtx=f->ctx;
       apr_read_type_e eReadType=eMode == AP_MODE_BLOCKING ? APR_BLOCK_READ :
  @@ -340,7 +340,7 @@
       assert(eMode != AP_MODE_PEEK);
   
       // churn the state machine
  -    ret=churn(pCtx,eReadType);
  +    ret=churn(pCtx,eReadType,readbytes);
       if(ret != APR_SUCCESS)
   	return ret;
   
  
  
  
  1.9       +1 -1      httpd-2.0/server/core.c
  
  Index: core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/core.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -d -b -w -u -r1.8 -r1.9
  --- core.c	2001/04/11 23:37:16	1.8
  +++ core.c	2001/04/22 22:19:32	1.9
  @@ -2995,7 +2995,7 @@
       return ap_pass_brigade(r->output_filters, bb);
   }
   
  -static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode)
  +static int core_input_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_size_t *readbytes)
   {
       apr_bucket *e;
       
  
  
  
  1.16      +2 -3      httpd-2.0/server/protocol.c
  
  Index: protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -d -b -w -u -r1.15 -r1.16
  --- protocol.c	2001/04/21 12:23:34	1.15
  +++ protocol.c	2001/04/22 22:19:32	1.16
  @@ -203,6 +203,7 @@
       int retval;
       int total = 0;
       int looking_ahead = 0;
  +    apr_size_t zero = 0;
       apr_size_t length;
       conn_rec *c = r->connection;
       core_request_config *req_cfg;
  @@ -217,7 +218,7 @@
   
       while (1) {
           if (APR_BRIGADE_EMPTY(b)) {
  -            if ((retval = ap_get_brigade(c->input_filters, b, AP_MODE_BLOCKING)) != APR_SUCCESS ||
  +            if ((retval = ap_get_brigade(c->input_filters, b, AP_MODE_BLOCKING, &zero)) != APR_SUCCESS ||
                   APR_BRIGADE_EMPTY(b)) {
                   apr_brigade_destroy(b);
                   return -1;
  @@ -547,8 +548,6 @@
       apr_pool_t *p;
       const char *expect;
       int access_status;
  -
  -    AP_DEBUG_ASSERT(conn->remain == 0);
   
       apr_pool_create(&p, conn->pool);
       r = apr_pcalloc(p, sizeof(request_rec));
  
  
  
  1.56      +2 -2      httpd-2.0/server/util_filter.c
  
  Index: util_filter.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/util_filter.c,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -d -b -w -u -r1.55 -r1.56
  --- util_filter.c	2001/04/12 20:06:50	1.55
  +++ util_filter.c	2001/04/22 22:19:32	1.56
  @@ -209,10 +209,10 @@
    * brigade especially for that use.
    */
   AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *next, apr_bucket_brigade *bb, 
  -                                        ap_input_mode_t mode)
  +                                        ap_input_mode_t mode, apr_size_t *readbytes)
   {
       if (next) {
  -        return next->frec->filter_func.in_func(next, bb, mode);
  +        return next->frec->filter_func.in_func(next, bb, mode, readbytes);
       }
       return AP_NOBODY_READ;
   }