apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwool...@apache.org
Subject cvs commit: apr-util/include apr_buckets.h
Date Thu, 28 Aug 2003 02:09:52 GMT
jwoolley    2003/08/27 19:09:52

  Modified:    .        CHANGES
               buckets  apr_brigade.c apr_buckets_alloc.c
               include  apr_buckets.h
  Log:
  bucket debugging.  a series of consistency checks for bucket brigades.
  
  to enable, define APR_BUCKET_DEBUG at compile time.  it was suggested that
  I should have a --enable-bucket-debug configure option instead, but because
  of the way we use APR's rules.mk, it's difficult to add extra CPPFLAGS from
  apr-util's configure.in.
  
  Revision  Changes    Path
  1.116     +4 -0      apr-util/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-util/CHANGES,v
  retrieving revision 1.115
  retrieving revision 1.116
  diff -u -d -u -r1.115 -r1.116
  --- CHANGES	8 Jul 2003 17:54:32 -0000	1.115
  +++ CHANGES	28 Aug 2003 02:09:52 -0000	1.116
  @@ -1,5 +1,9 @@
   Changes with APR-util 0.9.4
   
  +  *) Added debugging consistency checks to the buckets code.  Add
  +     -DAPR_BUCKET_DEBUG to the build flags to enable.
  +     [Cliff Woolley]
  +
     *) Make the version of the db library APU built against visible.
        [Thom May]
   
  
  
  
  1.58      +6 -0      apr-util/buckets/apr_brigade.c
  
  Index: apr_brigade.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_brigade.c,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -d -u -r1.57 -r1.58
  --- apr_brigade.c	1 Jan 2003 00:02:17 -0000	1.57
  +++ apr_brigade.c	28 Aug 2003 02:09:52 -0000	1.58
  @@ -127,6 +127,10 @@
           APR_RING_UNSPLICE(e, f, link);
           APR_RING_SPLICE_HEAD(&a->list, e, f, apr_bucket, link);
       }
  +
  +    APR_BRIGADE_CHECK_CONSISTENCY(a);
  +    APR_BRIGADE_CHECK_CONSISTENCY(b);
  +
       return a;
   }
   
  @@ -147,6 +151,8 @@
           *after_point = APR_BRIGADE_FIRST(b);
           return APR_SUCCESS;
       }
  +
  +    APR_BRIGADE_CHECK_CONSISTENCY(b);
   
       APR_BRIGADE_FOREACH(e, b) {
           if ((e->length == (apr_size_t)(-1)) && (point > (apr_size_t)(-1)))
{
  
  
  
  1.12      +21 -0     apr-util/buckets/apr_buckets_alloc.c
  
  Index: apr_buckets_alloc.c
  ===================================================================
  RCS file: /home/cvs/apr-util/buckets/apr_buckets_alloc.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -d -u -r1.11 -r1.12
  --- apr_buckets_alloc.c	2 Jul 2003 06:35:59 -0000	1.11
  +++ apr_buckets_alloc.c	28 Aug 2003 02:09:52 -0000	1.12
  @@ -151,12 +151,33 @@
       return ((char *)node) + SIZEOF_NODE_HEADER_T;
   }
   
  +#ifdef APR_BUCKET_DEBUG
  +#if APR_HAVE_STDLIB_H
  +#include <stdlib.h>
  +#endif
  +static void check_not_already_free(node_header_t *node)
  +{
  +    apr_bucket_alloc_t *list = node->alloc;
  +    node_header_t *curr = list->freelist;
  +
  +    while (curr) {
  +        if (node == curr) {
  +            abort();
  +        }
  +        curr = curr->next;
  +    }
  +}
  +#else
  +#define check_not_already_free(node)
  +#endif
  +
   APU_DECLARE_NONSTD(void) apr_bucket_free(void *mem)
   {
       node_header_t *node = (node_header_t *)((char *)mem - SIZEOF_NODE_HEADER_T);
       apr_bucket_alloc_t *list = node->alloc;
   
       if (node->size == SMALL_NODE_SIZE) {
  +        check_not_already_free(node);
           node->next = list->freelist;
           list->freelist = node;
       }
  
  
  
  1.153     +47 -4     apr-util/include/apr_buckets.h
  
  Index: apr_buckets.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_buckets.h,v
  retrieving revision 1.152
  retrieving revision 1.153
  diff -u -d -u -r1.152 -r1.153
  --- apr_buckets.h	2 Jul 2003 06:35:59 -0000	1.152
  +++ apr_buckets.h	28 Aug 2003 02:09:52 -0000	1.153
  @@ -59,6 +59,10 @@
   #ifndef APR_BUCKETS_H
   #define APR_BUCKETS_H
   
  +#if defined(APR_BUCKET_DEBUG) && !defined(APR_RING_DEBUG)
  +#define APR_RING_DEBUG
  +#endif
  +
   #include "apu.h"
   #include "apr_network_io.h"
   #include "apr_file_io.h"
  @@ -315,6 +319,37 @@
    */
   typedef apr_status_t (*apr_brigade_flush)(apr_bucket_brigade *bb, void *ctx);
   
  +/*
  + * define APR_BUCKET_DEBUG if you want your brigades to be checked for
  + * validity at every possible instant.  this will slow your code down
  + * substantially but is a very useful debugging tool.
  + */
  +#ifdef APR_BUCKET_DEBUG
  +
  +#define APR_BRIGADE_CHECK_CONSISTENCY(b)				\
  +        APR_RING_CHECK_CONSISTENCY(&(b)->list, apr_bucket, link)
  +
  +#define APR_BUCKET_CHECK_CONSISTENCY(e)					\
  +        APR_RING_CHECK_ELEM_CONSISTENCY((e), apr_bucket, link)
  +
  +#else
  +/**
  + * checks the ring pointers in a bucket brigade for consistency.  an
  + * abort() will be triggered if any inconsistencies are found.
  + *   note: this is a no-op unless APR_BUCKET_DEBUG is defined.
  + * @param b The brigade
  + */
  +#define APR_BRIGADE_CHECK_CONSISTENCY(b)
  +/**
  + * checks the brigade a bucket is in for ring consistency.  an
  + * abort() will be triggered if any inconsistencies are found.
  + *   note: this is a no-op unless APR_BUCKET_DEBUG is defined.
  + * @param e The bucket
  + */
  +#define APR_BUCKET_CHECK_CONSISTENCY(e)
  +#endif
  +
  +
   /**
    * Wrappers around the RING macros to reduce the verbosity of the code
    * that handles bucket brigades.
  @@ -405,6 +440,7 @@
   #define APR_BRIGADE_INSERT_HEAD(b, e) do {				\
   	apr_bucket *ap__b = (e);                                        \
   	APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link);	\
  +        APR_BRIGADE_CHECK_CONSISTENCY((b));				\
       } while (0)
   
   /**
  @@ -415,6 +451,7 @@
   #define APR_BRIGADE_INSERT_TAIL(b, e) do {				\
   	apr_bucket *ap__b = (e);					\
   	APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link);	\
  +        APR_BRIGADE_CHECK_CONSISTENCY((b));				\
       } while (0)
   
   /**
  @@ -422,16 +459,20 @@
    * @param a The first brigade
    * @param b The second brigade
    */
  -#define APR_BRIGADE_CONCAT(a, b)					\
  -	APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link)
  +#define APR_BRIGADE_CONCAT(a, b) do {					\
  +        APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link);	\
  +        APR_BRIGADE_CHECK_CONSISTENCY((a));				\
  +    } while (0)
   
   /**
    * Prepend brigade b onto the beginning of brigade a, leaving brigade b empty
    * @param a The first brigade
    * @param b The second brigade
    */
  -#define APR_BRIGADE_PREPEND(a, b)					\
  -	APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link)
  +#define APR_BRIGADE_PREPEND(a, b) do {					\
  +        APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link);	\
  +        APR_BRIGADE_CHECK_CONSISTENCY((a));				\
  +    } while (0)
   
   /**
    * Insert a list of buckets before a specified bucket
  @@ -441,6 +482,7 @@
   #define APR_BUCKET_INSERT_BEFORE(a, b) do {				\
   	apr_bucket *ap__a = (a), *ap__b = (b);				\
   	APR_RING_INSERT_BEFORE(ap__a, ap__b, link);			\
  +        APR_BUCKET_CHECK_CONSISTENCY(ap__a);				\
       } while (0)
   
   /**
  @@ -451,6 +493,7 @@
   #define APR_BUCKET_INSERT_AFTER(a, b) do {				\
   	apr_bucket *ap__a = (a), *ap__b = (b);				\
   	APR_RING_INSERT_AFTER(ap__a, ap__b, link);			\
  +        APR_BUCKET_CHECK_CONSISTENCY(ap__a);				\
       } while (0)
   
   /**
  
  
  

Mime
View raw message