From faa662844fc930cbe114a2c9d26260a3a6086f97 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 29 Mar 2017 07:04:07 +0000 Subject: [PATCH] On the trunk: mod_http2: checking for required nghttp2 features to enabled dynamic input window resizing for streams (nghttp2 >= v1.5.0). Reporting as feature DWINS on startup. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1789279 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 ++- modules/http2/config2.m4 | 3 +++ modules/http2/h2_session.c | 7 +++++-- modules/http2/h2_stream.c | 4 +++- modules/http2/mod_http2.c | 7 ++++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 6576d4a6b5..f99ca450bf 100644 --- a/CHANGES +++ b/CHANGES @@ -7,7 +7,8 @@ Changes with Apache 2.5.0 descriptors on graceful restart. [Yann Ylavic] *) mod_http2: input buffering and dynamic flow windows for increased - throughput. [Stefan Eissing] + throughput. Requires nghttp2 >= v1.5.0 features. Announced at startup + in mod_http2 INFO log as feature 'DWINS'. [Stefan Eissing] *) mod_http2: h2 workers with improved scalability for better scheduling performance. There are H2MaxWorkers threads created at start and the diff --git a/modules/http2/config2.m4 b/modules/http2/config2.m4 index 26f71632a0..fac130b219 100644 --- a/modules/http2/config2.m4 +++ b/modules/http2/config2.m4 @@ -155,6 +155,9 @@ dnl # nghttp2 >= 1.5.0: changing stream priorities dnl # nghttp2 >= 1.14.0: invalid header callback AC_CHECK_FUNCS([nghttp2_session_callbacks_set_on_invalid_header_callback], [APR_ADDTO(MOD_CPPFLAGS, ["-DH2_NG2_INVALID_HEADER_CB"])], []) +dnl # nghttp2 >= 1.15.0: get/set stream window sizes + AC_CHECK_FUNCS([nghttp2_session_get_stream_local_window_size], + [APR_ADDTO(MOD_CPPFLAGS, ["-DH2_NG2_LOCAL_WIN_SIZE"])], []) else AC_MSG_WARN([nghttp2 version is too old]) fi diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c index d05d998e10..78180b4c03 100644 --- a/modules/http2/h2_session.c +++ b/modules/http2/h2_session.c @@ -80,9 +80,9 @@ static h2_stream *get_stream(h2_session *session, int stream_id) static void update_window(void *ctx, int stream_id, apr_off_t bytes_read) { h2_session *session = ctx; + h2_stream *stream; if (bytes_read > 0) { - h2_stream *stream = get_stream(session, stream_id); apr_off_t consumed = bytes_read; while (consumed > 0) { @@ -91,7 +91,9 @@ static void update_window(void *ctx, int stream_id, apr_off_t bytes_read) consumed -= len; } - if (stream) { + (void)stream; +#ifdef H2_NG2_LOCAL_WIN_SIZE + if ((stream = get_stream(session, stream_id))) { int cur_size = nghttp2_session_get_stream_local_window_size( session->ngh2, stream->id); int win = stream->in_window_size; @@ -133,6 +135,7 @@ static void update_window(void *ctx, int stream_id, apr_off_t bytes_read) session->id, stream_id, (long)bytes_read, cur_size, stream->in_window_size); } +#endif } } diff --git a/modules/http2/h2_stream.c b/modules/http2/h2_stream.c index 835bf238ff..9af2f29edc 100644 --- a/modules/http2/h2_stream.c +++ b/modules/http2/h2_stream.c @@ -533,10 +533,12 @@ h2_stream *h2_stream_create(int id, apr_pool_t *pool, h2_session *session, h2_beam_create(&stream->output, pool, id, "output", H2_BEAM_OWNER_RECV, 0, session->s->timeout); - + +#ifdef H2_NG2_LOCAL_WIN_SIZE stream->in_window_size = nghttp2_session_get_stream_local_window_size( stream->session->ngh2, stream->id); +#endif ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, H2_STRM_LOG(APLOGNO(03082), stream, "created")); diff --git a/modules/http2/mod_http2.c b/modules/http2/mod_http2.c index e0a4b90883..ea399c91a2 100644 --- a/modules/http2/mod_http2.c +++ b/modules/http2/mod_http2.c @@ -61,6 +61,7 @@ typedef struct { unsigned int change_prio : 1; unsigned int sha256 : 1; unsigned int inv_headers : 1; + unsigned int dyn_windows : 1; } features; static features myfeats; @@ -96,6 +97,9 @@ static int h2_post_config(apr_pool_t *p, apr_pool_t *plog, #ifdef H2_NG2_INVALID_HEADER_CB myfeats.inv_headers = 1; #endif +#ifdef H2_NG2_LOCAL_WIN_SIZE + myfeats.dyn_windows = 1; +#endif apr_pool_userdata_get(&data, mod_h2_init_key, s->process->pool); if ( data == NULL ) { @@ -108,11 +112,12 @@ static int h2_post_config(apr_pool_t *p, apr_pool_t *plog, ngh2 = nghttp2_version(0); ap_log_error( APLOG_MARK, APLOG_INFO, 0, s, APLOGNO(03090) - "mod_http2 (v%s, feats=%s%s%s, nghttp2 %s), initializing...", + "mod_http2 (v%s, feats=%s%s%s%s, nghttp2 %s), initializing...", MOD_HTTP2_VERSION, myfeats.change_prio? "CHPRIO" : "", myfeats.sha256? "+SHA256" : "", myfeats.inv_headers? "+INVHD" : "", + myfeats.dyn_windows? "+DWINS" : "", ngh2? ngh2->version_str : "unknown"); switch (h2_conn_mpm_type()) { -- 2.40.0