You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2017/11/08 13:35:36 UTC

[trafficserver] branch master updated: Fix #2533: ATS doesn't have an active timeout for http2 connection

This is an automated email from the ASF dual-hosted git repository.

maskit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 0456a54  Fix #2533: ATS doesn't have an active timeout for http2 connection
0456a54 is described below

commit 0456a54b8a8e9ba8dec326db2e410d30bf96b371
Author: Zizhong Zhang <zi...@linkedin.com>
AuthorDate: Tue Sep 19 14:42:42 2017 -0700

    Fix #2533: ATS doesn't have an active timeout for http2 connection
---
 doc/admin-guide/files/records.config.en.rst  |  8 ++++
 mgmt/RecordsConfig.cc                        |  2 +-
 proxy/http2/Http2ConnectionState.cc          | 11 +++---
 tests/gold_tests/h2/gold/active_timeout.gold |  1 +
 tests/gold_tests/h2/h2active_timeout.py      | 57 ++++++++++++++++++++++++++++
 tests/gold_tests/h2/http2.test.py            | 13 ++++++-
 6 files changed, 83 insertions(+), 9 deletions(-)

diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst
index 83c5528..0dfec5a 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -3454,6 +3454,14 @@ HTTP/2 Configuration
 
    Enable the experimental HTTP/2 Stream Priority feature.
 
+.. ts:cv:: CONFIG proxy.config.http2.active_timeout_in INT 0
+   :reloadable:
+
+   This is the active timeout of the http2 connection. It is set when the connection is opened
+   and keeps ticking regardless of activity level.
+
+   The value of ``0`` specifies that there is no timeout.
+
 .. ts:cv:: CONFIG proxy.config.http2.accept_no_activity_timeout INT 120
    :reloadable:
    :overridable:
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 5b6410c..17b0672 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -1330,7 +1330,7 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.http2.no_activity_timeout_in", RECD_INT, "120", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.http2.active_timeout_in", RECD_INT, "900", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
+  {RECT_CONFIG, "proxy.config.http2.active_timeout_in", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.http2.push_diary_size", RECD_INT, "256", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
   ,
diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index 0cd9c3f..3420dc7 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -1046,8 +1046,6 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error)
   new_stream->is_first_transaction_flag = get_stream_requests() == 0;
   increment_stream_requests();
   ua_session->get_netvc()->add_to_active_queue();
-  // reset the activity timeout everytime a new stream is created
-  ua_session->get_netvc()->set_active_timeout(HRTIME_SECONDS(Http2::active_timeout_in));
 
   return new_stream;
 }
@@ -1116,8 +1114,10 @@ Http2ConnectionState::cleanup_streams()
   if (!is_state_closed()) {
     SCOPED_MUTEX_LOCK(lock, this->ua_session->mutex, this_ethread());
 
-    ua_session->get_netvc()->add_to_keep_alive_queue();
-    ua_session->get_netvc()->cancel_active_timeout();
+    UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(ua_session->get_netvc());
+    if (vc && vc->active_timeout_in == 0) {
+      vc->add_to_keep_alive_queue();
+    }
   }
 }
 
@@ -1176,8 +1176,7 @@ Http2ConnectionState::release_stream(Http2Stream *stream)
     if (total_client_streams_count == 0 && ua_session->is_active()) {
       ua_session->clear_session_active();
       UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(ua_session->get_netvc());
-      if (vc) {
-        vc->cancel_active_timeout();
+      if (vc && vc->active_timeout_in == 0) {
         vc->add_to_keep_alive_queue();
       }
     }
diff --git a/tests/gold_tests/h2/gold/active_timeout.gold b/tests/gold_tests/h2/gold/active_timeout.gold
new file mode 100644
index 0000000..5325cf1
--- /dev/null
+++ b/tests/gold_tests/h2/gold/active_timeout.gold
@@ -0,0 +1 @@
+CONNECTION_TIMEOUT
diff --git a/tests/gold_tests/h2/h2active_timeout.py b/tests/gold_tests/h2/h2active_timeout.py
new file mode 100644
index 0000000..b71608c
--- /dev/null
+++ b/tests/gold_tests/h2/h2active_timeout.py
@@ -0,0 +1,57 @@
+'''
+'''
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+import json
+from hyper import HTTPConnection
+import hyper
+import argparse
+import time
+
+
+def makerequest(port):
+    hyper.tls._context = hyper.tls.init_context()
+    hyper.tls._context.check_hostname = False
+    hyper.tls._context.verify_mode = hyper.compat.ssl.CERT_NONE
+
+    conn = HTTPConnection('localhost:{0}'.format(port), secure=True)
+
+    active_timeout = 3
+    request_interval = 0.1
+    loop_cnt = int((active_timeout + 2) / request_interval)
+    for i in range(loop_cnt):
+        try:
+            conn.request('GET', '/')
+            time.sleep(request_interval)
+        except:
+            print('CONNECTION_TIMEOUT')
+            return
+
+    print('NO_TIMEOUT')
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--port", "-p",
+                        type=int,
+                        help="Port to use")
+    args = parser.parse_args()
+    makerequest(args.port)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/tests/gold_tests/h2/http2.test.py b/tests/gold_tests/h2/http2.test.py
index 16fee95..cbb5b1f 100644
--- a/tests/gold_tests/h2/http2.test.py
+++ b/tests/gold_tests/h2/http2.test.py
@@ -30,7 +30,6 @@ Test.ContinueOnFail = True
 ts = Test.MakeATSProcess("ts", select_ports=False)
 server = Test.MakeOriginServer("server")
 
-
 requestLocation = "test2"
 reHost = "www.example.com"
 
@@ -66,17 +65,20 @@ ts.Disk.ssl_multicert_config.AddLine(
 )
 ts.Disk.records_config.update({
     'proxy.config.diags.debug.enabled': 1,
-    'proxy.config.diags.debug.tags': 'http|remap',
+    'proxy.config.diags.debug.tags': 'http|socket',
     'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir),
     'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir),
     # enable ssl port
     'proxy.config.http.server_ports': '{0} {1}:proto=http2;http:ssl'.format(ts.Variables.port, ts.Variables.ssl_port),
     'proxy.config.ssl.client.verify.server':  0,
     'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2',
+    'proxy.config.http2.active_timeout_in': 3,
+    'proxy.config.http2.max_concurrent_streams_in': 65535,
 })
 ts.Setup.CopyAs('h2client.py', Test.RunDirectory)
 ts.Setup.CopyAs('h2bigclient.py', Test.RunDirectory)
 ts.Setup.CopyAs('h2chunked.py', Test.RunDirectory)
+ts.Setup.CopyAs('h2active_timeout.py', Test.RunDirectory)
 
 # Test Case 1:  basic H2 interaction
 tr = Test.AddTestRun()
@@ -110,3 +112,10 @@ tr.Processes.Default.Command = "python3 {0} -type {1} -log_dir {2} -port {3} -ho
 tr.Processes.Default.ReturnCode = 0
 tr.Processes.Default.Streams.stdout = "gold/replay.gold"
 tr.StillRunningAfter = server
+
+# Test Case 5:h2_active_timeout
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = 'python3 h2active_timeout.py -p {0}'.format(ts.Variables.ssl_port)
+tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.All = "gold/active_timeout.gold"
+tr.StillRunningAfter = server

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].