diff options
author | Stefan Eissing <icing@apache.org> | 2016-01-29 15:37:17 +0100 |
---|---|---|
committer | Stefan Eissing <icing@apache.org> | 2016-01-29 15:37:17 +0100 |
commit | 736f2fce8e93221200e55aaebebc367417af9b85 (patch) | |
tree | 57996e7c58dd8ea8dc076fa0943064a9b9968e2c | |
parent | removed experimental++ H2* timeout directives, instead using normal Timeout a... (diff) | |
download | apache2-736f2fce8e93221200e55aaebebc367417af9b85.tar.xz apache2-736f2fce8e93221200e55aaebebc367417af9b85.zip |
using keepalive timeout only when no streams are open, changing from seconds to proper apr_interval_time_t
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1727594 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | modules/http2/h2_filter.c | 17 | ||||
-rw-r--r-- | modules/http2/h2_filter.h | 4 | ||||
-rw-r--r-- | modules/http2/h2_private.h | 2 | ||||
-rw-r--r-- | modules/http2/h2_session.c | 13 | ||||
-rw-r--r-- | modules/http2/h2_session.h | 2 | ||||
-rw-r--r-- | modules/http2/mod_http2.c | 1 |
6 files changed, 21 insertions, 18 deletions
diff --git a/modules/http2/h2_filter.c b/modules/http2/h2_filter.c index bde3b01b9c..87ac9df534 100644 --- a/modules/http2/h2_filter.c +++ b/modules/http2/h2_filter.c @@ -51,7 +51,7 @@ static apr_status_t consume_brigade(h2_filter_cin *cin, apr_bucket* bucket = APR_BRIGADE_FIRST(bb); if (APR_BUCKET_IS_METADATA(bucket)) { - /* we do nothing regarding any meta here */ + /* we do nothing regardih2_filter_cin_timeout_setng any meta here */ } else { const char *bucket_data = NULL; @@ -92,9 +92,9 @@ h2_filter_cin *h2_filter_cin_create(apr_pool_t *p, h2_filter_cin_cb *cb, void *c return cin; } -void h2_filter_cin_timeout_set(h2_filter_cin *cin, int timeout_secs) +void h2_filter_cin_timeout_set(h2_filter_cin *cin, apr_interval_time_t timeout) { - cin->timeout_secs = timeout_secs; + cin->timeout = timeout; } apr_status_t h2_filter_core_input(ap_filter_t* f, @@ -105,12 +105,12 @@ apr_status_t h2_filter_core_input(ap_filter_t* f, { h2_filter_cin *cin = f->ctx; apr_status_t status = APR_SUCCESS; - apr_time_t saved_timeout = UNSET; + apr_interval_time_t saved_timeout = UNSET; ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, f->c, - "core_input(%ld): read, %s, mode=%d, readbytes=%ld, timeout=%d", + "core_input(%ld): read, %s, mode=%d, readbytes=%ld", (long)f->c->id, (block == APR_BLOCK_READ)? "BLOCK_READ" : "NONBLOCK_READ", - mode, (long)readbytes, cin->timeout_secs); + mode, (long)readbytes); if (mode == AP_MODE_INIT || mode == AP_MODE_SPECULATIVE) { return ap_get_brigade(f->next, brigade, mode, block, readbytes); @@ -137,10 +137,9 @@ apr_status_t h2_filter_core_input(ap_filter_t* f, * in the scoreboard is preserved. */ if (block == APR_BLOCK_READ) { - if (cin->timeout_secs > 0) { - apr_time_t t = apr_time_from_sec(cin->timeout_secs); + if (cin->timeout > 0) { apr_socket_timeout_get(cin->socket, &saved_timeout); - apr_socket_timeout_set(cin->socket, t); + apr_socket_timeout_set(cin->socket, cin->timeout); } } status = ap_get_brigade(f->next, cin->bb, AP_MODE_READBYTES, diff --git a/modules/http2/h2_filter.h b/modules/http2/h2_filter.h index 401a6e0e44..9a38a9b9cb 100644 --- a/modules/http2/h2_filter.h +++ b/modules/http2/h2_filter.h @@ -29,13 +29,13 @@ typedef struct h2_filter_cin { h2_filter_cin_cb *cb; void *cb_ctx; apr_socket_t *socket; - int timeout_secs; + apr_interval_time_t timeout; apr_time_t start_read; } h2_filter_cin; h2_filter_cin *h2_filter_cin_create(apr_pool_t *p, h2_filter_cin_cb *cb, void *ctx); -void h2_filter_cin_timeout_set(h2_filter_cin *cin, int timeout_secs); +void h2_filter_cin_timeout_set(h2_filter_cin *cin, apr_interval_time_t timeout); apr_status_t h2_filter_core_input(ap_filter_t* filter, apr_bucket_brigade* brigade, diff --git a/modules/http2/h2_private.h b/modules/http2/h2_private.h index 0ad02d3b71..eb24fa1a21 100644 --- a/modules/http2/h2_private.h +++ b/modules/http2/h2_private.h @@ -16,6 +16,8 @@ #ifndef mod_h2_h2_private_h #define mod_h2_h2_private_h +#include <apr_time.h> + #include <nghttp2/nghttp2.h> extern module AP_MODULE_DECLARE_DATA http2_module; diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c index b22e515313..1597d787cd 100644 --- a/modules/http2/h2_session.c +++ b/modules/http2/h2_session.c @@ -1834,16 +1834,17 @@ static void h2_session_ev_no_io(h2_session *session, int arg, const char *msg) /* When we have no streams, no task event are possible, * switch to blocking reads */ transit(session, "no io", H2_SESSION_ST_IDLE); - session->keepalive_until = apr_time_now() + session->s->keep_alive_timeout; + session->idle_until = apr_time_now() + session->s->keep_alive_timeout; } } else if (!h2_stream_set_has_unsubmitted(session->streams) && !h2_stream_set_has_suspended(session->streams)) { /* none of our streams is waiting for a response or * new output data from task processing, - * switch to blocking reads. */ + * switch to blocking reads. We are probably waiting on + * window updates. */ transit(session, "no io", H2_SESSION_ST_IDLE); - session->keepalive_until = apr_time_now() + session->s->keep_alive_timeout; + session->idle_until = apr_time_now() + session->s->timeout; } else { /* Unable to do blocking reads, as we wait on events from @@ -2052,7 +2053,7 @@ apr_status_t h2_session_process(h2_session *session, int async) dispatch_event(session, H2_SESSION_EV_DATA_READ, 0, NULL); } else if (APR_STATUS_IS_EAGAIN(status) || APR_STATUS_IS_TIMEUP(status)) { - if (apr_time_now() > session->keepalive_until) { + if (apr_time_now() > session->idle_until) { dispatch_event(session, H2_SESSION_EV_CONN_TIMEOUT, 0, NULL); } else { @@ -2080,10 +2081,10 @@ apr_status_t h2_session_process(h2_session *session, int async) /* nothing to read */ } else if (APR_STATUS_IS_TIMEUP(status)) { - if (apr_time_now() > session->keepalive_until) { + if (apr_time_now() > session->idle_until) { dispatch_event(session, H2_SESSION_EV_CONN_TIMEOUT, 0, "timeout"); } - /* continue keepalive handling */ + /* continue reading handling */ } else { dispatch_event(session, H2_SESSION_EV_CONN_ERROR, 0, NULL); diff --git a/modules/http2/h2_session.h b/modules/http2/h2_session.h index bdf815df1a..354b837e17 100644 --- a/modules/http2/h2_session.h +++ b/modules/http2/h2_session.h @@ -113,7 +113,7 @@ typedef struct h2_session { apr_size_t max_stream_mem; /* max buffer memory for a single stream */ apr_time_t start_wait; /* Time we started waiting for sth. to happen */ - apr_time_t keepalive_until; /* Time when we stop keeing an idle conn alive */ + apr_time_t idle_until; /* Time we shut down due to sheer boredom */ apr_pool_t *pool; /* pool to use in session handling */ apr_bucket_brigade *bbtmp; /* brigade for keeping temporary data */ diff --git a/modules/http2/mod_http2.c b/modules/http2/mod_http2.c index 809a883276..a3b978c879 100644 --- a/modules/http2/mod_http2.c +++ b/modules/http2/mod_http2.c @@ -15,6 +15,7 @@ #include <apr_optional.h> #include <apr_optional_hooks.h> +#include <apr_time.h> #include <apr_want.h> #include <httpd.h> |