From 6101554faf7bb251f2e7a0567ddfc461e9de2ffd Mon Sep 17 00:00:00 2001 From: Yann Ylavic Date: Mon, 20 Feb 2017 22:50:56 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1783810 13f79535-47bb-0310-9956-ffa450edef68 --- server/mpm/motorz/motorz.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/server/mpm/motorz/motorz.c b/server/mpm/motorz/motorz.c index 3dea7fbe41..065dff1012 100644 --- a/server/mpm/motorz/motorz.c +++ b/server/mpm/motorz/motorz.c @@ -187,10 +187,18 @@ static apr_status_t motorz_io_accept(motorz_core_t *mz, motorz_sb_t *sb) 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, int child_num_arg, int child_bucket) 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, int child_num_arg, int child_bucket) /* 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, int child_num_arg, int child_bucket) 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, int child_num_arg, int child_bucket) * (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, int child_num_arg, int child_bucket) die_now = 1; } } - apr_pool_clear(ptrans); /* kludge to avoid crash in APR reslist cleanup code */ + clean_child_exit(0); } -- 2.50.1