Bug 52196

Summary: winnt mpm, others mpm also have this bug. pool shared by mulit-thread.
Product: Apache httpd-2 Reporter: zhiguo zhao <zhaozg>
Component: mpm_winntAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEEDINFO ---    
Severity: normal    
Priority: P2    
Version: 2.4-HEAD   
Target Milestone: ---   
Hardware: All   
OS: All   

Description zhiguo zhao 2011-11-16 12:45:52 UTC
request_rec->connection->current_thread is a new feature, 
and every request_rec->connection->current_thread should have different pool, but now with a same pool,

This is need to fix.

I fix this, Please see below
---------------------------------------------------
===================================================================
--- mpm/winnt/child.c   (版本 1202642)
+++ mpm/winnt/child.c   (工作副本)
@@ -754,9 +754,11 @@
     int rc;
     conn_rec *c;
     apr_int32_t disconnected;
+    apr_pool_t* self;

     osthd = apr_os_thread_current();
-    apr_os_thread_put(&thd, &osthd, pchild);
+    apr_pool_create(&self,pchild);
+    apr_os_thread_put(&thd, &osthd, self);

     while (1) {

@@ -858,6 +860,7 @@

     ap_update_child_status_from_indexes(0, thread_num, SERVER_DEAD,
                                         (request_rec *) NULL);
+    apr_pool_destroy(self);

     return 0;
 }
Comment 1 Jeff Trawick 2012-08-19 21:50:42 UTC
This appears to affect all MPMs.
The limitation is that certain APR thread functions can't be used, as the pool is shared between threads.
mod_lua in particular has a method to retrieve the pool of the thread, which would always be pchild (almost certainly not what the caller expected).
Comment 2 Jeff Trawick 2012-08-19 22:43:23 UTC
I had already noticed a thread-safety issue in the WinNT MPM code you modified, and the fix for that solves the problem you reported for this MPM without creating another pool.  (The code you posted didn't fix the thread-safety issue.)

Here is that revision:

http://svn.apache.org/viewvc?view=revision&revision=1374874

In order to justify changing the other MPMs for this problem report, I suggest that you add a comment describing the problem you face because the apr_thread_t structures are not associated with unique pools.  Thanks!