From dc56e60ed0c2eff934a3058933a77a63398686f7 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 5 Jan 2016 14:29:30 +0000 Subject: [PATCH] reducing # of file handles used in transfers by default, reduced global workers lock usage git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1723084 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http2/h2_conn.c | 2 +- modules/http2/h2_mplx.c | 6 +++--- modules/http2/h2_workers.c | 12 ++++-------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index 0f99076a1c..abc8d8989c 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -117,7 +117,7 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) */ n = h2_config_geti(config, H2_CONF_SESSION_FILES); if (n < 0) { - max_tx_handles = 256; + max_tx_handles = maxw * 2; } else { max_tx_handles = maxw * n; diff --git a/modules/http2/h2_mplx.c b/modules/http2/h2_mplx.c index 28c1d10159..f016a5aa80 100644 --- a/modules/http2/h2_mplx.c +++ b/modules/http2/h2_mplx.c @@ -894,7 +894,6 @@ apr_status_t h2_mplx_reprioritize(h2_mplx *m, h2_stream_pri_cmp *cmp, void *ctx) } apr_thread_mutex_unlock(m->lock); } - workers_register(m); return status; } @@ -921,6 +920,7 @@ apr_status_t h2_mplx_process(h2_mplx *m, int stream_id, const h2_request *req, h2_stream_pri_cmp *cmp, void *ctx) { apr_status_t status; + int was_empty = 0; AP_DEBUG_ASSERT(m); status = apr_thread_mutex_lock(m->lock); @@ -936,6 +936,7 @@ apr_status_t h2_mplx_process(h2_mplx *m, int stream_id, const h2_request *req, status = h2_io_in_close(io); } + was_empty = h2_tq_empty(m->q); h2_tq_add(m->q, io->id, cmp, ctx); ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, m->c, @@ -944,8 +945,7 @@ apr_status_t h2_mplx_process(h2_mplx *m, int stream_id, const h2_request *req, } apr_thread_mutex_unlock(m->lock); } - - if (status == APR_SUCCESS) { + if (status == APR_SUCCESS && was_empty) { workers_register(m); } return status; diff --git a/modules/http2/h2_workers.c b/modules/http2/h2_workers.c index f0020c81eb..1b95cecbce 100644 --- a/modules/http2/h2_workers.c +++ b/modules/http2/h2_workers.c @@ -322,6 +322,8 @@ apr_status_t h2_workers_register(h2_workers *workers, struct h2_mplx *m) ap_log_error(APLOG_MARK, APLOG_TRACE3, status, workers->s, "h2_workers: register mplx(%ld)", m->id); if (in_list(workers, m)) { + ap_log_error(APLOG_MARK, APLOG_INFO, 0, workers->s, + "h2_workers: already registered mplx(%ld)", m->id); status = APR_EAGAIN; } else { @@ -332,16 +334,13 @@ apr_status_t h2_workers_register(h2_workers *workers, struct h2_mplx *m) if (workers->idle_worker_count > 0) { apr_thread_cond_signal(workers->mplx_added); } - else if (workers->worker_count < workers->max_size) { + else if (status == APR_SUCCESS + && workers->worker_count < workers->max_size) { ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, workers->s, "h2_workers: got %d worker, adding 1", workers->worker_count); add_worker(workers); } - - /* cleanup any zombie workers that may have accumulated */ - cleanup_zombies(workers, 0); - apr_thread_mutex_unlock(workers->lock); } return status; @@ -356,9 +355,6 @@ apr_status_t h2_workers_unregister(h2_workers *workers, struct h2_mplx *m) H2_MPLX_REMOVE(m); status = APR_SUCCESS; } - /* cleanup any zombie workers that may have accumulated */ - cleanup_zombies(workers, 0); - apr_thread_mutex_unlock(workers->lock); } return status; -- 2.49.0