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_connection.c http_core.c http_protocol.c util_filter.c
Date Wed, 04 Oct 2000 23:19:36 GMT
rbb         00/10/04 16:19:35

  Modified:    src      CHANGES
               src/include httpd.h util_filter.h
               src/main http_connection.c http_core.c http_protocol.c
                        util_filter.c
  Log:
  Connection oriented filters are now stored in the conn_rec instead of the
  request_rec.  This means that a conn_rec must be supplied when calling
  ap_add_filter.  The reason for this change is that we need to be able to
  add the core_filter (whether or SSL or not) before we try to read the
  request.  This way, if a request fails, we can actually send the error
  page back to the client.  With this change, we add the core filter to the
  conn_rec during the pre-connection phase.
  Submitted by:	Ryan Bloom, Jeff Trawick, and Greg Ames
  
  Revision  Changes    Path
  1.244     +7 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.243
  retrieving revision 1.244
  diff -u -r1.243 -r1.244
  --- CHANGES	2000/10/04 12:01:12	1.243
  +++ CHANGES	2000/10/04 23:19:27	1.244
  @@ -1,5 +1,12 @@
   Changes with Apache 2.0a7
   
  +  *) Connection oriented output filters are now stored in the 
  +     conn_rec instead of the request_rec.  This allows us to add the
  +     output filter in the pre-connection phase instead of the
  +     post_read_request phase, which keeps us from trying to write an
  +     error page before we have a filter to write to the network.
  +     [Ryan Bloom, Jeff Trawick, and Greg Ames]
  +
     *) Cleaning up an mmap bucket no longer deletes the mmap.  An
        mmap can be used across multiple buckets (default_handler with
        byte ranges, mod_file_cache, mod_mmap_static), so cleanup of
  
  
  
  1.89      +3 -0      apache-2.0/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- httpd.h	2000/10/02 00:47:25	1.88
  +++ httpd.h	2000/10/04 23:19:29	1.89
  @@ -885,6 +885,9 @@
       /** Location to store data read from the client.
        *  @defvar ap_bucket_brigade *input_data */
       struct ap_bucket_brigade *input_data;
  +    /** A list of output filters to be used for this connection
  +     *  @defvar ap_filter_t *filters */
  +    struct ap_filter_t *output_filters;
   };
   
   /* Per-vhost config... */
  
  
  
  1.21      +2 -1      apache-2.0/src/include/util_filter.h
  
  Index: util_filter.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/util_filter.h,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- util_filter.h	2000/10/03 00:44:00	1.20
  +++ util_filter.h	2000/10/04 23:19:29	1.21
  @@ -332,7 +332,8 @@
    * @param r The request to add this filter for.
    * @deffunc void ap_add_filter(const char *name, request_rec *r)
    */
  -API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r);
  +API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r,
  +                               conn_rec *c);
   
   /* The next two filters are for abstraction purposes only.  They could be
    * done away with, but that would require that we break modules if we ever
  
  
  
  1.48      +1 -0      apache-2.0/src/main/http_connection.c
  
  Index: http_connection.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_connection.c,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- http_connection.c	2000/10/02 19:52:36	1.47
  +++ http_connection.c	2000/10/04 23:19:32	1.48
  @@ -217,6 +217,7 @@
   int ap_pre_http_connection(conn_rec *c)
   {
       ap_add_input_filter("CORE_IN", NULL, c);
  +    ap_add_filter("CORE", NULL, NULL, c);
       return OK;
   }
   
  
  
  
  1.143     +13 -19    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.142
  retrieving revision 1.143
  diff -u -r1.142 -r1.143
  --- http_core.c	2000/10/04 22:09:46	1.142
  +++ http_core.c	2000/10/04 23:19:33	1.143
  @@ -2564,7 +2564,7 @@
       return APR_SUCCESS;
   }
   /* XXX handle partial writes */
  -static apr_status_t send_the_file(request_rec *r, apr_file_t *fd, 
  +static apr_status_t send_the_file(conn_rec *c, apr_file_t *fd, 
                                     apr_hdtr_t *hdtr, apr_off_t offset, 
                                     apr_size_t length, apr_size_t *nbytes) 
   {
  @@ -2573,11 +2573,11 @@
       apr_size_t n = length;
   
   #if APR_HAS_SENDFILE
  -    if (!r->connection->keepalive) {
  +    if (!c->keepalive) {
           /* Prepare the socket to be reused */
           flags |= APR_SENDFILE_DISCONNECT_SOCKET;
       }
  -    rv = apr_sendfile(r->connection->client->bsock, 
  +    rv = apr_sendfile(c->client->bsock, 
                         fd,      /* The file to send */
                         hdtr,    /* Header and trailer iovecs */
                         &offset, /* Offset in file to begin sending from */
  @@ -2592,6 +2592,7 @@
   
       return APR_SUCCESS;
   }
  +
   /* Note --- ErrorDocument will now work from .htaccess files.  
    * The AllowOverride of Fileinfo allows webmasters to turn it off
    */
  @@ -3286,7 +3287,7 @@
       ap_bucket_brigade *more = NULL;
       apr_ssize_t bytes_sent = 0, nbytes = 0;
       ap_bucket *e;
  -    request_rec *r = f->r;
  +    conn_rec *c = f->c;
       core_output_filter_ctx_t *ctx = f->ctx;
   
       apr_ssize_t nvec = 0;
  @@ -3299,7 +3300,7 @@
       apr_off_t foffset = 0;
   
       if (ctx == NULL) {
  -        f->ctx = ctx = apr_pcalloc(r->pool, sizeof(core_output_filter_ctx_t));
  +        f->ctx = ctx = apr_pcalloc(c->pool, sizeof(core_output_filter_ctx_t));
       }
       /* If we have a saved brigade, concatenate the new brigade to it */
       if (ctx->b) {
  @@ -3309,10 +3310,10 @@
       }
   
       /* Hijack any bytes in BUFF and prepend it to the brigade. */
  -    if (r->connection->client->outcnt) {
  -        e = ap_bucket_create_heap(r->connection->client->outbase,
  -                                  r->connection->client->outcnt, 1, NULL);
  -        r->connection->client->outcnt = 0;
  +    if (c->client->outcnt) {
  +        e = ap_bucket_create_heap(c->client->outbase,
  +                                  c->client->outcnt, 1, NULL);
  +        c->client->outcnt = 0;
           AP_BRIGADE_INSERT_HEAD(b, e);
       }
   
  @@ -3376,10 +3377,10 @@
                   hdtr.numtrailers = nvec_trailers;
                   hdtr.trailers = vec_trailers;
               }
  -            rv = send_the_file(r, fd, &hdtr, foffset, flen, &bytes_sent);
  +            rv = send_the_file(c, fd, &hdtr, foffset, flen, &bytes_sent);
           }
           else {
  -            rv = writev_it_all(r->connection->client->bsock, 
  +            rv = writev_it_all(c->client->bsock, 
                                  vec, nvec, 
                                  nbytes, &bytes_sent);
               nbytes = 0; /* in case more points to another brigade */
  @@ -3423,12 +3424,6 @@
   static unsigned short core_port(const request_rec *r)
       { return DEFAULT_HTTP_PORT; }
   
  -static int core_post_read_req(request_rec *r)
  -{
  -    ap_add_filter("CORE", NULL, r);
  -    return DECLINED;
  -}
  -
   static void core_register_filter(request_rec *r)
   {
       int i;
  @@ -3439,7 +3434,7 @@
   
       for (i = 0; i < conf->filters->nelts; i++) {
           char *foobar = items[i];
  -        ap_add_filter(foobar, NULL, r);
  +        ap_add_filter(foobar, NULL, r, r->connection);
       }
   }
   
  @@ -3457,7 +3452,6 @@
       /* FIXME: I suspect we can eliminate the need for these - Ben */
       ap_hook_type_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
       ap_hook_access_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
  -    ap_hook_post_read_request(core_post_read_req, NULL, NULL, AP_HOOK_REALLY_FIRST);
   
       /* define the CORE filter, then register a hook to insert it at
        * request-processing time.
  
  
  
  1.138     +3 -2      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.137
  retrieving revision 1.138
  diff -u -r1.137 -r1.138
  --- http_protocol.c	2000/10/04 19:08:34	1.137
  +++ http_protocol.c	2000/10/04 23:19:33	1.138
  @@ -1244,6 +1244,7 @@
   
       r->status          = HTTP_REQUEST_TIME_OUT;  /* Until we get a request */
       r->the_request     = NULL;
  +    r->output_filters  = conn->output_filters;
   
   #ifdef APACHE_XLATE
       r->rrx = apr_pcalloc(p, sizeof(struct ap_rr_xlate));
  @@ -2108,8 +2109,8 @@
       if (r->chunked) {
           apr_table_mergen(r->headers_out, "Transfer-Encoding", "chunked");
           apr_table_unset(r->headers_out, "Content-Length");
  -        ap_add_filter("BUFFER", NULL, r);
  -        ap_add_filter("CHUNK", NULL, r);
  +        ap_add_filter("BUFFER", NULL, r, r->connection);
  +        ap_add_filter("CHUNK", NULL, r, r->connection);
       }
   
       if (r->byterange > 1) {
  
  
  
  1.25      +13 -9     apache-2.0/src/main/util_filter.c
  
  Index: util_filter.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/util_filter.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- util_filter.c	2000/10/03 00:44:00	1.24
  +++ util_filter.c	2000/10/04 23:19:33	1.25
  @@ -148,25 +148,28 @@
       }
   }
   
  -API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r)
  +API_EXPORT(void) ap_add_filter(const char *name, void *ctx, request_rec *r,
  +                               conn_rec *c)
   {
       ap_filter_rec_t *frec = registered_output_filters;
   
       for (; frec != NULL; frec = frec->next) {
           if (!strcasecmp(name, frec->name)) {
  -            ap_filter_t *f = apr_pcalloc(r->pool, sizeof(*f));
  +            apr_pool_t *p = r ? r->pool : c->pool;
  +            ap_filter_t *f = apr_pcalloc(p, sizeof(*f));
  +            ap_filter_t **outf = r ? &r->output_filters : &c->output_filters;
   
               f->frec = frec;
               f->ctx = ctx;
               f->r = r;
  -            f->c = NULL;
  +            f->c = c;
   
  -            if (INSERT_BEFORE(f, r->output_filters)) {
  -                f->next = r->output_filters;
  -                r->output_filters = f;
  +            if (INSERT_BEFORE(f, *outf)) {
  +                f->next = *outf;
  +                *outf = f;
               }
               else {
  -                ap_filter_t *fscan = r->output_filters;
  +                ap_filter_t *fscan = *outf;
                   while (!INSERT_BEFORE(f, fscan->next))
                       fscan = fscan->next;
                   f->next = fscan->next;
  @@ -201,7 +204,7 @@
   API_EXPORT(apr_status_t) ap_pass_brigade(ap_filter_t *next, ap_bucket_brigade *bb)
   {
       if (next) {
  -        if (AP_BRIGADE_LAST(bb)->type == AP_BUCKET_EOS) {
  +        if (AP_BRIGADE_LAST(bb)->type == AP_BUCKET_EOS && next->r) {
               next->r->eos_sent = 1;
           }
           return next->frec->filter_func(next, bb);
  @@ -213,12 +216,13 @@
                                           ap_bucket_brigade **b)
   {
       ap_bucket *e;
  +    apr_pool_t *p = f->r ? f->r->pool : f->c->pool;
   
       /* If have never stored any data in the filter, then we had better
        * create an empty bucket brigade so that we can concat.
        */
       if (!(*saveto)) {
  -        *saveto = ap_brigade_create(f->r->pool);
  +        *saveto = ap_brigade_create(p);
       }
       
       AP_RING_FOREACH(e, &(*b)->list, ap_bucket, link) {
  
  
  

Mime
View raw message