apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: apr-util/buckets apr_buckets.c apr_buckets_eos.c apr_buckets_flush.c apr_buckets_heap.c apr_buckets_simple.c
Date Thu, 07 Jun 2001 10:13:43 GMT
gstein      01/06/07 03:13:43

  Modified:    server   util_filter.c
               include  apr_buckets.h
               buckets  apr_buckets.c apr_buckets_eos.c apr_buckets_flush.c
                        apr_buckets_heap.c apr_buckets_simple.c
  Log:
  *) Add apr_bucket_setaside_noop to use for buckets that do not require a
     setaside function. It simply returns APR_SUCCESS.
     - adjust the EOS, FLUSH, IMMORTAL, and HEAP buckets to use _noop.
  
  *) Make the setaside() function take a pool to define the (new) lifetime for
     the bucket's data.
     - Adjust the apr_bucket_setaside() macro.
     - Adjust the apr_bucket_setaside_notimpl() and transient_setaside()
       functions.
     - Pass the additional parameter in ap_save_brigade()
  
  *) Update docs for setaside()
  
  *) Minor nit with macros in apr_buckets.h: add parens for binding safety.
  
  Revision  Changes    Path
  1.59      +7 -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.58
  retrieving revision 1.59
  diff -u -u -r1.58 -r1.59
  --- util_filter.c	2001/05/06 23:27:13	1.58
  +++ util_filter.c	2001/06/07 10:13:25	1.59
  @@ -248,6 +248,8 @@
                                            apr_bucket_brigade **b)
   {
       apr_bucket *e;
  +    /* ### this pool should be passed in; the caller is the only one who
  +       ### really knows what the proper lifetime is for this pool. */
       apr_pool_t *p = f->r ? f->r->pool : f->c->pool;
       apr_status_t rv;
   
  @@ -259,8 +261,11 @@
       }
       
       APR_RING_FOREACH(e, &(*b)->list, apr_bucket, link) {
  -        rv = apr_bucket_setaside(e);
  -        if (rv != APR_SUCCESS && rv != APR_ENOTIMPL) {
  +        rv = apr_bucket_setaside(e, p);
  +        if (rv != APR_SUCCESS
  +            /* ### this ENOTIMPL will go away once we implement setaside
  +               ### for all bucket types. */
  +            && rv != APR_ENOTIMPL) {
               return rv;
           }
       }
  
  
  
  1.95      +33 -12    apr-util/include/apr_buckets.h
  
  Index: apr_buckets.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -u -r1.94 -r1.95
  --- apr_buckets.h	2001/04/11 19:07:10	1.94
  +++ apr_buckets.h	2001/06/07 10:13:30	1.95
  @@ -177,14 +177,20 @@
       apr_status_t (*read)(apr_bucket *b, const char **str, apr_size_t *len, apr_read_type_e
block);
       
       /**
  -     * Make it possible to set aside the data. Buckets containing data that
  -     *  dies when the stack is un-wound must convert the bucket into a heap
  -     *  bucket. For most bucket types, though, this is a no-op and this
  -     *  function will return APR_ENOTIMPL.
  +     * Make it possible to set aside the data for at least as long as the
  +     *  given pool. Buckets containing data that could potentially die before
  +     *  this pool (e.g. the data resides on the stack, in a child pool of
  +     *  the given pool, or in a disjoint pool) must somehow copy, shift, or
  +     *  transform the data to have the proper lifetime.
        * @param e The bucket to convert
        * @deffunc apr_status_t setaside(apr_bucket *e)
  +     * @tip Some bucket types contain data that will always outlive the
  +     *      bucket itself. For example no data (EOS and FLUSH), or the data
  +     *      resides in global, constant memory (IMMORTAL), or the data is on
  +     *      the heap (HEAP). For these buckets, apr_bucket_setaside_noop can
  +     *      be used.
        */
  -    apr_status_t (*setaside)(apr_bucket *e);
  +    apr_status_t (*setaside)(apr_bucket *e, apr_pool_t *pool);
   
       /**
        * Split one bucket in two at the specified position by duplicating
  @@ -761,7 +767,7 @@
    * @deffunc void apr_bucket_destroy(apr_bucket *e)
    */
   #define apr_bucket_destroy(e) do {					\
  -        e->type->destroy(e->data);					\
  +        (e)->type->destroy((e)->data);					\
           free(e);							\
       } while (0)
   
  @@ -790,7 +796,7 @@
    * @param block Whether the read function blocks
    * @deffunc apr_status_t apr_bucket_read(apr_bucket *e, const char **str, apr_size_t *len,
apr_read_type_e block)
    */
  -#define apr_bucket_read(e,str,len,block) e->type->read(e, str, len, block)
  +#define apr_bucket_read(e,str,len,block) (e)e->type->read(e, str, len, block)
   
   /**
    * Setaside data so that stack data is not destroyed on returning from
  @@ -798,7 +804,7 @@
    * @param e The bucket to setaside
    * @deffunc apr_status_t apr_bucket_setaside(apr_bucket *e)
    */
  -#define apr_bucket_setaside(e) e->type->setaside(e)
  +#define apr_bucket_setaside(e,p) (e)->type->setaside(e,p)
   
   /**
    * Split one bucket in two.
  @@ -806,7 +812,7 @@
    * @param point The offset to split the bucket at
    * @deffunc apr_status_t apr_bucket_split(apr_bucket *e, apr_off_t point)
    */
  -#define apr_bucket_split(e,point) e->type->split(e, point)
  +#define apr_bucket_split(e,point) (e)->type->split(e, point)
   
   /**
    * Copy a bucket.
  @@ -814,18 +820,33 @@
    * @param c Returns a pointer to the new bucket
    * @deffunc apr_status_t apr_bucket_copy(apr_bucket *e, apr_bucket **c)
    */
  -#define apr_bucket_copy(e,c) e->type->copy(e, c)
  +#define apr_bucket_copy(e,c) (e)->type->copy(e, c)
   
   /* Bucket type handling */
   
   /**
  + * This function simply returns APR_SUCCESS to denote that the bucket does
  + * not require anything to happen for its setaside() function. This is
  + * appropriate for buckets that have "immortal" data -- the data will live
  + * at least as long as the bucket.
  + * @param data The bucket to setaside
  + * @param pool The pool defining the desired lifetime of the bucket data
  + * @return APR_SUCCESS
  + * @deffunc apr_status_t apr_bucket_setaside_notimpl(apr_bucket *data, apr_pool_t *pool)
  + */ 
  +APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data,
  +                                                          apr_pool_t *pool);
  +
  +/**
    * A place holder function that signifies that the setaside function was not
    * implemented for this bucket
    * @param data The bucket to setaside
  + * @param pool The pool defining the desired lifetime of the bucket data
    * @return APR_ENOTIMPL
  - * @deffunc apr_status_t apr_bucket_setaside_notimpl(apr_bucket *data)
  + * @deffunc apr_status_t apr_bucket_setaside_notimpl(apr_bucket *data, apr_pool_t *pool)
    */ 
  -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data);
  +APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data,
  +                                                             apr_pool_t *pool);
   
   /**
    * A place holder function that signifies that the split function was not
  
  
  
  1.50      +8 -1      apr-util/buckets/apr_buckets.c
  
  Index: apr_buckets.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -u -r1.49 -r1.50
  --- apr_buckets.c	2001/02/28 04:41:14	1.49
  +++ apr_buckets.c	2001/06/07 10:13:33	1.50
  @@ -54,7 +54,14 @@
   
   #include "apr_buckets.h"
   
  -APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data)
  +APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data,
  +                                                          apr_pool_t *pool)
  +{
  +    return APR_SUCCESS;
  +}
  +
  +APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data,
  +                                                             apr_pool_t *pool)
   {
       return APR_ENOTIMPL;
   }
  
  
  
  1.24      +1 -1      apr-util/buckets/apr_buckets_eos.c
  
  Index: apr_buckets_eos.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_eos.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -u -r1.23 -r1.24
  --- apr_buckets_eos.c	2001/04/11 19:07:03	1.23
  +++ apr_buckets_eos.c	2001/06/07 10:13:34	1.24
  @@ -91,7 +91,7 @@
       "EOS", 5,
       apr_bucket_destroy_notimpl,
       eos_read,
  -    apr_bucket_setaside_notimpl,
  +    apr_bucket_setaside_noop,
       apr_bucket_split_notimpl,
       eos_copy
   };
  
  
  
  1.16      +1 -1      apr-util/buckets/apr_buckets_flush.c
  
  Index: apr_buckets_flush.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_flush.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -u -r1.15 -r1.16
  --- apr_buckets_flush.c	2001/04/11 19:07:04	1.15
  +++ apr_buckets_flush.c	2001/06/07 10:13:35	1.16
  @@ -91,7 +91,7 @@
       "FLUSH", 5,
       apr_bucket_destroy_notimpl,
       flush_read,
  -    apr_bucket_setaside_notimpl,
  +    apr_bucket_setaside_noop,
       apr_bucket_split_notimpl,
       flush_copy
   };
  
  
  
  1.33      +1 -1      apr-util/buckets/apr_buckets_heap.c
  
  Index: apr_buckets_heap.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_heap.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -u -r1.32 -r1.33
  --- apr_buckets_heap.c	2001/05/21 19:14:33	1.32
  +++ apr_buckets_heap.c	2001/06/07 10:13:36	1.33
  @@ -127,7 +127,7 @@
       "HEAP", 5,
       heap_destroy,
       heap_read,
  -    apr_bucket_setaside_notimpl,
  +    apr_bucket_setaside_noop,
       apr_bucket_shared_split,
       apr_bucket_shared_copy
   };
  
  
  
  1.27      +2 -2      apr-util/buckets/apr_buckets_simple.c
  
  Index: apr_buckets_simple.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_simple.c,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -u -r1.26 -r1.27
  --- apr_buckets_simple.c	2001/04/11 19:07:06	1.26
  +++ apr_buckets_simple.c	2001/06/07 10:13:37	1.27
  @@ -127,7 +127,7 @@
    * function that co-ordinates the action of all the bucket setaside
    * functions to improve memory efficiency.
    */
  -static apr_status_t transient_setaside(apr_bucket *b)
  +static apr_status_t transient_setaside(apr_bucket *b, apr_pool_t *pool)
   {
       b = apr_bucket_heap_make(b, (char *)b->data + b->start, b->length, 1, NULL);
       if (b == NULL) {
  @@ -159,7 +159,7 @@
       "IMMORTAL", 5,
       apr_bucket_destroy_notimpl,
       simple_read,
  -    apr_bucket_setaside_notimpl,
  +    apr_bucket_setaside_noop,
       apr_bucket_simple_split,
       apr_bucket_simple_copy
   };
  
  
  

Mime
View raw message