From addc112a608a93bc9fbd3855e430a834db7ffdd2 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 1 Sep 2015 12:11:00 +0000 Subject: [PATCH] better connection state on ending sessions, improved default extra file config value depending on max workers per process git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1700514 13f79535-47bb-0310-9956-ffa450edef68 --- modules/http2/h2_config.c | 37 +++++++++++++++++++++++++++++++++++-- modules/http2/h2_config.h | 2 ++ modules/http2/h2_conn.c | 27 +++++++++++++++------------ modules/http2/h2_version.h | 4 ++-- 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/modules/http2/h2_config.c b/modules/http2/h2_config.c index 410522e73f..470f8c0fe4 100644 --- a/modules/http2/h2_config.c +++ b/modules/http2/h2_config.c @@ -21,6 +21,8 @@ #include #include +#include + #include #include "h2_alt_svc.h" @@ -46,9 +48,35 @@ static h2_config defconf = { -1, /* alt-svc max age */ 0, /* serialize headers */ -1, /* h2 direct mode */ - 5, /* # session extra files */ + -1, /* # session extra files */ }; +static int files_per_session = 0; + +void h2_config_init(apr_pool_t *pool) { + /* Determine a good default for this platform and mpm? + * TODO: not sure how APR wants to hand out this piece of + * information. + */ + int max_files = 256; + int conn_threads = 1; + int tx_files = max_files / 4; + + (void)pool; + ap_mpm_query(AP_MPMQ_MAX_THREADS, &conn_threads); + switch (h2_conn_mpm_type()) { + case H2_MPM_PREFORK: + case H2_MPM_WORKER: + case H2_MPM_EVENT: + /* allow that many transfer open files per mplx */ + files_per_session = (tx_files / conn_threads); + break; + default: + /* don't know anything about it, stay safe */ + break; + } +} + static void *h2_config_create(apr_pool_t *pool, const char *prefix, const char *x) { @@ -116,6 +144,7 @@ void *h2_config_merge(apr_pool_t *pool, void *basev, void *addv) int h2_config_geti(h2_config *conf, h2_config_var_t var) { + int n; switch(var) { case H2_CONF_MAX_STREAMS: return H2_CONFIG_GET(conf, &defconf, h2_max_streams); @@ -136,7 +165,11 @@ int h2_config_geti(h2_config *conf, h2_config_var_t var) case H2_CONF_DIRECT: return H2_CONFIG_GET(conf, &defconf, h2_direct); case H2_CONF_SESSION_FILES: - return H2_CONFIG_GET(conf, &defconf, session_extra_files); + n = H2_CONFIG_GET(conf, &defconf, session_extra_files); + if (n < 0) { + n = files_per_session; + } + return n; default: return DEF_VAL; } diff --git a/modules/http2/h2_config.h b/modules/http2/h2_config.h index a13a590514..931af59d30 100644 --- a/modules/http2/h2_config.h +++ b/modules/http2/h2_config.h @@ -68,5 +68,7 @@ h2_config *h2_config_rget(request_rec *r); int h2_config_geti(h2_config *conf, h2_config_var_t var); +void h2_config_init(apr_pool_t *pool); + #endif /* __mod_h2__h2_config_h__ */ diff --git a/modules/http2/h2_conn.c b/modules/http2/h2_conn.c index 60c76b323b..38e5c11a28 100644 --- a/modules/http2/h2_conn.c +++ b/modules/http2/h2_conn.c @@ -84,19 +84,11 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) int idle_secs = 0; int i; + h2_config_init(pool); + ap_mpm_query(AP_MPMQ_MAX_THREADS, &max_threads_per_child); ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &threads_limit); - if (minw <= 0) { - minw = max_threads_per_child; - } - if (maxw <= 0) { - maxw = threads_limit; - if (maxw < minw) { - maxw = minw; - } - } - for (i = 0; ap_loaded_modules[i]; ++i) { module *m = ap_loaded_modules[i]; if (!strcmp("event.c", m->name)) { @@ -116,6 +108,16 @@ apr_status_t h2_conn_child_init(apr_pool_t *pool, server_rec *s) } } + if (minw <= 0) { + minw = max_threads_per_child; + } + if (maxw <= 0) { + maxw = threads_limit; + if (maxw < minw) { + maxw = minw; + } + } + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "h2_workers: min=%d max=%d, mthrpchild=%d, thr_limit=%d", minw, maxw, max_threads_per_child, threads_limit); @@ -177,9 +179,10 @@ apr_status_t h2_conn_main(conn_rec *c) status = h2_session_process(session); + /* Make sure this connection gets closed properly. */ + c->keepalive = AP_CONN_CLOSE; if (c->cs) { - /* Make sure this connection gets cleaned up properly. */ - c->cs->state = CONN_STATE_LINGER; + c->cs->state = CONN_STATE_WRITE_COMPLETION; } return status; diff --git a/modules/http2/h2_version.h b/modules/http2/h2_version.h index b253bef68a..abd90d8092 100644 --- a/modules/http2/h2_version.h +++ b/modules/http2/h2_version.h @@ -20,7 +20,7 @@ * @macro * Version number of the h2 module as c string */ -#define MOD_H2_VERSION "0.9.2" +#define MOD_H2_VERSION "0.9.6" /** * @macro @@ -28,7 +28,7 @@ * release. This is a 24 bit number with 8 bits for major number, 8 bits * for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203. */ -#define MOD_H2_VERSION_NUM 0x000902 +#define MOD_H2_VERSION_NUM 0x000906 #endif /* mod_h2_h2_version_h */ -- 2.50.0