Uhhh... the patch :|

----- Original Message ----- 
From: "William A. Rowe, Jr." <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, August 02, 2001 3:17 PM
Subject: Does anyone want this committed?


> Pipe 'names' for debugging patch attached.
> 
> Three issues,i
> 
> 1. the stack exception code doesn't work on NT.   In fact, I doubt it ever 
> works for
> threading.  Pulling _just_that_ alone should help debug on threaded 
> architechtures.
> 
> The better solution is to build a 'list of stacks'.  The _end symbol is a 
> pita, we
> need autoconf/libtoolers to figure out that _end exists to define HAVE__END.
> 
> 2. I can't figure out how to stringize __LINE__, which sort of sucks.
> 
> 3. I really didn't like breaking the semantics and sometimes passing the 
> extra hidden
> 'name' argument, and sometimes not.  I figured the overhead of an extra NULL 
> arg on
> some rarely called function is a trivial issue.
> 
> If you like this, yell :)
> 
> Bill
> 
> 
> 
Index: srclib/apr/memory/unix/apr_pools.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
retrieving revision 1.106
diff -u -r1.106 apr_pools.c
--- srclib/apr/memory/unix/apr_pools.c  2001/08/02 05:24:42     1.106
+++ srclib/apr/memory/unix/apr_pools.c  2001/08/02 20:14:50
@@ -105,6 +105,10 @@
 #include <malloc.h>
 #endif
 
+#undef apr_pool_alloc_init
+#undef apr_pool_create
+#undef apr_pool_sub_make
+
 /* Details of the debugging options can now be found in the developer
  * section of the documentaion.
  * ### gjs: where the hell is that?
@@ -199,6 +203,7 @@
 #endif
 #ifdef APR_POOL_DEBUG
     /** a list of joined pools */
+    const char *created;
     struct apr_pool_t *joined;
 #endif
     /** A function to control how pools behave when they receive ENOMEM */
@@ -582,12 +587,12 @@
 
 APR_DECLARE(void) apr_pool_sub_make(apr_pool_t **p,
                                     apr_pool_t *parent,
-                                    apr_abortfunc_t abortfunc)
+                                    apr_abortfunc_t abortfunc,
+                                    const char *created)
 {
     union block_hdr *blok;
     apr_pool_t *new_pool;
 
-
 #if APR_HAS_THREADS
     if (alloc_mutex) {
         apr_lock_acquire(alloc_mutex);
@@ -597,11 +602,14 @@
     blok = new_block(POOL_HDR_BYTES, abortfunc);
     new_pool = (apr_pool_t *) blok->h.first_avail;
     blok->h.first_avail += POOL_HDR_BYTES;
+
+    memset((char *) new_pool, '\0', sizeof(struct apr_pool_t));
+
 #ifdef APR_POOL_DEBUG
     blok->h.owning_pool = new_pool;
+    new_pool->created = created;
 #endif
 
-    memset((char *) new_pool, '\0', sizeof(struct apr_pool_t));
     new_pool->free_first_avail = blok->h.first_avail;
     new_pool->first = new_pool->last = blok;
 
@@ -655,13 +663,14 @@
 
 /* ### why do we have this, in addition to apr_pool_sub_make? */
 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newpool,
-                                          apr_pool_t *parent_pool)
+                                          apr_pool_t *parent_pool,
+                                          const char *created)
 {
     apr_abortfunc_t abortfunc;
 
     abortfunc = parent_pool ? parent_pool->apr_abort : NULL;
 
-    apr_pool_sub_make(newpool, parent_pool, abortfunc);
+    apr_pool_sub_make(newpool, parent_pool, abortfunc, created);
     if (*newpool == NULL) {
         return APR_ENOPOOL;
     }   
@@ -811,7 +820,8 @@
     return APR_SUCCESS;
 }
 
-APR_DECLARE(apr_status_t) apr_pool_alloc_init(apr_pool_t *globalp)
+APR_DECLARE(apr_status_t) apr_pool_alloc_init(apr_pool_t *globalp, 
+                                              const char *created)
 {
 #if APR_HAS_THREADS
     apr_status_t status;
@@ -836,7 +846,7 @@
         return status;
     }
 #endif
-    apr_pool_sub_make(&permanent_pool, globalp, NULL);
+    apr_pool_sub_make(&permanent_pool, globalp, NULL, created);
 
 #ifdef ALLOC_STATS
     atexit(dump_stats);
Index: srclib/apr/include/apr_pools.h
===================================================================
RCS file: /home/cvs/apr/include/apr_pools.h,v
retrieving revision 1.55
diff -u -r1.55 apr_pools.h
--- srclib/apr/include/apr_pools.h      2001/08/02 05:24:42     1.55
+++ srclib/apr/include/apr_pools.h      2001/08/02 20:14:51
@@ -207,9 +207,18 @@
  * @remark Programs do NOT need to call this directly.  APR will call this
  *      automatically from apr_initialize. 
  * @internal
+ * @deffunc apr_status_t apr_pool_alloc_init(apr_pool_t *globalp)
  */
-APR_DECLARE(apr_status_t) apr_pool_alloc_init(apr_pool_t *globalp);
+APR_DECLARE(apr_status_t) apr_pool_alloc_init(apr_pool_t *globalp, const char 
* created);
 
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_alloc_init(p) \
+    (apr_pool_alloc_init)(p, #p " " __FILE__)
+#else
+#define apr_pool_alloc_init(p) \
+    (apr_pool_alloc_init)(p, NULL)
+#endif
+
 /**
  * Tear down all of the internal structures required to use pools
  * @param globalp The APR global pool, used to allocate APR structures
@@ -230,9 +239,19 @@
  *        pool.  If it is non-NULL, the new pool will inherit all
  *        of it's parent pool's attributes, except the apr_pool_t will 
  *        be a sub-pool.
+ * @deffunc apr_status_t apr_pool_create(apr_pool_t **newcont, apr_pool_t 
*cont)
  */
 APR_DECLARE(apr_status_t) apr_pool_create(apr_pool_t **newcont,
-                                          apr_pool_t *cont);
+                                          apr_pool_t *cont,
+                                          const char *created);
+
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_create(p, pp) \
+    (apr_pool_create)(p, pp, #p " " __FILE__)
+#else
+#define apr_pool_create(p, pp) \
+    (apr_pool_create)(p, pp, NULL)
+#endif
 
 #if !defined(APR_POOLS_ARE_SMS) || defined(DOXYGEN)
 /**
@@ -329,6 +348,7 @@
 #endif /* !APR_POOLS_ARE_SMS || DOXYGEN */
 
 /**
+ * Make a sub pool from the current pool
  * @param p The new sub-pool
  * @param parent The pool to use as a parent pool
  * @param apr_abort A function to use if the pool cannot allocate more memory.
@@ -336,9 +356,18 @@
  * @remark The @a apr_abort function provides a way to quit the program if the
  *      machine is out of memory.  By default, APR will return on error.
  */
-APR_DECLARE(void) apr_pool_sub_make(apr_pool_t **p, 
-                                            apr_pool_t *pparent,
-                                            int (*apr_abort)(int retcode));
+APR_DECLARE(void) apr_pool_sub_make(apr_pool_t **p,
+                                    apr_pool_t *parent,
+                                    int (*apr_abort)(int retcode),
+                                    const char *created);
+
+#if defined(APR_POOL_DEBUG)
+#define apr_pool_sub_make(p, pp, abort) \
+    (apr_pool_sub_make)(p, pp, abort, #p " " __FILE__)
+#else
+#define apr_pool_sub_make(p, pp, abort) \
+    (apr_pool_sub_make)(p, pp, abort, NULL)
+#endif
 
 #if defined(APR_POOL_DEBUG) || defined(DOXYGEN) 
 /**

Reply via email to