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 2002/03/03 03:15:52 UTC

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

rbb         02/03/02 18:15:52

  Modified:    include  httpd.h
               modules/http http_request.c
               server   protocol.c request.c util_filter.c
  Log:
  Fix the mod_dir/mod_negotiation bug, where redirects and sub requests
  were not getting the correct filters.  This is done by creating a location
  in the request rec that holds protocol level filters.  Protocol level
  filters survive for one request, from the time the request is received
  from the user to the time the response is sent.  r->output_filters now
  stores the request level filters, which are only valid for the lifetime
  of one request_rec.
  
  This patch works, but it is not complete.  The second half of the problem
  is that add_any_filter doesn't check where it puts the filters that it
  adds, so it is possible for filters to be put on this wrong list, and
  for filters to be lost completely during request processing.  That half
  of the fix will be coming in the next day or so.
  
  Submitted by:	Will Rowe, Justin Erenkrantz, Ryan Bloom
  
  Revision  Changes    Path
  1.179     +8 -0      httpd-2.0/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
  retrieving revision 1.178
  retrieving revision 1.179
  diff -u -r1.178 -r1.179
  --- httpd.h	21 Feb 2002 02:19:39 -0000	1.178
  +++ httpd.h	3 Mar 2002 02:15:52 -0000	1.179
  @@ -905,6 +905,14 @@
       struct ap_filter_t *output_filters;
       /** A list of input filters to be used for this request */
       struct ap_filter_t *input_filters;
  +
  +    /** A list of protocol level output filters to be used for this
  +     *  request */
  +    struct ap_filter_t *proto_output_filters;
  +    /** A list of protocol level input filters to be used for this
  +     *  request */
  +    struct ap_filter_t *proto_input_filters;
  +
       /** A flag to determine if the eos bucket has been sent yet */
       int eos_sent;
   
  
  
  
  1.126     +8 -2      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.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- http_request.c	25 Jan 2002 01:11:46 -0000	1.125
  +++ http_request.c	3 Mar 2002 02:15:52 -0000	1.126
  @@ -391,8 +391,11 @@
       new->read_length     = r->read_length;     /* We can only read it once */
       new->vlist_validator = r->vlist_validator;
   
  -    new->output_filters  = r->connection->output_filters;
  -    new->input_filters   = r->connection->input_filters;
  +    new->proto_output_filters  = r->proto_output_filters;
  +    new->proto_input_filters   = r->proto_input_filters;
  +
  +    new->output_filters  = new->proto_output_filters;
  +    new->input_filters   = new->proto_input_filters;
   
       ap_add_input_filter("HTTP_IN", NULL, new, new->connection);
   
  @@ -441,6 +444,9 @@
                                           r->err_headers_out);
       r->subprocess_env = apr_table_overlay(r->pool, rr->subprocess_env,
                                          r->subprocess_env);
  +
  +    r->output_filters = rr->output_filters;
  +    r->input_filters = rr->input_filters;
   }
   
   AP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r)
  
  
  
  1.86      +4 -2      httpd-2.0/server/protocol.c
  
  Index: protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- protocol.c	27 Feb 2002 21:16:19 -0000	1.85
  +++ protocol.c	3 Mar 2002 02:15:52 -0000	1.86
  @@ -776,8 +776,10 @@
   
       r->request_config  = ap_create_request_config(r->pool);
       /* Must be set before we run create request hook */
  -    r->output_filters  = conn->output_filters;
  -    r->input_filters   = conn->input_filters;
  +    r->proto_output_filters = conn->output_filters;
  +    r->output_filters  = r->proto_output_filters;
  +    r->proto_input_filters = conn->input_filters;
  +    r->input_filters   = r->proto_input_filters;
       ap_run_create_request(r);
       r->per_dir_config  = r->server->lookup_defaults;
   
  
  
  
  1.100     +13 -3     httpd-2.0/server/request.c
  
  Index: request.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/request.c,v
  retrieving revision 1.99
  retrieving revision 1.100
  diff -u -r1.99 -r1.100
  --- request.c	15 Feb 2002 07:43:20 -0000	1.99
  +++ request.c	3 Mar 2002 02:15:52 -0000	1.100
  @@ -1492,13 +1492,23 @@
   
       /* start with the same set of output filters */
       if (next_filter) {
  +        /* no input filters for a subrequest */
           rnew->output_filters = next_filter;
  +        ap_add_output_filter_handle(ap_subreq_core_filter_handle,
  +                                    NULL, rnew, rnew->connection); 
       }
       else {
  -        rnew->output_filters = r->output_filters;
  +        /* If NULL - we are expecting to be internal_fast_redirect'ed
  +         * to this subrequest - or this request will never be invoked.
  +         * Ignore the original request filter stack entirely, and
  +         * drill the input and output stacks back to the connection.
  +         */
  +        rnew->proto_input_filters = r->proto_input_filters;
  +        rnew->proto_output_filters = r->proto_output_filters;
  +
  +        rnew->input_filters = r->proto_input_filters;
  +        rnew->output_filters = r->proto_output_filters;
       }
  -    ap_add_output_filter_handle(ap_subreq_core_filter_handle,
  -                                NULL, rnew, rnew->connection); 
   
       /* no input filters for a subrequest */
   
  
  
  
  1.79      +11 -5     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.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- util_filter.c	23 Feb 2002 03:58:05 -0000	1.78
  +++ util_filter.c	3 Mar 2002 02:15:52 -0000	1.79
  @@ -294,7 +294,8 @@
   static ap_filter_t *add_any_filter(const char *name, void *ctx, 
                                      request_rec *r, conn_rec *c, 
                                      const filter_trie_node *reg_filter_set,
  -                                   ap_filter_t **r_filters,
  +                                   ap_filter_t **r_filters, 
  +                                   ap_filter_t **p_filters,
                                      ap_filter_t **c_filters)
   {
       if (reg_filter_set) {
  @@ -329,7 +330,7 @@
           if (node && node->frec) {
               apr_pool_t* p = r ? r->pool : c->pool;
               ap_filter_t *f = apr_palloc(p, sizeof(*f));
  -            ap_filter_t **outf = r ? r_filters : c_filters;
  +            ap_filter_t **outf = r ? (r_filters ? r_filters : p_filters) : c_filters;
   
               f->frec = node->frec;
               f->ctx = ctx;
  @@ -360,11 +361,12 @@
   static ap_filter_t *add_any_filter_handle(ap_filter_rec_t *frec, void *ctx, 
                                             request_rec *r, conn_rec *c, 
                                             ap_filter_t **r_filters,
  +                                          ap_filter_t **p_filters,
                                             ap_filter_t **c_filters)
   {
       apr_pool_t* p = r ? r->pool : c->pool;
       ap_filter_t *f = apr_palloc(p, sizeof(*f));
  -    ap_filter_t **outf = r ? r_filters : c_filters;
  +    ap_filter_t **outf = r ? (r_filters ? r_filters : p_filters) : c_filters;
   
       f->frec = frec;
       f->ctx = ctx;
  @@ -390,7 +392,8 @@
                                                 request_rec *r, conn_rec *c)
   {
       return add_any_filter(name, ctx, r, c, registered_input_filters,
  -                          r ? &r->input_filters : NULL, &c->input_filters);
  +                          r ? &r->input_filters : NULL, 
  +                          r ? &r->proto_input_filters : NULL, &c->input_filters);
   }
   
   AP_DECLARE(ap_filter_t *) ap_add_input_filter_handle(ap_filter_rec_t *f,
  @@ -399,6 +402,7 @@
                                                        conn_rec *c)
   {
       return add_any_filter_handle(f, ctx, r, c, r ? &r->input_filters : NULL,
  +                                 r ? &r->proto_input_filters : NULL, 
                                    &c->input_filters);
   }
   
  @@ -406,7 +410,8 @@
                                                  request_rec *r, conn_rec *c)
   {
       return add_any_filter(name, ctx, r, c, registered_output_filters,
  -                          r ? &r->output_filters : NULL, &c->output_filters);
  +                          r ? &r->output_filters : NULL, 
  +                          r ? &r->proto_output_filters : NULL, &c->output_filters);
   }
   
   AP_DECLARE(ap_filter_t *) ap_add_output_filter_handle(ap_filter_rec_t *f,
  @@ -415,6 +420,7 @@
                                                         conn_rec *c)
   {
       return add_any_filter_handle(f, ctx, r, c, r ? &r->output_filters : NULL,
  +                                 r ? &r->proto_output_filters : NULL,
                                    &c->output_filters);
   }