From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:21:16 +0000 (+0000) Subject: Use SBuf in CompositeSelectionDetails and DelayTaggedBucket (#1450) X-Git-Tag: SQUID_7_0_1~373 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b78b376d1e66de8f645aca638b4a2c7ff2562f9e;p=thirdparty%2Fsquid.git Use SBuf in CompositeSelectionDetails and DelayTaggedBucket (#1450) --- diff --git a/src/CompositePoolNode.h b/src/CompositePoolNode.h index cabec23c8d..173b55b978 100644 --- a/src/CompositePoolNode.h +++ b/src/CompositePoolNode.h @@ -17,7 +17,7 @@ #include "DelayIdComposite.h" #include "DelayPools.h" #include "ip/Address.h" -#include "SquidString.h" +#include "sbuf/SBuf.h" class StoreEntry; @@ -44,13 +44,15 @@ public: { public: - CompositeSelectionDetails() {} + CompositeSelectionDetails(const Ip::Address& aSrcAddr, const SBuf &aTag) : + src_addr(aSrcAddr), tag(aTag) + {} Ip::Address src_addr; #if USE_AUTH Auth::UserRequest::Pointer user; #endif - String tag; + const SBuf tag; }; protected: diff --git a/src/DelayId.cc b/src/DelayId.cc index 0e86d3d934..6143ff806f 100644 --- a/src/DelayId.cc +++ b/src/DelayId.cc @@ -22,6 +22,7 @@ #include "DelayPools.h" #include "http/Stream.h" #include "HttpRequest.h" +#include "sbuf/StringConvert.h" #include "SquidConfig.h" DelayId::DelayId () : pool_ (0), compositeId(nullptr), markedAsNoDelay(false) @@ -102,12 +103,10 @@ DelayId::DelayClient(ClientHttpRequest * http, HttpReply *reply) if (DelayPools::delay_data[pool].theComposite().getRaw() && ch.fastCheck().allowed()) { DelayId result (pool + 1); - CompositePoolNode::CompositeSelectionDetails details; - details.src_addr = ch.src_addr; + CompositePoolNode::CompositeSelectionDetails details(ch.src_addr, StringToSBuf(r->tag)); #if USE_AUTH details.user = r->auth_user_request; #endif - details.tag = r->tag; result.compositePosition(DelayPools::delay_data[pool].theComposite()->id(details)); return result; } diff --git a/src/DelayTagged.cc b/src/DelayTagged.cc index 5cdbaa3486..e6da141251 100644 --- a/src/DelayTagged.cc +++ b/src/DelayTagged.cc @@ -110,13 +110,13 @@ DelayIdComposite::Pointer DelayTagged::id(CompositePoolNode::CompositeSelectionDetails &details) { - if (!details.tag.size()) + if (!details.tag.length()) return new NullDelayId; return new Id(this, details.tag); } -DelayTaggedBucket::DelayTaggedBucket(String &aTag) : tag (aTag) +DelayTaggedBucket::DelayTaggedBucket(const SBuf &aTag): tag(aTag) { debugs(77, 3, "DelayTaggedBucket::DelayTaggedBucket"); } @@ -129,11 +129,11 @@ DelayTaggedBucket::~DelayTaggedBucket() void DelayTaggedBucket::stats(StoreEntry *entry) const { - storeAppendPrintf(entry, " " SQUIDSTRINGPH ":", SQUIDSTRINGPRINT(tag)); + storeAppendPrintf(entry, " " SQUIDSBUFPH ":", SQUIDSBUFPRINT(tag)); theBucket.stats(entry); } -DelayTagged::Id::Id(DelayTagged::Pointer aDelayTagged, String &aTag) : theTagged(aDelayTagged) +DelayTagged::Id::Id(const DelayTagged::Pointer &aDelayTagged, const SBuf &aTag): theTagged(aDelayTagged) { theBucket = new DelayTaggedBucket(aTag); DelayTaggedBucket::Pointer const *existing = theTagged->buckets.find(theBucket, DelayTaggedCmp); diff --git a/src/DelayTagged.h b/src/DelayTagged.h index bf2a112ecc..76ec0335d8 100644 --- a/src/DelayTagged.h +++ b/src/DelayTagged.h @@ -19,6 +19,7 @@ #include "DelayBucket.h" #include "DelayIdComposite.h" #include "DelaySpec.h" +#include "sbuf/SBuf.h" #include "splay.h" /// \ingroup DelayPoolsAPI @@ -30,10 +31,10 @@ public: typedef RefCount Pointer; void stats(StoreEntry *)const; - DelayTaggedBucket(String &aTag); + explicit DelayTaggedBucket(const SBuf &aTag); ~DelayTaggedBucket() override; DelayBucket theBucket; - String tag; + const SBuf tag; }; /// \ingroup DelayPoolsAPI @@ -61,7 +62,7 @@ private: MEMPROXY_CLASS(DelayTagged::Id); public: - Id (RefCount, String &); + Id(const RefCount &, const SBuf &); ~Id() override; int bytesWanted (int min, int max) const override; void bytesIn(int qty) override;