You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2010/09/24 13:25:25 UTC

svn commit: r1000814 - in /httpd/httpd/trunk: CHANGES server/mpm/event/event.c

Author: trawick
Date: Fri Sep 24 11:25:25 2010
New Revision: 1000814

URL: http://svn.apache.org/viewvc?rev=1000814&view=rev
Log:
Fix crash accessing pollset on worker thread when child process is exiting.

The timeout mutex and pollset were allocated from the listener thread
pool.  During child process shutdown, the listener thread exits first
while any outstanding requests finish.  These objects need to be allocated
from pchild since the lifetime extends until the last worker thread has
finished.

Switch to pchild, and move init of these objects to the same place as
other thread-independent objects.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/server/mpm/event/event.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1000814&r1=1000813&r2=1000814&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Sep 24 11:25:25 2010
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.3.9
 
+  *) Event MPM: Fix crash accessing pollset on worker thread when child
+     process is exiting.  [Jeff Trawick]
+
   *) core: For process invocation (cgi, fcgid, piped loggers and so forth)
      pass the system library path (LD_LIBRARY_PATH or platform-specific
      variables) along with the system PATH, by default.  Both should be 

Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1000814&r1=1000813&r2=1000814&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Fri Sep 24 11:25:25 2010
@@ -826,30 +826,12 @@ static apr_status_t init_pollset(apr_poo
 #if HAVE_SERF
     s_baton_t *baton = NULL;
 #endif
-    apr_status_t rv;
     ap_listen_rec *lr;
     listener_poll_type *pt;
 
-    rv = apr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_DEFAULT, p);
-    if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
-                     "creation of the timeout mutex failed.");
-        return rv;
-    }
-
     APR_RING_INIT(&timeout_head, conn_state_t, timeout_list);
     APR_RING_INIT(&keepalive_timeout_head, conn_state_t, timeout_list);
 
-    /* Create the main pollset */
-    rv = apr_pollset_create(&event_pollset,
-                            threads_per_child,
-                            p, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY);
-    if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
-                     "apr_pollset_create with Thread Safety failed.");
-        return rv;
-    }
-
     for (lr = ap_listeners; lr != NULL; lr = lr->next) {
         apr_pollfd_t *pfd = apr_palloc(p, sizeof(*pfd));
         pt = apr_pcalloc(p, sizeof(*pt));
@@ -1507,6 +1489,27 @@ static void *APR_THREAD_FUNC start_threa
         clean_child_exit(APEXIT_CHILDFATAL);
     }
 
+    /* Create the timeout mutex and main pollset before the listener
+     * thread starts.
+     */
+    rv = apr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_DEFAULT,
+                                 pchild);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
+                     "creation of the timeout mutex failed.");
+        clean_child_exit(APEXIT_CHILDFATAL);
+    }
+
+    /* Create the main pollset */
+    rv = apr_pollset_create(&event_pollset,
+                            threads_per_child,
+                            pchild, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
+                     "apr_pollset_create with Thread Safety failed.");
+        clean_child_exit(APEXIT_CHILDFATAL);
+    }
+
     worker_sockets = apr_pcalloc(pchild, threads_per_child
                                  * sizeof(apr_socket_t *));
 



Re: svn commit: r1000814 - in /httpd/httpd/trunk: CHANGES server/mpm/event/event.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Wed, Oct 13, 2010 at 1:37 AM, William A. Rowe Jr.
<wr...@rowe-clan.net> wrote:
> On 10/12/2010 4:22 PM, Jeff Trawick wrote:
>>
>> Someone mentioned using 2.2 event in production on the list,today or
>> yesterday, so I peeked at 2.2 and this bug appears to affect it.  Any
>> interest out there in seeing what it takes to backport?  (away from
>> working env until tonight; dunno when wrowe is going to T&R; dunno if
>> anyone cares)
>
> 2.0 docs/manual/ build.sh all (and build.bat all) is still giving me hassle,
> so let me know what you want to do with this.

Nobody spoke up as caring so far, so ignore it for your purposes.
There's always another one if I don't get a chance to play with 2.2.

Re: svn commit: r1000814 - in /httpd/httpd/trunk: CHANGES server/mpm/event/event.c

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 10/12/2010 4:22 PM, Jeff Trawick wrote:
> 
> Someone mentioned using 2.2 event in production on the list,today or
> yesterday, so I peeked at 2.2 and this bug appears to affect it.  Any
> interest out there in seeing what it takes to backport?  (away from
> working env until tonight; dunno when wrowe is going to T&R; dunno if
> anyone cares)

2.0 docs/manual/ build.sh all (and build.bat all) is still giving me hassle,
so let me know what you want to do with this.

Re: svn commit: r1000814 - in /httpd/httpd/trunk: CHANGES server/mpm/event/event.c

Posted by Greg Ames <am...@gmail.com>.
On Tue, Oct 12, 2010 at 5:22 PM, Jeff Trawick <tr...@gmail.com> wrote:

>
> Someone mentioned using 2.2 event in production on the list,today or
> yesterday, so I peeked at 2.2 and this bug appears to affect it.  Any
> interest out there in seeing what it takes to backport?
>

yes, I'd like to see it fixed on 2.2.

Greg

Re: svn commit: r1000814 - in /httpd/httpd/trunk: CHANGES server/mpm/event/event.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Fri, Sep 24, 2010 at 7:25 AM,  <tr...@apache.org> wrote:
> Author: trawick
> Date: Fri Sep 24 11:25:25 2010
> New Revision: 1000814
>
> URL: http://svn.apache.org/viewvc?rev=1000814&view=rev
> Log:
> Fix crash accessing pollset on worker thread when child process is exiting.
>
> The timeout mutex and pollset were allocated from the listener thread
> pool.  During child process shutdown, the listener thread exits first
> while any outstanding requests finish.  These objects need to be allocated
> from pchild since the lifetime extends until the last worker thread has
> finished.
>
> Switch to pchild, and move init of these objects to the same place as
> other thread-independent objects.

Someone mentioned using 2.2 event in production on the list,today or
yesterday, so I peeked at 2.2 and this bug appears to affect it.  Any
interest out there in seeing what it takes to backport?  (away from
working env until tonight; dunno when wrowe is going to T&R; dunno if
anyone cares)