You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bn...@apache.org on 2025/10/07 22:51:44 UTC
(trafficserver-libswoc) branch master updated (93a4d71 -> 372c9a5)
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
from 93a4d71 A few updates to the doc generation (#7)
new e8c29e0 proxy.config.http.per_client.connection.exempt_list
new 8870ee1 Remove maybe problematic constructors on storage_type (#12493)
new 27269ba test_ip.cc updates
new 169cfab Catch2: update to v3.9.1 (#12453)
new 385dc6b Fix build for clang 20 (#12202)
new 7627e06 -std=c++20: Remove TextView space before _sv/_tv literal (#12164)
new 372c9a5 GCC 15: Address mismatched-new-delete in MemArena::Block (#12163)
The 7 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:
code/include/swoc/IPRange.h | 29 ++++++++++++---------------
code/include/swoc/MemArena.h | 40 +++++++++++++++++++++++++++++++++++++
code/include/swoc/TextView.h | 4 ++--
code/src/MemArena.cc | 6 ++----
code/src/swoc_ip.cc | 4 ++--
unit_tests/ex_IntrusiveDList.cc | 2 +-
unit_tests/ex_Lexicon.cc | 2 +-
unit_tests/ex_MemArena.cc | 2 +-
unit_tests/ex_TextView.cc | 2 +-
unit_tests/ex_UnitParser.cc | 2 +-
unit_tests/ex_bw_format.cc | 2 +-
unit_tests/ex_ipspace_properties.cc | 2 +-
unit_tests/test_BufferWriter.cc | 2 +-
unit_tests/test_Errata.cc | 2 +-
unit_tests/test_IntrusiveDList.cc | 2 +-
unit_tests/test_IntrusiveHashMap.cc | 2 +-
unit_tests/test_Lexicon.cc | 2 +-
unit_tests/test_MemArena.cc | 3 ++-
unit_tests/test_MemSpan.cc | 2 +-
unit_tests/test_Scalar.cc | 2 +-
unit_tests/test_TextView.cc | 6 ++++--
unit_tests/test_Vectray.cc | 2 +-
unit_tests/test_bw_format.cc | 3 ++-
unit_tests/test_ip.cc | 11 ++++++----
unit_tests/test_meta.cc | 2 +-
unit_tests/test_range.cc | 2 +-
unit_tests/test_swoc_file.cc | 2 +-
unit_tests/unit_test_main.cc | 4 ++--
28 files changed, 94 insertions(+), 52 deletions(-)
(trafficserver-libswoc) 07/07: GCC 15: Address mismatched-new-delete in MemArena::Block (#12163)
Posted by bn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit 372c9a547170f8b3312cd9792621d19982816de7
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Fri Apr 4 15:43:38 2025 -0500
GCC 15: Address mismatched-new-delete in MemArena::Block (#12163)
This addresses a GCC 15 compiler warning about mismatched std operator
new and overridden operator delete in MemArena. This patch addresses the
warning by also overriding operator new for the MemArena::Block.
This is the warning being addressed:
```
code/src/MemArena.cc: In member function ‘swoc::_1_5_14::MemArena::Block* swoc::_1_5_14::MemArena::make_block(size_t)’:
code/src/MemArena.cc:99:44: error: ‘static void swoc::_1_5_14::MemArena::Block::operator delete(void*, void*)’ called on pointer returned from a mismatched allocation function [-Werror=mism
atched-new-delete]
99 | return new (::malloc(n)) Block(free_space);
| ^
src/ts_asf_master_fix_builds_for_fedora_42/code/src/MemArena.cc:99:23: note: returned from ‘void* malloc(size_t)’
99 | return new (::malloc(n)) Block(free_space);
| ~~~~~~~~^~~
```
---
code/include/swoc/MemArena.h | 40 ++++++++++++++++++++++++++++++++++++++++
code/src/MemArena.cc | 6 ++----
2 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/code/include/swoc/MemArena.h b/code/include/swoc/MemArena.h
index e0b25fb..f960599 100644
--- a/code/include/swoc/MemArena.h
+++ b/code/include/swoc/MemArena.h
@@ -9,6 +9,8 @@
#include <mutex>
#include <memory>
+#include <stdexcept>
+#include <type_traits>
#include <utility>
#include <new>
#if __has_include(<memory_resource>)
@@ -124,6 +126,24 @@ public:
protected:
friend MemArena; ///< Container.
+ /** A custom @c operator @c new.
+ *
+ * Compilers complain about mismatched std operator new and the custom
+ * operator delete unless this custom operator new is provided.
+ *
+ * @param block_size The implicit compiler-provided sizeof(Block), the object size.
+ * @param n The number of bytes the user is requesting for the backend storage of Block.
+ * @return Pointer to the allocated memory.
+ */
+ static void* operator new(size_t block_size, size_t n);
+
+ /** Override placement (non-allocated) @c new.
+ * @param block_size The implicit compiler-provided sizeof(Block), the object size. Not used.
+ * @param place Value passed to @c new.
+ * @return Pointer to the memory.
+ */
+ static void* operator new([[maybe_unused]] size_t block_size, void* place) noexcept;
+
/** Override @c operator @c delete.
*
* This is required because the allocated memory size is larger than the class size which
@@ -641,6 +661,26 @@ MemArena::Block::discard() {
return *this;
}
+inline void*
+MemArena::Block::operator new(size_t block_size, size_t n)
+{
+ if (n < block_size) {
+ throw std::invalid_argument("MemArena::Block::operator new size is less than object size.");
+ }
+ // In theory we could use ::operator new(n) but this causes a size mismatch during ::operator delete.
+ // Easier to use malloc here and also override @c delete.
+ auto b = static_cast<Block *>(::malloc(n));
+ if (b == nullptr) {
+ throw std::bad_alloc();
+ }
+ return b;
+}
+
+inline void*
+MemArena::Block::operator new([[maybe_unused]] size_t block_size, void* place) noexcept {
+ return place;
+}
+
inline void
MemArena::Block::operator delete(void *ptr) noexcept {
::free(ptr);
diff --git a/code/src/MemArena.cc b/code/src/MemArena.cc
index 1d4d708..8621467 100644
--- a/code/src/MemArena.cc
+++ b/code/src/MemArena.cc
@@ -91,12 +91,10 @@ MemArena::make_block(size_t n) {
n = QuarterPage{round_up(n)};
}
- // Allocate space for the Block instance and the request memory and construct a Block at the front.
- // In theory this could use ::operator new(n) but this causes a size mismatch during ::operator delete.
- // Easier to use malloc and override @c delete.
+ // Allocate space for the Block instance and the requested memory and construct a Block at the front.
auto free_space = n - sizeof(Block);
_active_reserved += free_space;
- return new (::malloc(n)) Block(free_space);
+ return new (n) Block(free_space);
}
MemSpan<void>
(trafficserver-libswoc) 03/07: test_ip.cc updates
Posted by bn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit 27269baf775e173d02a30b3539ac7e4c23e781d7
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Tue Oct 7 22:48:43 2025 +0000
test_ip.cc updates
---
unit_tests/test_ip.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/unit_tests/test_ip.cc b/unit_tests/test_ip.cc
index 9737aca..8cfb9fe 100644
--- a/unit_tests/test_ip.cc
+++ b/unit_tests/test_ip.cc
@@ -9,6 +9,7 @@
#include <set>
#include <iostream>
+#include <type_traits>
#include "swoc/TextView.h"
#include "swoc/swoc_ip.h"
@@ -1239,11 +1240,11 @@ TEST_CASE("IPSpace Edge", "[libswoc][ipspace][edge]") {
auto const &cspace = space;
if (auto [r, p] = *(cspace.find(a1)); !r.empty()) {
Thing const &cp = p;
- static_assert(std::is_const_v<typeof(cp)>, "Payload was expected to be const.");
+ static_assert(std::is_const_v<typename std::remove_reference<decltype(cp)>::type>, "Payload was expected to be const.");
REQUIRE(false); // Checking this syntax doesn't copy the payload.
}
if (auto [r, p] = *(cspace.find(a1)); !r.empty()) {
- static_assert(std::is_const_v<typeof(p)>, "Payload was expected to be const.");
+ static_assert(std::is_const_v<typename std::remove_reference<decltype(p)>::type>, "Payload was expected to be const.");
REQUIRE(false); // Checking this syntax doesn't copy the payload.
}
(trafficserver-libswoc) 02/07: Remove maybe problematic constructors on storage_type (#12493)
Posted by bn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit 8870ee18ffc5e515b7275bc138c2a4a49e420f30
Author: Chris McFarlen <ch...@mcfarlen.us>
AuthorDate: Mon Sep 22 17:23:12 2025 -0500
Remove maybe problematic constructors on storage_type (#12493)
* Remove maybe problematic constructors on storage_type
* remove the code rather than comment.
---
code/include/swoc/IPRange.h | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/code/include/swoc/IPRange.h b/code/include/swoc/IPRange.h
index 64740b3..3cc3327 100644
--- a/code/include/swoc/IPRange.h
+++ b/code/include/swoc/IPRange.h
@@ -609,14 +609,6 @@ class IPRangeView {
std::monostate _nil; ///< No data present.
IP4Range const *_4; ///< IPv4 range.
IP6Range const *_6; ///< IPv6 range.
- void const *_void; ///< Used only for fast copy in construction and assignment.
-
- // These constructors are needed to make the default construction / assignent methods work.
- // Otherwise the compiler thinks the union isn't initialized.
- storage_type() = default;
- storage_type(std::monostate) {}
- storage_type(storage_type const &that);
- storage_type &operator=(storage_type const &rhs);
};
public:
@@ -1894,14 +1886,6 @@ IPSpace<PAYLOAD>::iterator::operator--(int) -> self_type {
// +++ IPRange +++
-inline IPRangeView::storage_type::storage_type(IPRangeView::storage_type const &that) : _void(that._void) {}
-
-inline IPRangeView::storage_type &
-IPRangeView::storage_type::operator=(IPRangeView::storage_type const &rhs) {
- _void = rhs._void;
- return *this;
-}
-
inline IP4Range::IP4Range(string_view const &text) {
this->load(text);
}
(trafficserver-libswoc) 05/07: Fix build for clang 20 (#12202)
Posted by bn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit 385dc6b4922821399e28a881d6c1c215c3ff0086
Author: Mo Chen <mo...@apache.org>
AuthorDate: Tue Apr 22 13:19:44 2025 -0500
Fix build for clang 20 (#12202)
Fix these warnings:
code/src/swoc_ip.cc:242:10: error: first argument in call to 'memset' is a pointer to non-trivially copyable type 'swoc::IPEndpoint' [-Werror,-Wnontrivial-memaccess]
242 | memset(this, 0, sizeof(*this));
| ^
---
code/src/swoc_ip.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/src/swoc_ip.cc b/code/src/swoc_ip.cc
index 6403922..6f6ae13 100644
--- a/code/src/swoc_ip.cc
+++ b/code/src/swoc_ip.cc
@@ -239,7 +239,7 @@ IPEndpoint::family_name(sa_family_t family) {
IPEndpoint &
IPEndpoint::set_to_any(int family) {
- memset(this, 0, sizeof(*this));
+ memset(static_cast<void *>(this), 0, sizeof(*this));
if (AF_INET == family) {
sa4.sin_family = family;
sa4.sin_addr.s_addr = INADDR_ANY;
@@ -268,7 +268,7 @@ IPEndpoint::is_any() const {
IPEndpoint &
IPEndpoint::set_to_loopback(int family) {
- memset(this, 0, sizeof(*this));
+ memset(static_cast<void *>(this), 0, sizeof(*this));
if (AF_INET == family) {
sa.sa_family = family;
sa4.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
(trafficserver-libswoc) 06/07: -std=c++20: Remove TextView space before _sv/_tv literal (#12164)
Posted by bn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit 7627e06b19ba3a1b98cefc100f80e425a1301957
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Mon Apr 7 15:36:50 2025 -0500
-std=c++20: Remove TextView space before _sv/_tv literal (#12164)
Spaces before _sv literals in operator"" declarations are deprecated for
-std=c++20. This removes those spaces in the TextView.h declarations.
This addresses the following warning:
```
include/swoc/TextView.h:2088:12: error: identifier '_sv' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
2088 | operator"" _sv(const char *s, size_t n) {
| ~~~~~~~~~~~^~~
| operator""_sv
include/swoc/TextView.h:2103:12: error: identifier '_tv' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator]
2103 | operator"" _tv(const char *s, size_t n) {
| ~~~~~~~~~~~^~~
| operator""_tv
```
---
code/include/swoc/TextView.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/include/swoc/TextView.h b/code/include/swoc/TextView.h
index 3fecf03..ed017da 100644
--- a/code/include/swoc/TextView.h
+++ b/code/include/swoc/TextView.h
@@ -2085,7 +2085,7 @@ namespace literals {
* so hopefully someday this can be removed.
*/
constexpr std::string_view
-operator"" _sv(const char *s, size_t n) {
+operator""_sv(const char *s, size_t n) {
return {s, n};
}
@@ -2100,7 +2100,7 @@ operator"" _sv(const char *s, size_t n) {
* so hopefully someday this can be removed.
*/
constexpr swoc::TextView
-operator"" _tv(const char *s, size_t n) {
+operator""_tv(const char *s, size_t n) {
return {s, n};
}
} // namespace literals
(trafficserver-libswoc) 04/07: Catch2: update to v3.9.1 (#12453)
Posted by bn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit 169cfab1c5a23846d35768fdd338b552681cfded
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Tue Aug 19 14:23:17 2025 -0500
Catch2: update to v3.9.1 (#12453)
This updates our Catch2 version from v2.13.8 to the latest v3.9.1. It
also transitions us from the deprecated monolithic header file to the
new library model using CMake via FetchContent.
This has several advantages:
* This uses the library model which the authors of Catch2 advocate for.
The monolithic header we used before this patch is not "the primarily
supported option".
* Since not all of catch.hpp is built for every UT, compilation times
are quicker.
* Since the new v3 version provides a main function definition via
Catch2::Catch2WithMain, we no longer need the empty unit_test_main.cc
files we had before.
* The updated Catch v3 is purported to execute its checks more
efficiently (according to the changelog).
As a part of this transition, this removes
src/records/unit_tests/unit_test_main_on_eventsystem.cc since that was
added with #7704 for DynamicStats which has since been removed. In v2,
this simply didn't run any tests. In v3, this failed because no tests
were run.
---
unit_tests/ex_IntrusiveDList.cc | 2 +-
unit_tests/ex_Lexicon.cc | 2 +-
unit_tests/ex_MemArena.cc | 2 +-
unit_tests/ex_TextView.cc | 2 +-
unit_tests/ex_UnitParser.cc | 2 +-
unit_tests/ex_bw_format.cc | 2 +-
unit_tests/ex_ipspace_properties.cc | 2 +-
unit_tests/test_BufferWriter.cc | 2 +-
unit_tests/test_Errata.cc | 2 +-
unit_tests/test_IntrusiveDList.cc | 2 +-
unit_tests/test_IntrusiveHashMap.cc | 2 +-
unit_tests/test_Lexicon.cc | 2 +-
unit_tests/test_MemArena.cc | 3 ++-
unit_tests/test_MemSpan.cc | 2 +-
unit_tests/test_Scalar.cc | 2 +-
unit_tests/test_TextView.cc | 6 ++++--
unit_tests/test_Vectray.cc | 2 +-
unit_tests/test_bw_format.cc | 3 ++-
unit_tests/test_ip.cc | 6 ++++--
unit_tests/test_meta.cc | 2 +-
unit_tests/test_range.cc | 2 +-
unit_tests/test_swoc_file.cc | 2 +-
unit_tests/unit_test_main.cc | 4 ++--
23 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/unit_tests/ex_IntrusiveDList.cc b/unit_tests/ex_IntrusiveDList.cc
index a26f386..aed0e7c 100644
--- a/unit_tests/ex_IntrusiveDList.cc
+++ b/unit_tests/ex_IntrusiveDList.cc
@@ -30,7 +30,7 @@
#include "swoc/IntrusiveDList.h"
#include "swoc/bwf_base.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::IntrusiveDList;
diff --git a/unit_tests/ex_Lexicon.cc b/unit_tests/ex_Lexicon.cc
index 1be975e..58cd95d 100644
--- a/unit_tests/ex_Lexicon.cc
+++ b/unit_tests/ex_Lexicon.cc
@@ -10,7 +10,7 @@
#include "swoc/Lexicon.h"
#include "swoc/swoc_file.h"
#include "swoc/swoc_ip.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
// Example code for documentatoin
// ---
diff --git a/unit_tests/ex_MemArena.cc b/unit_tests/ex_MemArena.cc
index e0e9a03..1287c55 100644
--- a/unit_tests/ex_MemArena.cc
+++ b/unit_tests/ex_MemArena.cc
@@ -25,7 +25,7 @@
#include "swoc/IntrusiveHashMap.h"
#include "swoc/bwf_base.h"
#include "swoc/ext/HashFNV.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::MemSpan;
using swoc::MemArena;
diff --git a/unit_tests/ex_TextView.cc b/unit_tests/ex_TextView.cc
index d048439..9fcbafb 100644
--- a/unit_tests/ex_TextView.cc
+++ b/unit_tests/ex_TextView.cc
@@ -13,7 +13,7 @@
#include "swoc/swoc_file.h"
#include "swoc/TextView.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::TextView;
using namespace swoc::literals;
diff --git a/unit_tests/ex_UnitParser.cc b/unit_tests/ex_UnitParser.cc
index b146196..5026744 100644
--- a/unit_tests/ex_UnitParser.cc
+++ b/unit_tests/ex_UnitParser.cc
@@ -10,7 +10,7 @@
#include "swoc/Lexicon.h"
#include "swoc/Errata.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::TextView;
using swoc::Lexicon;
diff --git a/unit_tests/ex_bw_format.cc b/unit_tests/ex_bw_format.cc
index d26b70c..c82c047 100644
--- a/unit_tests/ex_bw_format.cc
+++ b/unit_tests/ex_bw_format.cc
@@ -28,7 +28,7 @@
#include "swoc/bwf_ex.h"
#include "swoc/bwf_ip.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using namespace std::literals;
using swoc::TextView;
diff --git a/unit_tests/ex_ipspace_properties.cc b/unit_tests/ex_ipspace_properties.cc
index 8db96fe..98ae0c0 100644
--- a/unit_tests/ex_ipspace_properties.cc
+++ b/unit_tests/ex_ipspace_properties.cc
@@ -6,7 +6,7 @@
Example use of IPSpace for property mapping.
*/
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
#include <memory>
#include <limits>
diff --git a/unit_tests/test_BufferWriter.cc b/unit_tests/test_BufferWriter.cc
index 9eeee19..c7f18d5 100644
--- a/unit_tests/test_BufferWriter.cc
+++ b/unit_tests/test_BufferWriter.cc
@@ -24,7 +24,7 @@
#include "swoc/MemArena.h"
#include "swoc/BufferWriter.h"
#include "swoc/ArenaWriter.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::TextView;
using swoc::MemSpan;
diff --git a/unit_tests/test_Errata.cc b/unit_tests/test_Errata.cc
index ea4e2e8..890ffab 100644
--- a/unit_tests/test_Errata.cc
+++ b/unit_tests/test_Errata.cc
@@ -11,7 +11,7 @@
#include "swoc/bwf_ex.h"
#include "swoc/swoc_file.h"
#include "swoc/Lexicon.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::Errata;
using swoc::Rv;
diff --git a/unit_tests/test_IntrusiveDList.cc b/unit_tests/test_IntrusiveDList.cc
index 96c3e6f..4deca98 100644
--- a/unit_tests/test_IntrusiveDList.cc
+++ b/unit_tests/test_IntrusiveDList.cc
@@ -26,7 +26,7 @@
#include "swoc/IntrusiveDList.h"
#include "swoc/bwf_base.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::IntrusiveDList;
using swoc::bwprint;
diff --git a/unit_tests/test_IntrusiveHashMap.cc b/unit_tests/test_IntrusiveHashMap.cc
index e3fa247..ee02fd3 100644
--- a/unit_tests/test_IntrusiveHashMap.cc
+++ b/unit_tests/test_IntrusiveHashMap.cc
@@ -26,7 +26,7 @@
#include "swoc/IntrusiveHashMap.h"
#include "swoc/bwf_base.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::IntrusiveHashMap;
diff --git a/unit_tests/test_Lexicon.cc b/unit_tests/test_Lexicon.cc
index 463ed3b..c6f5051 100644
--- a/unit_tests/test_Lexicon.cc
+++ b/unit_tests/test_Lexicon.cc
@@ -8,7 +8,7 @@
#include <iostream>
#include "swoc/Lexicon.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
// Example code for documentatoin
// ---
diff --git a/unit_tests/test_MemArena.cc b/unit_tests/test_MemArena.cc
index e98a982..d0224d7 100644
--- a/unit_tests/test_MemArena.cc
+++ b/unit_tests/test_MemArena.cc
@@ -24,10 +24,11 @@
#include <map>
#include <set>
#include <random>
+#include <algorithm>
#include "swoc/MemArena.h"
#include "swoc/TextView.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::MemSpan;
using swoc::MemArena;
diff --git a/unit_tests/test_MemSpan.cc b/unit_tests/test_MemSpan.cc
index 6355530..5752985 100644
--- a/unit_tests/test_MemSpan.cc
+++ b/unit_tests/test_MemSpan.cc
@@ -5,7 +5,7 @@
*/
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
#include <iostream>
#include <vector>
diff --git a/unit_tests/test_Scalar.cc b/unit_tests/test_Scalar.cc
index f7f4479..cd9c36d 100644
--- a/unit_tests/test_Scalar.cc
+++ b/unit_tests/test_Scalar.cc
@@ -20,7 +20,7 @@
#include "swoc/Scalar.h"
#include "swoc/bwf_base.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using Bytes = swoc::Scalar<1, off_t>;
using Paragraphs = swoc::Scalar<16, off_t>;
diff --git a/unit_tests/test_TextView.cc b/unit_tests/test_TextView.cc
index 1499594..2e05092 100644
--- a/unit_tests/test_TextView.cc
+++ b/unit_tests/test_TextView.cc
@@ -10,9 +10,11 @@
#include <string>
#include <map>
#include <unordered_map>
+#include <cmath>
+#include <algorithm>
#include "swoc/TextView.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::TextView;
using namespace std::literals;
@@ -73,7 +75,7 @@ TEST_CASE("TextView Operations", "[libswoc][TextView]") {
REQUIRE(tv);
REQUIRE(!tv == false);
if (nothing) {
- REQUIRE(nullptr == "bad operator bool on TextView");
+ REQUIRE(false); // bad operator bool on TextView
}
REQUIRE(!nothing == true);
REQUIRE(nothing.empty() == true);
diff --git a/unit_tests/test_Vectray.cc b/unit_tests/test_Vectray.cc
index ebe7d34..b6fdd5a 100644
--- a/unit_tests/test_Vectray.cc
+++ b/unit_tests/test_Vectray.cc
@@ -7,7 +7,7 @@
#include <iostream>
#include "swoc/Vectray.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::Vectray;
diff --git a/unit_tests/test_bw_format.cc b/unit_tests/test_bw_format.cc
index dc3169a..2cfb99a 100644
--- a/unit_tests/test_bw_format.cc
+++ b/unit_tests/test_bw_format.cc
@@ -7,6 +7,7 @@
#include <chrono>
#include <iostream>
#include <variant>
+#include <cmath>
#include <netinet/in.h>
@@ -15,7 +16,7 @@
#include "swoc/bwf_std.h"
#include "swoc/bwf_ex.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using namespace std::literals;
using namespace swoc::literals;
diff --git a/unit_tests/test_ip.cc b/unit_tests/test_ip.cc
index 8cfb9fe..1a24b6a 100644
--- a/unit_tests/test_ip.cc
+++ b/unit_tests/test_ip.cc
@@ -5,10 +5,12 @@
IP address support testing.
*/
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
-#include <set>
+#include <algorithm>
#include <iostream>
+#include <random>
+#include <set>
#include <type_traits>
#include "swoc/TextView.h"
diff --git a/unit_tests/test_meta.cc b/unit_tests/test_meta.cc
index d0d6ec5..e4da5b6 100644
--- a/unit_tests/test_meta.cc
+++ b/unit_tests/test_meta.cc
@@ -24,7 +24,7 @@
#include "swoc/swoc_meta.h"
#include "swoc/TextView.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::TextView;
using namespace swoc::literals;
diff --git a/unit_tests/test_range.cc b/unit_tests/test_range.cc
index 30c9064..d94c9dc 100644
--- a/unit_tests/test_range.cc
+++ b/unit_tests/test_range.cc
@@ -5,7 +5,7 @@
#include "swoc/DiscreteRange.h"
#include "swoc/TextView.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using swoc::TextView;
using namespace std::literals;
diff --git a/unit_tests/test_swoc_file.cc b/unit_tests/test_swoc_file.cc
index 7076c8a..435516b 100644
--- a/unit_tests/test_swoc_file.cc
+++ b/unit_tests/test_swoc_file.cc
@@ -23,7 +23,7 @@
#include <fstream>
#include "swoc/swoc_file.h"
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
using namespace swoc;
using namespace swoc::literals;
diff --git a/unit_tests/unit_test_main.cc b/unit_tests/unit_test_main.cc
index 083564d..21830d3 100644
--- a/unit_tests/unit_test_main.cc
+++ b/unit_tests/unit_test_main.cc
@@ -20,8 +20,8 @@
the License.
*/
-#define CATCH_CONFIG_RUNNER
-#include "catch.hpp"
+#include <catch2/catch_test_macros.hpp>
+#include <catch2/catch_session.hpp>
#include <array>
(trafficserver-libswoc) 01/07: proxy.config.http.per_client.connection.exempt_list
Posted by bn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git
commit e8c29e05acac14c17124137c303839596fc91973
Author: Brian Neradt <br...@gmail.com>
AuthorDate: Mon Apr 14 17:31:39 2025 +0000
proxy.config.http.per_client.connection.exempt_list
This implements
proxy.config.http.per_client.connection.exempt_list, a
configuration for the user to be able to provide a set of IP addresses
that are not counted against
proxy.config.net.per_client.max_connections_in.
This also adds the following TS APIs to modify this list via a plugin:
TSConnectionLimitExemptListSet
TSConnectionLimitExemptListAdd
TSConnectionLimitExemptListClear
(cherry picked from commit 8b85aa1b7f84abd084c5d21326f2821e1859dffb)
---
code/include/swoc/IPRange.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/code/include/swoc/IPRange.h b/code/include/swoc/IPRange.h
index cdcf5b7..64740b3 100644
--- a/code/include/swoc/IPRange.h
+++ b/code/include/swoc/IPRange.h
@@ -1578,6 +1578,13 @@ public:
*/
self_type &fill(swoc::IPRange const &r);
+ /** Erase addresses from the set.
+ *
+ * @param r Range of addresses to erase.
+ * @return @a this
+ */
+ self_type &erase(swoc::IPRange const &r);
+
/// @return @c true if @a addr is in the set.
bool contains(swoc::IPAddr const &addr) const;
@@ -1683,6 +1690,12 @@ IPRangeSet::fill(swoc::IPRange const &r) -> self_type & {
return *this;
}
+inline auto
+IPRangeSet::erase(swoc::IPRange const &r) -> self_type & {
+ _addrs.erase(r);
+ return *this;
+}
+
inline bool
IPRangeSet::contains(swoc::IPAddr const &addr) const {
return _addrs.find(addr) != _addrs.end();