From: Stefan Eissing Date: Mon, 9 Nov 2015 16:18:52 +0000 (+0000) Subject: task bucket_alloc now created per task pool, spare pools properly destroyed X-Git-Tag: 2.5.0-alpha~2651 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb866d5a7a4ca72d5f7ffe0bc15c13980c173a1a;p=thirdparty%2Fapache%2Fhttpd.git task bucket_alloc now created per task pool, spare pools properly destroyed git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1713472 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index f1fcbffb808..15dca277757 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -248,7 +248,8 @@ conn_rec *h2_conn_create(conn_rec *master, apr_pool_t *pool) return c; } -apr_status_t h2_conn_setup(h2_task *task, struct h2_worker *worker) +apr_status_t h2_conn_setup(h2_task *task, apr_bucket_alloc_t *bucket_alloc, + apr_thread_t *thread, apr_socket_t *socket) { conn_rec *master = task->mplx->c; @@ -262,8 +263,8 @@ apr_status_t h2_conn_setup(h2_task *task, struct h2_worker *worker) * pools. */ task->c->pool = task->pool; - task->c->bucket_alloc = h2_worker_get_bucket_alloc(worker); - task->c->current_thread = h2_worker_get_thread(worker); + task->c->current_thread = thread; + task->c->bucket_alloc = bucket_alloc; task->c->conn_config = ap_create_conn_config(task->pool); task->c->notes = apr_table_make(task->pool, 5); @@ -271,8 +272,7 @@ apr_status_t h2_conn_setup(h2_task *task, struct h2_worker *worker) /* In order to do this in 2.4.x, we need to add a member to conn_rec */ task->c->master = master; - ap_set_module_config(task->c->conn_config, &core_module, - h2_worker_get_socket(worker)); + ap_set_module_config(task->c->conn_config, &core_module, socket); /* This works for mpm_worker so far. Other mpm modules have * different needs, unfortunately. The most interesting one diff --git a/modules/http2/h2_conn.h b/modules/http2/h2_conn.h index 88caf1710d5..84cf8d83c40 100644 --- a/modules/http2/h2_conn.h +++ b/modules/http2/h2_conn.h @@ -17,7 +17,6 @@ #define __mod_h2__h2_conn__ struct h2_task; -struct h2_worker; /** * Process the connection that is now starting the HTTP/2 @@ -49,6 +48,7 @@ h2_mpm_type_t h2_conn_mpm_type(void); conn_rec *h2_conn_create(conn_rec *master, apr_pool_t *stream_pool); -apr_status_t h2_conn_setup(struct h2_task *task, struct h2_worker *worker); +apr_status_t h2_conn_setup(struct h2_task *task, apr_bucket_alloc_t *bucket_alloc, + apr_thread_t *thread, apr_socket_t *socket); #endif /* defined(__mod_h2__h2_conn__) */ diff --git a/modules/http2/h2_mplx.c b/modules/http2/h2_mplx.c index 11cfd5c8082..7d052c53ea3 100644 --- a/modules/http2/h2_mplx.c +++ b/modules/http2/h2_mplx.c @@ -74,6 +74,10 @@ static void h2_mplx_destroy(h2_mplx *m) m->lock = NULL; } + if (m->spare_pool) { + apr_pool_destroy(m->spare_pool); + m->spare_pool = NULL; + } if (m->pool) { apr_pool_destroy(m->pool); } diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c index 1ccfaa26ade..2e93a66cc51 100644 --- a/modules/http2/h2_session.c +++ b/modules/http2/h2_session.c @@ -780,14 +780,20 @@ void h2_session_destroy(h2_session *session) nghttp2_session_del(session->ngh2); session->ngh2 = NULL; } + if (session->spare) { + apr_pool_destroy(session->spare); + session->spare = NULL; + } + if (session->pool) { + apr_pool_destroy(session->pool); + } } void h2_session_cleanup(h2_session *session) { + ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, session->c, + "session(%ld): cleanup and destroy", session->id); h2_session_destroy(session); - if (session->pool) { - apr_pool_destroy(session->pool); - } } static apr_status_t h2_session_abort_int(h2_session *session, int reason) diff --git a/modules/http2/h2_task.c b/modules/http2/h2_task.c index 1d95496d2d1..f0f024a0dcc 100644 --- a/modules/http2/h2_task.c +++ b/modules/http2/h2_task.c @@ -206,17 +206,8 @@ apr_status_t h2_task_do(h2_task *task, h2_worker *worker) AP_DEBUG_ASSERT(task); task->serialize_headers = h2_config_geti(cfg, H2_CONF_SER_HEADERS); - - /* Create a subpool from the worker one to be used for all things - * with life-time of this task execution. - */ - apr_pool_create(&task->pool, h2_worker_get_pool(worker)); - /* Link the task to the worker which provides useful things such - * as mutex, a socket etc. */ - task->io = h2_worker_get_cond(worker); - - status = h2_conn_setup(task, worker); + status = h2_worker_setup_task(worker, task); /* save in connection that this one is a pseudo connection, prevents * other hooks from messing with it. */ @@ -252,10 +243,7 @@ apr_status_t h2_task_do(h2_task *task, h2_worker *worker) apr_thread_cond_signal(task->io); } - if (task->pool) { - apr_pool_destroy(task->pool); - task->pool = NULL; - } + h2_worker_release_task(worker, task); h2_mplx_task_done(task->mplx, task->stream_id); diff --git a/modules/http2/h2_worker.c b/modules/http2/h2_worker.c index 297b4b21fe6..01004213712 100644 --- a/modules/http2/h2_worker.c +++ b/modules/http2/h2_worker.c @@ -22,6 +22,7 @@ #include #include "h2_private.h" +#include "h2_conn.h" #include "h2_mplx.h" #include "h2_task.h" #include "h2_worker.h" @@ -55,7 +56,7 @@ static void* APR_THREAD_FUNC execute(apr_thread_t *thread, void *wctx) if (worker->task) { h2_task_do(worker->task, worker); worker->task = NULL; - apr_thread_cond_signal(h2_worker_get_cond(worker)); + apr_thread_cond_signal(worker->io); } } @@ -112,7 +113,6 @@ h2_worker *h2_worker_create(int id, w->id = id; w->pool = pool; - w->bucket_alloc = apr_bucket_alloc_create(pool); w->get_next = get_next; w->worker_done = worker_done; @@ -157,14 +157,32 @@ int h2_worker_is_aborted(h2_worker *worker) return worker->aborted; } -apr_thread_t *h2_worker_get_thread(h2_worker *worker) -{ - return worker->thread; +apr_status_t h2_worker_setup_task(h2_worker *worker, h2_task *task) { + apr_status_t status; + + /* Create a subpool from the worker one to be used for all things + * with life-time of this task execution. + */ + apr_pool_create(&task->pool, worker->pool); + + /* Link the task to the worker which provides useful things such + * as mutex, a socket etc. */ + task->io = worker->io; + + status = h2_conn_setup(task, apr_bucket_alloc_create(task->pool), + worker->thread, worker->socket); + + return status; } -apr_thread_cond_t *h2_worker_get_cond(h2_worker *worker) +void h2_worker_release_task(h2_worker *worker, struct h2_task *task) { - return worker->io; + task->io = NULL; + + if (task->pool) { + apr_pool_destroy(task->pool); + task->pool = NULL; + } } apr_socket_t *h2_worker_get_socket(h2_worker *worker) @@ -172,13 +190,4 @@ apr_socket_t *h2_worker_get_socket(h2_worker *worker) return worker->socket; } -apr_pool_t *h2_worker_get_pool(h2_worker *worker) -{ - return worker->pool; -} - -apr_bucket_alloc_t *h2_worker_get_bucket_alloc(h2_worker *worker) -{ - return worker->bucket_alloc; -} diff --git a/modules/http2/h2_worker.h b/modules/http2/h2_worker.h index 9c69e6b57a8..ce934f745b2 100644 --- a/modules/http2/h2_worker.h +++ b/modules/http2/h2_worker.h @@ -44,7 +44,6 @@ struct h2_worker { int id; apr_thread_t *thread; apr_pool_t *pool; - apr_bucket_alloc_t *bucket_alloc; struct apr_thread_cond_t *io; apr_socket_t *socket; @@ -142,14 +141,9 @@ int h2_worker_get_id(h2_worker *worker); int h2_worker_is_aborted(h2_worker *worker); -apr_pool_t *h2_worker_get_pool(h2_worker *worker); - -apr_bucket_alloc_t *h2_worker_get_bucket_alloc(h2_worker *worker); +apr_status_t h2_worker_setup_task(h2_worker *worker, struct h2_task *task); +void h2_worker_release_task(h2_worker *worker, struct h2_task *task); apr_socket_t *h2_worker_get_socket(h2_worker *worker); -apr_thread_t *h2_worker_get_thread(h2_worker *worker); - -struct apr_thread_cond_t *h2_worker_get_cond(h2_worker *worker); - #endif /* defined(__mod_h2__h2_worker__) */