You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2003/06/30 23:59:32 UTC

cvs commit: httpd-apreq-2/env mod_apreq.c

joes        2003/06/30 14:59:32

  Modified:    env      mod_apreq.c
  Log:
  Be sure filter->ctx is non-NULL before using it in a prefetch read.
  
  Revision  Changes    Path
  1.19      +19 -16    httpd-apreq-2/env/mod_apreq.c
  
  Index: mod_apreq.c
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/env/mod_apreq.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- mod_apreq.c	30 Jun 2003 20:42:14 -0000	1.18
  +++ mod_apreq.c	30 Jun 2003 21:59:32 -0000	1.19
  @@ -209,6 +209,23 @@
       return c->req;
   }
   
  +APR_INLINE
  +static void apreq_filter_make_context(ap_filter_t *f)
  +{
  +    request_rec *r = f->r;
  +    apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(r->pool);
  +    struct filter_ctx *ctx = apr_palloc(r->pool, sizeof *ctx);
  +    f->ctx      = ctx;
  +    ctx->bb     = apr_brigade_create(r->pool, alloc);
  +    ctx->spool  = apr_brigade_create(r->pool, alloc);
  +    ctx->bytes_seen = 0;
  +    ctx->status = APR_INCOMPLETE;
  +    ctx->mode = AP_MODE_SPECULATIVE;
  +
  +    apreq_log(APREQ_DEBUG 0, r, 
  +              "apreq filter context created." );    
  +}
  +
   /**
    * Reads data directly into the parser.
    *@bug  This function is badly broken.  It needs to use
  @@ -226,27 +243,13 @@
   
       if (f == NULL)
           return APR_NOTFOUND;
  +    if (f->ctx == NULL)
  +        apreq_filter_make_context(f);
       ctx = f->ctx;
   
       return ap_get_brigade(f, NULL, ctx->mode, block, bytes);
   }
   
  -APR_INLINE
  -static void apreq_filter_make_context(ap_filter_t *f)
  -{
  -    request_rec *r = f->r;
  -    apr_bucket_alloc_t *alloc = apr_bucket_alloc_create(r->pool);
  -    struct filter_ctx *ctx = apr_palloc(r->pool, sizeof *ctx);
  -    f->ctx      = ctx;
  -    ctx->bb     = apr_brigade_create(r->pool, alloc);
  -    ctx->spool  = apr_brigade_create(r->pool, alloc);
  -    ctx->bytes_seen = 0;
  -    ctx->status = APR_INCOMPLETE;
  -    ctx->mode = AP_MODE_SPECULATIVE;
  -
  -    apreq_log(APREQ_DEBUG 0, r, 
  -              "apreq filter context created." );    
  -}
   
   APR_INLINE
   static void apreq_filter_relocate(ap_filter_t *f)