summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2017-02-20 23:49:05 +0100
committerYann Ylavic <ylavic@apache.org>2017-02-20 23:49:05 +0100
commit5b8c9f7a26ee9b1c447af7998a59127d240e9ec4 (patch)
tree9ec2830da8a51df4919548f4e244d7297e39ff9d /server
parentmpm_motorz: follow up to r1783772, with the real changes. (diff)
downloadapache2-5b8c9f7a26ee9b1c447af7998a59127d240e9ec4.tar.xz
apache2-5b8c9f7a26ee9b1c447af7998a59127d240e9ec4.zip
mpm_worker: follow up to r1783755.
Use a mutex for ptrans' allocator 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@1783808 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r--server/mpm/worker/worker.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/server/mpm/worker/worker.c b/server/mpm/worker/worker.c
index ed062b2abe..e3452c99a3 100644
--- a/server/mpm/worker/worker.c
+++ b/server/mpm/worker/worker.c
@@ -833,6 +833,8 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy)
} /* if/else */
if (!listener_may_exit) {
+ apr_thread_mutex_t *mutex;
+
if (ptrans == NULL) {
/* we can't use a recycled transaction pool this time.
* create a new transaction pool */
@@ -844,6 +846,31 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t *thd, void * dummy)
apr_allocator_owner_set(allocator, ptrans);
}
apr_pool_tag(ptrans, "transaction");
+
+ /* We need a mutex in the allocator to synchronize ptrans'
+ * children creations/destructions, but this mutex ought to
+ * live in ptrans itself to avoid leaks, hence it's cleared
+ * in ap_push_pool(). We could recycle some pconf's mutexes
+ * like we do for ptrans subpools, but that'd need another
+ * synchronization mechanism, whereas creating a pthread
+ * mutex (unix here!) is really as simple/fast as a static
+ * PTHREAD_MUTEX_INIT assignment, so let's not bother and
+ * create the mutex for each ptrans (recycled or not).
+ */
+ rv = apr_thread_mutex_create(&mutex,
+ APR_THREAD_MUTEX_DEFAULT,
+ ptrans);
+ if (rv != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv,
+ ap_server_conf, APLOGNO(10019)
+ "Failed to create transaction pool mutex");
+ resource_shortage = 1;
+ signal_threads(ST_GRACEFUL);
+ return NULL;
+ }
+ apr_allocator_mutex_set(apr_pool_allocator_get(ptrans),
+ mutex);
+
rv = lr->accept_func(&csd, lr, ptrans);
/* later we trash rv and rely on csd to indicate success/failure */
AP_DEBUG_ASSERT(rv == APR_SUCCESS || !csd);