You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2019/11/08 21:08:10 UTC

[trafficserver] branch 9.0.x updated (d6b2266 -> 3115d02)

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

zwoop pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


    from d6b2266  Explicit c:type:
     new 7e73a38  detect bogus jemalloc version
     new 97b55e7  Only decrement log_stat_log_files_open_stat when the file is closed.
     new ab5f56c  Normalize loopback usage in session_match autest
     new 3115d02  tests: Adds autest for WebSocket mappings

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 build/jemalloc.m4                                  | 13 +++-
 include/tscore/BaseLogFile.h                       |  2 +-
 include/tscore/JeAllocator.h                       |  3 +
 proxy/logging/LogFile.cc                           | 22 +++++--
 src/tscore/BaseLogFile.cc                          | 20 ++++--
 .../remap/gold/remap-ws-upgrade-400.gold           |  7 ++
 tests/gold_tests/remap/gold/remap-ws-upgrade.gold  | 11 ++++
 tests/gold_tests/remap/remap_ws.test.py            | 77 ++++++++++++++++++++++
 .../session_sharing/session_match.test.py          |  6 +-
 9 files changed, 145 insertions(+), 16 deletions(-)
 create mode 100644 tests/gold_tests/remap/gold/remap-ws-upgrade-400.gold
 create mode 100644 tests/gold_tests/remap/gold/remap-ws-upgrade.gold
 create mode 100644 tests/gold_tests/remap/remap_ws.test.py


[trafficserver] 02/04: Only decrement log_stat_log_files_open_stat when the file is closed.

Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 97b55e78b9fc9741e74230ff356c0c18cea4d4a8
Author: bneradt <bn...@verizonmedia.com>
AuthorDate: Mon Oct 28 22:00:55 2019 +0000

    Only decrement log_stat_log_files_open_stat when the file is closed.
    
    (cherry picked from commit 0db18c7af94e6d81d997a583035f8834aa0c8813)
---
 include/tscore/BaseLogFile.h |  2 +-
 proxy/logging/LogFile.cc     | 22 +++++++++++++++-------
 src/tscore/BaseLogFile.cc    | 20 ++++++++++++++++----
 3 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/include/tscore/BaseLogFile.h b/include/tscore/BaseLogFile.h
index 38f6a49..aad4735 100644
--- a/include/tscore/BaseLogFile.h
+++ b/include/tscore/BaseLogFile.h
@@ -177,7 +177,7 @@ public:
   static bool rolled_logfile(char *path);
   static bool exists(const char *pathname);
   int open_file(int perm = -1);
-  void close_file();
+  int close_file();
   void change_name(const char *new_name);
   void display(FILE *fd = stdout);
   const char *
diff --git a/proxy/logging/LogFile.cc b/proxy/logging/LogFile.cc
index d0b95da..59c6bde 100644
--- a/proxy/logging/LogFile.cc
+++ b/proxy/logging/LogFile.cc
@@ -258,18 +258,24 @@ LogFile::close_file()
 {
   if (is_open()) {
     if (m_file_format == LOG_FILE_PIPE) {
-      ::close(m_fd);
-      Debug("log-file", "LogFile %s (fd=%d) is closed", m_name, m_fd);
+      if (::close(m_fd)) {
+        Error("Error closing LogFile %s: %s.", m_name, strerror(errno));
+      } else {
+        Debug("log-file", "LogFile %s (fd=%d) is closed", m_name, m_fd);
+        RecIncrRawStat(log_rsb, this_thread()->mutex->thread_holding, log_stat_log_files_open_stat, -1);
+      }
       m_fd = -1;
     } else if (m_log) {
-      m_log->close_file();
-      Debug("log-file", "LogFile %s is closed", m_log->get_name());
+      if (m_log->close_file()) {
+        Error("Error closing LogFile %s: %s.", m_log->get_name(), strerror(errno));
+      } else {
+        Debug("log-file", "LogFile %s is closed", m_log->get_name());
+        RecIncrRawStat(log_rsb, this_thread()->mutex->thread_holding, log_stat_log_files_open_stat, -1);
+      }
     } else {
       Warning("LogFile %s is open but was not closed", m_name);
     }
   }
-
-  RecIncrRawStat(log_rsb, this_thread()->mutex->thread_holding, log_stat_log_files_open_stat, -1);
 }
 
 struct RolledFile {
@@ -369,7 +375,9 @@ LogFile::roll(long interval_start, long interval_end, bool reopen_after_rolling)
     // Since these two methods of using BaseLogFile are not compatible, we perform the logging log file specific
     // close file operation here within the containing LogFile object.
     if (m_log->roll(interval_start, interval_end)) {
-      m_log->close_file();
+      if (m_log->close_file()) {
+        Error("Error closing LogFile %s: %s.", m_log->get_name(), strerror(errno));
+      }
 
       if (reopen_after_rolling) {
         /* If we re-open now log file will be created even if there is nothing being logged */
diff --git a/src/tscore/BaseLogFile.cc b/src/tscore/BaseLogFile.cc
index 1dac88f..26f567e 100644
--- a/src/tscore/BaseLogFile.cc
+++ b/src/tscore/BaseLogFile.cc
@@ -339,18 +339,30 @@ BaseLogFile::open_file(int perm)
   return LOG_FILE_NO_ERROR;
 }
 
-/*
- * Closes actual log file, not metainfo
+/**
+ * @brief Close the managed log file.
+ *
+ * @note This closes the actual log file, not its metainfo.
+ *
+ * @return The result of calling fclose on the file descriptor or 0 if the file
+ * was not open. If the result is non-zero, fclose failed and errno is set
+ * appropriately.
  */
-void
+int
 BaseLogFile::close_file()
 {
+  int ret = 0;
   if (is_open()) {
-    fclose(m_fp);
     log_log_trace("BaseLogFile %s is closed\n", m_name.get());
+
+    // Both log_log_trace and fclose may set errno. Thus, keep fclose after
+    // log_log_trace so that by the time this function completes if errno was
+    // set by fclose it will remain upon function return.
+    ret       = fclose(m_fp);
     m_fp      = nullptr;
     m_is_init = false;
   }
+  return ret;
 }
 
 /*


[trafficserver] 04/04: tests: Adds autest for WebSocket mappings

Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 3115d02c16286e4180dfca7261b0e65f4ac3039c
Author: Randall Meyer <rr...@apache.org>
AuthorDate: Mon Nov 4 18:08:35 2019 -0800

    tests: Adds autest for WebSocket mappings
    
    (cherry picked from commit 5902d863869e7cc5147866d96bb8efe30b241668)
---
 .../remap/gold/remap-ws-upgrade-400.gold           |  7 ++
 tests/gold_tests/remap/gold/remap-ws-upgrade.gold  | 11 ++++
 tests/gold_tests/remap/remap_ws.test.py            | 77 ++++++++++++++++++++++
 3 files changed, 95 insertions(+)

diff --git a/tests/gold_tests/remap/gold/remap-ws-upgrade-400.gold b/tests/gold_tests/remap/gold/remap-ws-upgrade-400.gold
new file mode 100644
index 0000000..a46a249
--- /dev/null
+++ b/tests/gold_tests/remap/gold/remap-ws-upgrade-400.gold
@@ -0,0 +1,7 @@
+``
+> GET /chat HTTP/1.1
+> Host: ``
+> User-Agent: curl/``
+``
+< HTTP/1.1 400 Invalid Upgrade Request
+``
diff --git a/tests/gold_tests/remap/gold/remap-ws-upgrade.gold b/tests/gold_tests/remap/gold/remap-ws-upgrade.gold
new file mode 100644
index 0000000..317fee1
--- /dev/null
+++ b/tests/gold_tests/remap/gold/remap-ws-upgrade.gold
@@ -0,0 +1,11 @@
+``
+> GET /chat HTTP/1.1
+> Host: ``
+> User-Agent: curl/``
+``
+< HTTP/1.1 101 Switching Protocols
+< Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
+< Date: ``
+< Connection: Upgrade
+< Upgrade: websocket
+``
diff --git a/tests/gold_tests/remap/remap_ws.test.py b/tests/gold_tests/remap/remap_ws.test.py
new file mode 100644
index 0000000..5379c4d
--- /dev/null
+++ b/tests/gold_tests/remap/remap_ws.test.py
@@ -0,0 +1,77 @@
+'''
+'''
+#  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.
+
+Test.Summary = '''
+Test a basic remap of a websocket connections
+'''
+
+Test.ContinueOnFail = True
+
+ts = Test.MakeATSProcess("ts", select_ports=False)
+server = Test.MakeOriginServer("server")
+
+testName = "Test WebSocket Remaps"
+request_header = {"headers": "GET /chat HTTP/1.1\r\nHost: www.example.com\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n\r\n",
+                  "body": None}
+response_header = {"headers": "HTTP/1.1 101 OK\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n\r\n",
+                   "body": None}
+server.addResponse("sessionlog.json", request_header, response_header)
+
+ts.addSSLfile("ssl/server.pem")
+ts.addSSLfile("ssl/server.key")
+
+ts.Disk.records_config.update({
+    'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir),
+    'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir),
+    'proxy.config.http.server_ports': '{0} {1}:proto=http2;http:ssl'.format(ts.Variables.port, ts.Variables.ssl_port),
+})
+
+ts.Disk.remap_config.AddLines([
+    'map ws://www.example.com:{1} ws://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.port),
+    'map wss://www.example.com:{1} ws://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port)
+])
+
+ts.Disk.ssl_multicert_config.AddLine(
+    'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key'
+)
+
+# wss mapping
+tr = Test.AddTestRun()
+tr.Processes.Default.StartBefore(server)
+tr.Processes.Default.StartBefore(Test.Processes.ts, ready=1)
+tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k https://www.example.com:{0}/chat'.format(ts.Variables.ssl_port)
+tr.Processes.Default.ReturnCode = 28
+tr.Processes.Default.Streams.stderr = "gold/remap-ws-upgrade.gold"
+tr.StillRunningAfter = server
+tr.StillRunningAfter = ts
+
+# ws mapping
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" -H "Sec-WebSocket-Version: 13" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k http://www.example.com:{0}/chat'.format(ts.Variables.port)
+tr.Processes.Default.ReturnCode = 28
+tr.Processes.Default.Streams.stderr = "gold/remap-ws-upgrade.gold"
+tr.StillRunningAfter = server
+tr.StillRunningAfter = ts
+
+# Missing required headers (should result in 400)
+tr = Test.AddTestRun()
+tr.Processes.Default.Command = 'curl --max-time 2 -v -s -q -H "Connection: Upgrade" -H "Upgrade: websocket" --http1.1 --resolve www.example.com:{0}:127.0.0.1 -k http://www.example.com:{0}/chat'.format(ts.Variables.port)
+tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.stderr = "gold/remap-ws-upgrade-400.gold"
+tr.StillRunningAfter = server
+tr.StillRunningAfter = ts


[trafficserver] 01/04: detect bogus jemalloc version

Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 7e73a385d3f13ea31faf0c6b5da23e19993f1db5
Author: Fei Deng <du...@gmail.com>
AuthorDate: Fri Nov 8 13:44:16 2019 -0600

    detect bogus jemalloc version
    
    (cherry picked from commit 02c0e5b4e2b14fc2fab567762e24a1aede3f7e29)
---
 build/jemalloc.m4            | 13 ++++++++++++-
 include/tscore/JeAllocator.h |  3 +++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/build/jemalloc.m4 b/build/jemalloc.m4
index 48b2cdc..6b707cd 100644
--- a/build/jemalloc.m4
+++ b/build/jemalloc.m4
@@ -68,7 +68,18 @@ if test "$enable_jemalloc" != "no"; then
     AC_CHECK_HEADERS(jemalloc/jemalloc.h, [jemalloc_have_headers=1])
   fi
   if test "$jemalloc_have_headers" != "0"; then
-    jemalloch=1
+    AC_RUN_IFELSE([
+      AC_LANG_PROGRAM(
+        [#include <jemalloc/jemalloc.h>],
+        [
+          #if (JEMALLOC_VERSION_MAJOR == 0)
+          exit(1);
+          #endif
+        ]
+      )],
+      [jemalloch=1],
+      [AC_MSG_ERROR(jemalloc has bogus version)]
+    )
   else
     CPPFLAGS=$saved_cppflags
     LDFLAGS=$saved_ldflags
diff --git a/include/tscore/JeAllocator.h b/include/tscore/JeAllocator.h
index 7d1b678..24e94d9 100644
--- a/include/tscore/JeAllocator.h
+++ b/include/tscore/JeAllocator.h
@@ -26,6 +26,9 @@
 
 #if TS_HAS_JEMALLOC
 #include <jemalloc/jemalloc.h>
+#if (JEMALLOC_VERSION_MAJOR == 0)
+#error jemalloc has bogus version
+#endif
 #if (JEMALLOC_VERSION_MAJOR == 5) && defined(MADV_DONTDUMP)
 #define JEMALLOC_NODUMP_ALLOCATOR_SUPPORTED 1
 #endif /* MADV_DONTDUMP */


[trafficserver] 03/04: Normalize loopback usage in session_match autest

Posted by zw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit ab5f56c08ebcf5e17525ceb15611320cda77db61
Author: Randall Meyer <rr...@apache.org>
AuthorDate: Fri Nov 1 16:46:03 2019 -0700

    Normalize loopback usage in session_match autest
    
    (cherry picked from commit 07e6e2d4243ef218410b6dff22f85cfb314492cd)
---
 tests/gold_tests/session_sharing/session_match.test.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/gold_tests/session_sharing/session_match.test.py b/tests/gold_tests/session_sharing/session_match.test.py
index 2e619e5..20dcd61 100644
--- a/tests/gold_tests/session_sharing/session_match.test.py
+++ b/tests/gold_tests/session_sharing/session_match.test.py
@@ -70,9 +70,9 @@ class SessionMatchTest:
 
     def _runTraffic(self):
         self._tr.Processes.Default.Command = (
-                'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.1:{port}/one &&'
-                'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.1:{port}/two &&'
-                'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.1:{port}/three'.format(
+                'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/one &&'
+                'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/two &&'
+                'curl -v -H\'Host: www.example.com\' -H\'Connection: close\' http://127.0.0.1:{port}/three'.format(
                     port = self._ts.Variables.port))
         self._tr.Processes.Default.ReturnCode = 0
         self._tr.Processes.Default.StartBefore(self._server)