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
The following commit(s) were added to refs/heads/master by this push:
new 3fa02cb Fix port from ATS.
3fa02cb is described below
commit 3fa02cb101a86e04d0ab54f7cba6edb3fcad475e
Author: Brian Neradt <[email protected]>
AuthorDate: Thu Mar 21 16:19:45 2024 +0000
Fix port from ATS.
A few patches didn't come over correctly when I ported in the ATS
patches. I verified that with this patch, the source code is now
identical with the ATS version.
---
code/include/swoc/IPRange.h | 8 +++++++-
code/include/swoc/IntrusiveHashMap.h | 9 +++++++++
code/include/swoc/TextView.h | 2 +-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/code/include/swoc/IPRange.h b/code/include/swoc/IPRange.h
index 547afdb..b09b879 100644
--- a/code/include/swoc/IPRange.h
+++ b/code/include/swoc/IPRange.h
@@ -1985,7 +1985,13 @@ IPRangeView::clear() -> self_type & {
inline bool
IPRangeView::empty() const {
- return AF_INET6 == _family ? _raw._6->empty() : AF_INET == _family ?
_raw._4->empty() : true;
+ if (AF_INET6 == _family) {
+ return _raw._6->empty();
+ } else if (AF_INET == _family) {
+ return _raw._4->empty();
+ } else {
+ return true;
+ }
}
inline bool
diff --git a/code/include/swoc/IntrusiveHashMap.h
b/code/include/swoc/IntrusiveHashMap.h
index 201f093..4bbe3b6 100644
--- a/code/include/swoc/IntrusiveHashMap.h
+++ b/code/include/swoc/IntrusiveHashMap.h
@@ -514,6 +514,15 @@ IntrusiveHashMap<H>::insert(value_type *v) {
if (spot != bucket->_v) {
mixed_p = true; // found some other key, it's going to be mixed.
}
+ if (spot != limit) {
+ // If an equal key was found, walk past those to insert at the upper end
of the range.
+ do {
+ spot = H::next_ptr(spot);
+ } while (spot != limit && H::equal(key, H::key_of(spot)));
+ if (spot != limit) { // something not equal past last equivalent, it's
going to be mixed.
+ mixed_p = true;
+ }
+ }
_list.insert_before(spot, v);
if (spot == bucket->_v) { // added before the bucket start, update the
start.
diff --git a/code/include/swoc/TextView.h b/code/include/swoc/TextView.h
index 01ddb65..9e914c8 100644
--- a/code/include/swoc/TextView.h
+++ b/code/include/swoc/TextView.h
@@ -1384,7 +1384,7 @@ TextView::suffix(int n) const noexcept {
inline TextView
TextView::suffix_at(char c) const {
self_type zret;
- if (auto n = this->rfind(c); n != npos) {
+ if (auto n = this->rfind(c); n != npos && n + 1 < this->size()) {
++n;
zret.assign(this->data() + n, this->size() - n);
}