You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2024/03/19 15:06:19 UTC

(trafficserver) branch 10.0.x updated (3d86f0e254 -> edd59eae0c)

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

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


    from 3d86f0e254 set CMAKE_HOST for TS_BUILD_CANONICAL_HOST (#11154)
     new 0d02f591e4 set compile definition to turn on maxminddb (#11169)
     new f9438b87b1 Restore alignment for structs stored in cache (#11167)
     new da873dcb99 Adds TSHttpTxnErrorBodyGet() corresponding to the Set (#11163)
     new 8b455373bd Fix a build error (#11162)
     new 5eaa0cea10 Fixed asan issue for test_AIO when an argument wasn't set on the command line (#11139)
     new edd59eae0c Fix asan and valgrind issue with libswoc unit test (#11138)

The 6 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:
 .../api/functions/TSHttpTxnErrorBodySet.en.rst     | 21 ++++++++++++
 include/proxy/hdrs/HTTP.h                          | 12 +++----
 include/proxy/hdrs/HdrHeap.h                       |  9 +++---
 include/ts/ts.h                                    | 10 ++++++
 lib/swoc/unit_tests/ex_IntrusiveDList.cc           |  6 ++++
 lib/swoc/unit_tests/ex_MemArena.cc                 |  3 ++
 lib/swoc/unit_tests/test_IntrusiveDList.cc         | 37 ++++++++++++++++++++++
 lib/swoc/unit_tests/test_IntrusiveHashMap.cc       | 13 +++++++-
 lib/swoc/unit_tests/test_ip.cc                     |  2 +-
 plugins/header_rewrite/CMakeLists.txt              |  1 +
 src/api/InkAPI.cc                                  | 19 +++++++++++
 src/iocore/aio/test_AIO.cc                         | 24 ++++++++------
 src/iocore/net/quic/QUICTypes.cc                   |  1 +
 13 files changed, 136 insertions(+), 22 deletions(-)


(trafficserver) 06/06: Fix asan and valgrind issue with libswoc unit test (#11138)

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

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

commit edd59eae0cdbae01597be7df3fcce454ee37c839
Author: Bryan Call <bc...@apache.org>
AuthorDate: Wed Mar 13 08:42:46 2024 -0700

    Fix asan and valgrind issue with libswoc unit test (#11138)
    
    (cherry picked from commit 0bde81a7fac7513ee19e0b6ce4f3c42cf27bc7ea)
---
 lib/swoc/unit_tests/ex_IntrusiveDList.cc     |  6 +++++
 lib/swoc/unit_tests/ex_MemArena.cc           |  3 +++
 lib/swoc/unit_tests/test_IntrusiveDList.cc   | 37 ++++++++++++++++++++++++++++
 lib/swoc/unit_tests/test_IntrusiveHashMap.cc | 13 +++++++++-
 lib/swoc/unit_tests/test_ip.cc               |  2 +-
 5 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/lib/swoc/unit_tests/ex_IntrusiveDList.cc b/lib/swoc/unit_tests/ex_IntrusiveDList.cc
index 3c59a9ed47..a26f386662 100644
--- a/lib/swoc/unit_tests/ex_IntrusiveDList.cc
+++ b/lib/swoc/unit_tests/ex_IntrusiveDList.cc
@@ -212,4 +212,10 @@ TEST_CASE("IntrusiveDList Inheritance", "[libswoc][IntrusiveDList][example]") {
   }
   REQUIRE(priv2_list.head()->payload() == "Item 1");
   REQUIRE(priv2_list.tail()->payload() == "Item 23");
+
+  // Delete everything in priv_list.
+  priv_list.apply([](PrivateThing *thing) { delete thing; });
+
+  // Delete everything in priv2_list.
+  priv2_list.apply([](PrivateThing2 *thing) { delete thing; });
 }
diff --git a/lib/swoc/unit_tests/ex_MemArena.cc b/lib/swoc/unit_tests/ex_MemArena.cc
index a6f7098e57..e0e9a038f9 100644
--- a/lib/swoc/unit_tests/ex_MemArena.cc
+++ b/lib/swoc/unit_tests/ex_MemArena.cc
@@ -221,4 +221,7 @@ TEST_CASE("MemArena example", "[libswoc][MemArena][example]") {
   REQUIRE(arena.contains(ihm));
   REQUIRE(arena.contains(thing));
   REQUIRE(arena.contains(thing->name.data()));
+
+  // Call the destructor for the IntrusiveHashMap to free anything it allocated.
+  ihm->~Map();
 };
diff --git a/lib/swoc/unit_tests/test_IntrusiveDList.cc b/lib/swoc/unit_tests/test_IntrusiveDList.cc
index 51f57a09e8..96c3e6f61e 100644
--- a/lib/swoc/unit_tests/test_IntrusiveDList.cc
+++ b/lib/swoc/unit_tests/test_IntrusiveDList.cc
@@ -118,6 +118,7 @@ TEST_CASE("IntrusiveDList", "[libswoc][IntrusiveDList]") {
 
   list.append(thing);
   list.erase(list.tail());
+  delete thing; // this deletes "two"
   REQUIRE(list.count() == 3);
   REQUIRE(list.tail() != nullptr);
   REQUIRE(list.tail()->_payload == "muddle");
@@ -126,6 +127,9 @@ TEST_CASE("IntrusiveDList", "[libswoc][IntrusiveDList]") {
   list.insert_before(list.end(), new Thing("trailer"));
   REQUIRE(list.count() == 4);
   REQUIRE(list.tail()->_payload == "trailer");
+
+  // Delete everything in list.
+  list.apply([](Thing *thing) { delete thing; });
 }
 
 TEST_CASE("IntrusiveDList list prefix", "[libswoc][IntrusiveDList]") {
@@ -174,6 +178,21 @@ TEST_CASE("IntrusiveDList list prefix", "[libswoc][IntrusiveDList]") {
   REQUIRE(list_rest.head()->_payload == "16");
   REQUIRE(list.count() == 0);
   REQUIRE(list.head() == nullptr);
+
+  // Delete everything in list.
+  list.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_1.
+  list_1.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_5.
+  list_5.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_most.
+  list_most.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_rest.
+  list_rest.apply([](Thing *thing) { delete thing; });
 }
 
 TEST_CASE("IntrusiveDList list suffix", "[libswoc][IntrusiveDList]") {
@@ -230,6 +249,21 @@ TEST_CASE("IntrusiveDList list suffix", "[libswoc][IntrusiveDList]") {
   REQUIRE(list.tail()->_payload == "20");
   REQUIRE(list.nth(7)->_payload == "8");
   REQUIRE(list.nth(17)->_payload == "18");
+
+  // Delete everything in list.
+  list.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_1.
+  list_1.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_5.
+  list_5.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_most.
+  list_most.apply([](Thing *thing) { delete thing; });
+
+  // Delete everything in list_rest.
+  list_rest.apply([](Thing *thing) { delete thing; });
 }
 
 TEST_CASE("IntrusiveDList Extra", "[libswoc][IntrusiveDList]") {
@@ -269,4 +303,7 @@ TEST_CASE("IntrusiveDList Extra", "[libswoc][IntrusiveDList]") {
     bwprint(tmp, "{}", idx);
     REQUIRE(spot->_payload == tmp);
   }
+
+  // Delete everything in list.
+  list.apply([](Thing *thing) { delete thing; });
 }
diff --git a/lib/swoc/unit_tests/test_IntrusiveHashMap.cc b/lib/swoc/unit_tests/test_IntrusiveHashMap.cc
index aa228ba8e0..cd4db95329 100644
--- a/lib/swoc/unit_tests/test_IntrusiveHashMap.cc
+++ b/lib/swoc/unit_tests/test_IntrusiveHashMap.cc
@@ -158,9 +158,12 @@ TEST_CASE("IntrusiveHashMap", "[libts][IntrusiveHashMap]") {
 
   // Erase all the non-"dup" and see if the range is still correct.
   map.apply([&map](Thing &thing) {
-    if (thing._payload != "dup"sv)
+    if (thing._payload != "dup"sv) {
       map.erase(map.iterator_for(&thing));
+      delete &thing;
+    }
   });
+
   r = map.equal_range("dup"sv);
   REQUIRE(r.first != r.second);
   idx = r.first;
@@ -269,6 +272,14 @@ TEST_CASE("IntrusiveHashMapManyStrings", "[IntrusiveHashMap]") {
     }
   }
   REQUIRE(miss_p == false);
+
+  // Delete everything in strings.
+  for (auto &&s : strings) {
+    free(const_cast<char *>(s.data()));
+  }
+
+  // Delete everything in ihm.
+  ihm.apply([](Thing *thing) { delete thing; });
 };
 
 TEST_CASE("IntrusiveHashMap Utilities", "[IntrusiveHashMap]") {}
diff --git a/lib/swoc/unit_tests/test_ip.cc b/lib/swoc/unit_tests/test_ip.cc
index 178e85b72a..2c7aa7ce39 100644
--- a/lib/swoc/unit_tests/test_ip.cc
+++ b/lib/swoc/unit_tests/test_ip.cc
@@ -1094,7 +1094,7 @@ TEST_CASE("IPSpace bitset", "[libswoc][ipspace][bitset]") {
   using PAYLOAD = std::bitset<32>;
   using Space   = swoc::IPSpace<PAYLOAD>;
 
-  std::array<std::tuple<TextView, std::initializer_list<unsigned>>, 6> ranges = {
+  std::vector<std::tuple<TextView, std::vector<unsigned>>> ranges = {
     {{"172.28.56.12-172.28.56.99"_tv, {0, 2, 3}},
      {"10.10.35.0/24"_tv, {1, 2}},
      {"192.168.56.0/25"_tv, {10, 12, 31}},


(trafficserver) 01/06: set compile definition to turn on maxminddb (#11169)

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

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

commit 0d02f591e400531655991ecc059443e842111620
Author: Chris McFarlen <ch...@mcfarlen.us>
AuthorDate: Mon Mar 18 17:34:12 2024 -0500

    set compile definition to turn on maxminddb (#11169)
    
    (cherry picked from commit e1e8e434d3b3b27561a14bc09fec3d37c4ec0dc2)
---
 plugins/header_rewrite/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/header_rewrite/CMakeLists.txt b/plugins/header_rewrite/CMakeLists.txt
index af70193541..d5b53916ae 100644
--- a/plugins/header_rewrite/CMakeLists.txt
+++ b/plugins/header_rewrite/CMakeLists.txt
@@ -42,6 +42,7 @@ target_link_libraries(
 )
 
 if(maxminddb_FOUND)
+  target_compile_definitions(header_rewrite PUBLIC TS_USE_HRW_MAXMINDDB=1)
   target_sources(header_rewrite PRIVATE conditions_geo_maxmind.cc)
   target_link_libraries(header_rewrite PRIVATE maxminddb::maxminddb)
 endif()


(trafficserver) 03/06: Adds TSHttpTxnErrorBodyGet() corresponding to the Set (#11163)

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

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

commit da873dcb9963218faefc166dc4fc97ded8b88463
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Mon Mar 18 14:44:46 2024 -0600

    Adds TSHttpTxnErrorBodyGet() corresponding to the Set (#11163)
    
    * Adds TSHttpTxnErrorBodyGet() corresponding to the Set
    
    * Adds documentation
    
    (cherry picked from commit 98e60108c8a527ab630344639b417f8c2fbdb411)
---
 .../api/functions/TSHttpTxnErrorBodySet.en.rst      | 21 +++++++++++++++++++++
 include/ts/ts.h                                     | 10 ++++++++++
 src/api/InkAPI.cc                                   | 19 +++++++++++++++++++
 3 files changed, 50 insertions(+)

diff --git a/doc/developer-guide/api/functions/TSHttpTxnErrorBodySet.en.rst b/doc/developer-guide/api/functions/TSHttpTxnErrorBodySet.en.rst
index 082ba18d7b..89b602dd7c 100644
--- a/doc/developer-guide/api/functions/TSHttpTxnErrorBodySet.en.rst
+++ b/doc/developer-guide/api/functions/TSHttpTxnErrorBodySet.en.rst
@@ -39,3 +39,24 @@ Note that both string arguments must be allocated with :c:func:`TSmalloc` or
 :c:func:`TSstrdup`.  The :arg:`mimetype` is optional, and if not provided it
 defaults to :literal:`text/html`. Sending an empty string would prevent setting
 a content type header (but that is not advised).
+
+
+TSHttpTxnErrorBodyGet
+*********************
+
+Gets the error body as set above.
+
+Synopsis
+========
+
+.. code-block:: cpp
+
+    #include <ts/ts.h>
+
+.. function:: char * TSHttpTxnErrorBodyGet(TSHttpTxn txnp, size_t *buflength, char **mimetype)
+
+Description
+===========
+
+This is the getter version for the above setter. The :arg:`mimetype` and the :arg:`buflength`
+arguments can be :const:`nullptr` if the caller is not interested in the mimetype or the length.
diff --git a/include/ts/ts.h b/include/ts/ts.h
index b244610a8b..956963faae 100644
--- a/include/ts/ts.h
+++ b/include/ts/ts.h
@@ -1599,6 +1599,16 @@ TSReturnCode TSHttpTxnServerPacketDscpSet(TSHttpTxn txnp, int dscp);
 */
 void TSHttpTxnErrorBodySet(TSHttpTxn txnp, char *buf, size_t buflength, char *mimetype);
 
+/**
+   Retrives the error body, if any, from a transaction. This would be a body as set
+   via the API body.
+
+   @param txnp HTTP transaction whose parent proxy to get.
+   @param buflength Optional outpu pointer to the length of the body message.
+   @param mimetype Optional output pointer to the MIME type of the response.
+*/
+char *TSHttpTxnErrorBodyGet(TSHttpTxn txnp, size_t *buflength, char **mimetype);
+
 /**
     Retrieves the parent proxy hostname and port, if parent
     proxying is enabled. If parent proxying is not enabled,
diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc
index dffa5d236a..17c10b3bba 100644
--- a/src/api/InkAPI.cc
+++ b/src/api/InkAPI.cc
@@ -4760,6 +4760,25 @@ TSHttpTxnErrorBodySet(TSHttpTxn txnp, char *buf, size_t buflength, char *mimetyp
   s->internal_msg_buffer_type = mimetype;
 }
 
+char *
+TSHttpTxnErrorBodyGet(TSHttpTxn txnp, size_t *buflength, char **mimetype)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+
+  HttpSM *sm             = (HttpSM *)txnp;
+  HttpTransact::State *s = &(sm->t_state);
+
+  if (buflength) {
+    *buflength = s->internal_msg_buffer_size;
+  }
+
+  if (mimetype) {
+    *mimetype = s->internal_msg_buffer_type;
+  }
+
+  return s->internal_msg_buffer;
+}
+
 void
 TSHttpTxnServerRequestBodySet(TSHttpTxn txnp, char *buf, int64_t buflength)
 {


(trafficserver) 05/06: Fixed asan issue for test_AIO when an argument wasn't set on the command line (#11139)

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

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

commit 5eaa0cea108f78b439341a99cc58506a16b8650b
Author: Bryan Call <bc...@apache.org>
AuthorDate: Wed Mar 13 08:44:18 2024 -0700

    Fixed asan issue for test_AIO when an argument wasn't set on the command line (#11139)
    
    (cherry picked from commit b7e33af35f65322100fffc07f7152b0514573c9f)
---
 src/iocore/aio/test_AIO.cc | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/iocore/aio/test_AIO.cc b/src/iocore/aio/test_AIO.cc
index 3daa770d52..d08eb4b62d 100644
--- a/src/iocore/aio/test_AIO.cc
+++ b/src/iocore/aio/test_AIO.cc
@@ -361,16 +361,13 @@ int
 read_config(const char *config_filename)
 {
   std::ifstream fin(config_filename);
+  if (!fin.rdbuf()->is_open()) {
+    return (0);
+  }
+
   char field_name[256];
   char field_value[256];
 
-  if (!fin.rdbuf()->is_open()) {
-    fin.open("sample.cfg");
-    if (!fin.rdbuf()->is_open()) {
-      cout << "cannot open config files " << config_filename << endl;
-      return (0);
-    }
-  }
   while (!fin.eof()) {
     field_name[0] = '\0';
     fin >> field_name;
@@ -459,13 +456,20 @@ public:
 #endif
 
 int
-main(int /* argc ATS_UNUSED */, char *argv[])
+main(int argc, char *argv[])
 {
   int i;
-  printf("input file %s\n", argv[1]);
-  if (!read_config(argv[1])) {
+
+  // Read the configuration file
+  const char *config_filename = "sample.cfg";
+  if (argc == 2) {
+    config_filename = argv[1];
+  }
+  printf("configuration file: %s\n", config_filename);
+  if (!read_config(config_filename)) {
     exit(1);
   }
+
   if (num_processors == 0) {
     num_processors = ink_number_of_processors();
   }


(trafficserver) 02/06: Restore alignment for structs stored in cache (#11167)

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

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

commit f9438b87b1975cab6e15bdfbabed09a6c7754b3d
Author: Chris McFarlen <ch...@mcfarlen.us>
AuthorDate: Mon Mar 18 17:33:52 2024 -0500

    Restore alignment for structs stored in cache (#11167)
    
    (cherry picked from commit b4f1fcacb94f4a2c20491a33e9d448c64f9497a1)
---
 include/proxy/hdrs/HTTP.h    | 12 ++++++------
 include/proxy/hdrs/HdrHeap.h |  9 +++++----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/proxy/hdrs/HTTP.h b/include/proxy/hdrs/HTTP.h
index d85ac9dc65..beffc8eb6d 100644
--- a/include/proxy/hdrs/HTTP.h
+++ b/include/proxy/hdrs/HTTP.h
@@ -480,19 +480,19 @@ class HTTPHdr : public MIMEHdr
 public:
   HTTPHdrImpl *m_http = nullptr;
   mutable URL m_url_cached;
-  mutable bool m_100_continue_required = false; ///< Whether 100_continue is in the Expect header.
-  mutable bool m_target_in_url         = false; ///< Whether host name and port are in the URL.
+  mutable MIMEField *m_host_mime       = nullptr;
+  mutable int m_host_length            = 0;     ///< Length of hostname.
+  mutable int m_port                   = 0;     ///< Target port.
   mutable bool m_target_cached         = false; ///< Whether host name and port are cached.
-  mutable bool early_data              = false;
+  mutable bool m_target_in_url         = false; ///< Whether host name and port are in the URL.
+  mutable bool m_100_continue_required = false; ///< Whether 100_continue is in the Expect header.
   /// Set if the port was effectively specified in the header.
   /// @c true if the target (in the URL or the HOST field) also specified
   /// a port. That is, @c true if whatever source had the target host
   /// also had a port, @c false otherwise.
   mutable bool m_port_in_header = false;
 
-  mutable int m_port             = 0; ///< Target port.
-  mutable int m_host_length      = 0; ///< Length of hostname.
-  mutable MIMEField *m_host_mime = nullptr;
+  mutable bool early_data = false;
 
   HTTPHdr() = default; // Force the creation of the default constructor
 
diff --git a/include/proxy/hdrs/HdrHeap.h b/include/proxy/hdrs/HdrHeap.h
index f2a5cb335b..61145342f5 100644
--- a/include/proxy/hdrs/HdrHeap.h
+++ b/include/proxy/hdrs/HdrHeap.h
@@ -271,13 +271,11 @@ public:
   void dump_heap(int len = -1);
 
   uint32_t m_magic;
-  bool m_writeable;
   char *m_free_start;
   char *m_data_start;
   uint32_t m_size;
 
-  // HdrBuf heap pointers
-  uint32_t m_free_size;
+  bool m_writeable;
 
   // Overflow block ptr
   //   Overflow blocks are necessary because we can
@@ -288,6 +286,9 @@ public:
   //    point to string heaps
   HdrHeap *m_next;
 
+  // HdrBuf heap pointers
+  uint32_t m_free_size;
+
   int demote_rw_str_heap();
   void coalesce_str_heaps(int incoming_size = 0);
   void evacuate_from_str_heaps(HdrStrHeap *new_heap);
@@ -330,8 +331,8 @@ public:
 
   // String Heap access
   Ptr<HdrStrHeap> m_read_write_heap;
-  int m_lost_string_space;
   StrHeapDesc m_ronly_heap[HDR_BUF_RONLY_HEAPS];
+  int m_lost_string_space;
 };
 
 static constexpr HdrHeapMarshalBlocks HDR_HEAP_HDR_SIZE{swoc::round_up(sizeof(HdrHeap))};


(trafficserver) 04/06: Fix a build error (#11162)

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

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

commit 8b455373bd1a73dfbbea5c3f5d0031e861ba8d69
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Thu Mar 14 16:18:55 2024 -0600

    Fix a build error (#11162)
    
    Before #10986 sstream was indirectly included by tscore/Errata.h but now it's not with libswoc.
    
    (cherry picked from commit 62eb17c107bb656cab6a12afc469027ceec72efa)
---
 src/iocore/net/quic/QUICTypes.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/iocore/net/quic/QUICTypes.cc b/src/iocore/net/quic/QUICTypes.cc
index e037463af8..8d35844920 100644
--- a/src/iocore/net/quic/QUICTypes.cc
+++ b/src/iocore/net/quic/QUICTypes.cc
@@ -24,6 +24,7 @@
 #include <algorithm>
 #include <iomanip>
 #include <iostream>
+#include <sstream>
 
 #include "iocore/net/quic/QUICTypes.h"
 #include "iocore/net/quic/QUICIntUtil.h"