Skip to content

Commit

Permalink
h2 timeouts default to their ht1 counterparts, fixes in calculating (…
Browse files Browse the repository at this point in the history
…remaining) timeouts
  • Loading branch information
Stefan Eissing committed Jan 4, 2016
1 parent f608b6b commit 8a6167f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 18 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
v1.0.17
--------------------------------------------------------------------------------
* H2Timeout/H2KeepAliveTimeout now defaults to what ever is set for HTTP/1
connections via Timeout/KeepAliveTimeout
* fixes in calculating remaining timeout values

v1.0.16
--------------------------------------------------------------------------------
* simplified connection shutdown and worker join for robustness
* improved performance for small requests due to less locking
* http2 connections work in event with normal server KeepAliveTimeout setting

v1.0.15
--------------------------------------------------------------------------------
* fixed busy loops on random connection errors
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#

AC_PREREQ([2.69])
AC_INIT([mod_http2], [1.0.16], [[email protected]])
AC_INIT([mod_http2], [1.0.17], [[email protected]])

LT_PREREQ([2.2.6])
LT_INIT()
Expand Down
2 changes: 1 addition & 1 deletion mod_http2/h2_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static h2_config defconf = {
1, /* TLS cooldown secs */
1, /* HTTP/2 server push enabled */
NULL, /* map of content-type to priorities */
5, /* normal connection timeout */
-1, /* connection timeout */
-1, /* keepalive timeout */
0, /* stream timeout */
};
Expand Down
6 changes: 2 additions & 4 deletions mod_http2/h2_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,17 @@ static apr_status_t h2_conn_process(h2_ctx *ctx)
apr_status_t h2_conn_run(struct h2_ctx *ctx, conn_rec *c)
{
int mpm_state = 0;
apr_status_t status;
do {
status = h2_conn_process(ctx);
h2_conn_process(ctx);

if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state)) {
break;
}
} while (!async_mpm
&& status == APR_SUCCESS
&& c->keepalive == AP_CONN_KEEPALIVE
&& mpm_state != AP_MPMQ_STOPPING);

return status;
return DONE;
}


Expand Down
2 changes: 1 addition & 1 deletion mod_http2/h2_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ apr_status_t h2_filter_core_input(ap_filter_t* f,
if (cin->timeout_secs > 0) {
apr_time_t t = apr_time_from_sec(cin->timeout_secs);
apr_socket_timeout_get(cin->socket, &saved_timeout);
apr_socket_timeout_set(cin->socket, H2MIN(t, saved_timeout));
apr_socket_timeout_set(cin->socket, t);
}
}
ap_update_child_status_from_conn(f->c->sbh, SERVER_BUSY_READ, f->c);
Expand Down
30 changes: 21 additions & 9 deletions mod_http2/h2_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,12 @@ static h2_session *h2_session_create_int(conn_rec *c,
session->max_stream_count = h2_config_geti(session->config, H2_CONF_MAX_STREAMS);
session->max_stream_mem = h2_config_geti(session->config, H2_CONF_STREAM_MAX_MEM);
session->timeout_secs = h2_config_geti(session->config, H2_CONF_TIMEOUT_SECS);
if (session->timeout_secs <= 0) {
session->timeout_secs = apr_time_sec(session->s->timeout);
}
session->keepalive_secs = h2_config_geti(session->config, H2_CONF_KEEPALIVE_SECS);
if (session->keepalive_secs <= 0) {
session->keepalive_secs = session->timeout_secs;
session->keepalive_secs = apr_time_sec(session->s->keep_alive_timeout);
}

status = apr_thread_cond_create(&session->iowait, session->pool);
Expand Down Expand Up @@ -858,7 +861,14 @@ static h2_session *h2_session_create_int(conn_rec *c,
h2_session_destroy(session);
return NULL;
}


if (APLOGcdebug(c)) {
ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c,
"session(%ld) created, timeout=%d, keepalive_timeout=%d, "
"max_streams=%d, stream_mem=%d",
session->id, session->timeout_secs, session->keepalive_secs,
(int)session->max_stream_count, (int)session->max_stream_mem);
}
}
return session;
}
Expand Down Expand Up @@ -1770,6 +1780,7 @@ apr_status_t h2_session_process(h2_session *session, int async)

case H2_SESSION_ST_BUSY:
if (nghttp2_session_want_read(session->ngh2)) {
h2_filter_cin_timeout_set(session->cin, session->timeout_secs);
status = h2_session_read(session, 0, 10);
if (status == APR_SUCCESS) {
/* got something, continue processing */
Expand Down Expand Up @@ -1898,24 +1909,25 @@ apr_status_t h2_session_process(h2_session *session, int async)

case H2_SESSION_ST_KEEPALIVE:
/* Our normal H2Timeout has passed and we are considering to
* extend that with the H2KeepAliveTimeout. This works different
* for async MPMs. */
* extend that with the H2KeepAliveTimeout. */
remain_secs = session->keepalive_secs - session->timeout_secs;
if (!async && remain_secs <= 0) {
/* not async, keepalive is smaller than normal timeout, close the session */
if (remain_secs <= 0) {
/* keepalive is <= normal timeout, close the session */
reason = "keepalive expired";
h2_session_shutdown(session, 0);
goto out;
}
session->c->keepalive = AP_CONN_KEEPALIVE;
ap_update_child_status_from_conn(c->sbh, SERVER_BUSY_KEEPALIVE, c);
if (async && !session->r && session->c->cs) {

if ((apr_time_sec(session->s->keep_alive_timeout) >= remain_secs)
&& async && session->c->cs
&& !session->r) {
/* Async MPMs are able to handle keep-alive connections without
* blocking a thread. For this to happen, we need to return from
* processing, indicating the IO event we are waiting for, and
* may be called again if the event happens.
* For now, we let the MPM handle any timing on this, so we
* cannot really enforce the remain_secs here.
* TODO: this does not properly GOAWAY connections...
* TODO: This currently does not work on upgraded requests...
*/
ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, c,
Expand Down
1 change: 1 addition & 0 deletions mod_http2/h2_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ typedef struct h2_session {

apr_size_t max_stream_count; /* max number of open streams */
apr_size_t max_stream_mem; /* max buffer memory for a single stream */

int timeout_secs; /* connection timeout (seconds) */
int keepalive_secs; /* connection idle timeout (seconds) */

Expand Down
4 changes: 2 additions & 2 deletions mod_http2/h2_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
* @macro
* Version number of the http2 module as c string
*/
#define MOD_HTTP2_VERSION "1.0.16"
#define MOD_HTTP2_VERSION "1.0.17"

/**
* @macro
* Numerical representation of the version number of the http2 module
* 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_HTTP2_VERSION_NUM 0x010010
#define MOD_HTTP2_VERSION_NUM 0x010011


#endif /* mod_h2_h2_version_h */

0 comments on commit 8a6167f

Please sign in to comment.