This is in reference to my previous e-mail regarding Solaris and an EOF when reading from apr_proc_create'd processes. I narrowed this down to another problem I had experienced with apr_thread_exit.

There are a few places where we're doing things to pools from threads who don't "own" the given pool, thereby causing the apr_pool_check_integrity to fail horrible when debugging. For example, in apr_thread_exit (we call apr_pool_destroy on the pool we created in apr_pool_create) Another example is in apr_proc_create, where we call apr_pool_cleanup_kill to remove some apr_file_t cleanups.

I checked the docs and at one point there seemed to have been the desire to include an apr_pool_owner_set (just grep, it's only mentioned once in the source) So here's a patch that implements the apr_pool_owner_set function and places calls to fix the above mentioned problems. The reason for the EOF was such that the child process would simply abort (with no messages because stdout and such had been redirected) Things worked fine under Linux because of the way thread ID's are assigned, I would guess. Fire away.

--
jacob lewallen
[EMAIL PROTECTED]
Index: include/apr_pools.h
===================================================================
RCS file: /home/cvspublic/apr/include/apr_pools.h,v
retrieving revision 1.103
diff -u -r1.103 apr_pools.h
--- include/apr_pools.h 11 Mar 2003 20:02:06 -0000      1.103
+++ include/apr_pools.h 10 Jul 2003 17:26:32 -0000
@@ -293,6 +293,12 @@
 APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
 
 /**
+ * Sets the owner of the given pool to the current thread.
+ * @param pool The pool to set the owner of.
+ */
+APR_DECLARE(void) apr_pool_owner_set(apr_pool_t *pool);
+
+/**
  * Clear all memory in the pool and run all the cleanups. This also destroys 
all
  * subpools.
  * @param p The pool to clear
Index: memory/unix/apr_pools.c
===================================================================
RCS file: /home/cvspublic/apr/memory/unix/apr_pools.c,v
retrieving revision 1.196
diff -u -r1.196 apr_pools.c
--- memory/unix/apr_pools.c     28 May 2003 04:39:42 -0000      1.196
+++ memory/unix/apr_pools.c     10 Jul 2003 17:26:32 -0000
@@ -2022,6 +2022,13 @@
     return APR_SUCCESS;
 }
 
+APR_DECLARE(void) apr_pool_owner_set(apr_pool_t *pool)
+{
+#if APR_HAS_THREADS
+    pool->owner = apr_os_thread_current();
+#endif /* APR_HAS_THREADS */
+}
+
 /* Subprocesses don't use the generic cleanup interface because
  * we don't want multiple subprocesses to result in multiple
  * three-second pauses; the subprocesses have to be "freed" all
Index: threadproc/unix/proc.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/unix/proc.c,v
retrieving revision 1.67
diff -u -r1.67 proc.c
--- threadproc/unix/proc.c      8 May 2003 08:51:02 -0000       1.67
+++ threadproc/unix/proc.c      10 Jul 2003 17:26:32 -0000
@@ -369,16 +369,19 @@
          */
 
         if (attr->child_in) {
+            apr_pool_owner_set(apr_file_pool_get(attr->child_in));
             apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in),
                                   attr->child_in, apr_unix_file_cleanup);
         }
 
         if (attr->child_out) {
+            apr_pool_owner_set(apr_file_pool_get(attr->child_out));
             apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out),
                                   attr->child_out, apr_unix_file_cleanup);
         }
 
         if (attr->child_err) {
+            apr_pool_owner_set(apr_file_pool_get(attr->child_err));
             apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err),
                                   attr->child_err, apr_unix_file_cleanup);
         }
Index: threadproc/unix/thread.c
===================================================================
RCS file: /home/cvspublic/apr/threadproc/unix/thread.c,v
retrieving revision 1.54
diff -u -r1.54 thread.c
--- threadproc/unix/thread.c    6 Jan 2003 23:44:38 -0000       1.54
+++ threadproc/unix/thread.c    10 Jul 2003 17:26:32 -0000
@@ -124,6 +124,7 @@
 static void *dummy_worker(void *opaque)
 {
     apr_thread_t *thread = (apr_thread_t*)opaque;
+    apr_pool_owner_set(thread->pool);
     return thread->func(thread, thread->data);
 }
 

Reply via email to