httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yla...@apache.org
Subject svn commit: r1783810 - /httpd/httpd/trunk/server/mpm/motorz/motorz.c
Date Mon, 20 Feb 2017 22:50:56 GMT
Author: ylavic
Date: Mon Feb 20 22:50:56 2017
New Revision: 1783810

URL: http://svn.apache.org/viewvc?rev=1783810&view=rev
Log:
mpm_motorz: follow up to r1783755.
Use an allocator and mutex for ptrans' to be safe with concurrent
creation and destruction of its subpools, like with mod_http2.


Modified:
    httpd/httpd/trunk/server/mpm/motorz/motorz.c

Modified: httpd/httpd/trunk/server/mpm/motorz/motorz.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/motorz/motorz.c?rev=1783810&r1=1783809&r2=1783810&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/motorz/motorz.c (original)
+++ httpd/httpd/trunk/server/mpm/motorz/motorz.c Mon Feb 20 22:50:56 2017
@@ -187,10 +187,18 @@ static apr_status_t motorz_io_accept(mot
     apr_pool_t *ptrans;
     apr_socket_t *socket;
     ap_listen_rec *lr = (ap_listen_rec *) sb->baton;
+    apr_allocator_t *allocator;
+    apr_thread_mutex_t *mutex;
 
-    apr_pool_create(&ptrans, NULL);
+    apr_allocator_create(&allocator);
+    apr_allocator_max_free_set(allocator, ap_max_mem_free);
+    apr_pool_create_ex(&ptrans, pconf, NULL, allocator);
+    apr_allocator_owner_set(allocator, ptrans);
+    apr_pool_tag(ptrans, "transaction");
+
+    apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_DEFAULT, ptrans);
+    apr_allocator_mutex_set(allocator, mutex);
 
-    apr_pool_tag(ptrans, "accept");
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(03318)
                          "motorz_io_accept(): entered");
 
@@ -862,8 +870,6 @@ static void child_main(motorz_core_t *mz
     apr_thread_t *thd = NULL;
     apr_os_thread_t osthd;
 #endif
-    apr_pool_t *ptrans;
-    apr_allocator_t *allocator;
     apr_status_t status;
     int i;
     ap_listen_rec *lr;
@@ -883,10 +889,7 @@ static void child_main(motorz_core_t *mz
     /* Get a sub context for global allocations in this child, so that
      * we can have cleanups occur when the child exits.
      */
-    apr_allocator_create(&allocator);
-    apr_allocator_max_free_set(allocator, ap_max_mem_free);
-    apr_pool_create_ex(&pchild, pconf, NULL, allocator);
-    apr_allocator_owner_set(allocator, pchild);
+    apr_pool_create(&pchild, pconf);
     apr_pool_tag(pchild, "pchild");
 
 #if APR_HAS_THREADS
@@ -894,9 +897,6 @@ static void child_main(motorz_core_t *mz
     apr_os_thread_put(&thd, &osthd, pchild);
 #endif
 
-    apr_pool_create(&ptrans, pchild);
-    apr_pool_tag(ptrans, "transaction");
-
     /* close unused listeners and pods */
     for (i = 0; i < num_buckets; i++) {
         if (i != child_bucket) {
@@ -994,8 +994,6 @@ static void child_main(motorz_core_t *mz
          * (Re)initialize this child to a pre-connection state.
          */
 
-        apr_pool_clear(ptrans);
-
         if ((ap_max_requests_per_child > 0
              && requests_this_child++ >= ap_max_requests_per_child)) {
             clean_child_exit(0);
@@ -1057,7 +1055,7 @@ static void child_main(motorz_core_t *mz
             die_now = 1;
         }
     }
-    apr_pool_clear(ptrans); /* kludge to avoid crash in APR reslist cleanup code */
+
     clean_child_exit(0);
 }
 



Mime
View raw message