]> granicus.if.org Git - apache/commitdiff
using keepalive timeout only when no streams are open, changing from seconds to prope...
authorStefan Eissing <icing@apache.org>
Fri, 29 Jan 2016 14:37:17 +0000 (14:37 +0000)
committerStefan Eissing <icing@apache.org>
Fri, 29 Jan 2016 14:37:17 +0000 (14:37 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1727594 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_filter.c
modules/http2/h2_filter.h
modules/http2/h2_private.h
modules/http2/h2_session.c
modules/http2/h2_session.h
modules/http2/mod_http2.c

index bde3b01b9ce6803519e3241f47544bffc118b1e2..87ac9df5345eba5a5edfba07226956a840ad9e88 100644 (file)
@@ -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,
index 401a6e0e44a0aca0110d4e40c30f006aeadc04da..9a38a9b9cbcfbd7acea42c12c3f04392009d9ce5 100644 (file)
@@ -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,
index 0ad02d3b71fe567f7cea845483555efb13f4c014..eb24fa1a21034f996e98caa3a485ed30253a5b93 100644 (file)
@@ -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;
index b22e5153133833580fb75aa19df297d45db102a4..1597d787cd1da81870d8f83a316df1634371135b 100644 (file)
@@ -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);
index bdf815df1af7a52602b8075a66d29be00a614fc0..354b837e17bfe3478053338a6cc863eacc0ee37f 100644 (file)
@@ -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 */
index 809a883276513fd912ee50b342e1f9c79297f196..a3b978c879093524c5830b869fe8390cdd668e9f 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <apr_optional.h>
 #include <apr_optional_hooks.h>
+#include <apr_time.h>
 #include <apr_want.h>
 
 #include <httpd.h>