]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Use SBuf in CompositeSelectionDetails and DelayTaggedBucket (#1450)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Fri, 11 Aug 2023 11:21:16 +0000 (11:21 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 11 Aug 2023 14:23:43 +0000 (14:23 +0000)
src/CompositePoolNode.h
src/DelayId.cc
src/DelayTagged.cc
src/DelayTagged.h

index cabec23c8dbcd8b31996b93b579a24840e21c3ce..173b55b9786726a1bc5de347de10a3d5db211215 100644 (file)
@@ -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:
index 0e86d3d934ab0defaa0697fa943bbd02fc19a394..6143ff806f2161b4265953167978cc3b892f8c0e 100644 (file)
@@ -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;
         }
index 5cdbaa3486b9f8ec686e20fa2ccac162b28102f9..e6da141251a64725a70a443a22dc5be106fe3fe4 100644 (file)
@@ -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);
index bf2a112ecc399d8c4991a68cb0af65129a8b9e0c..76ec0335d8efb9f3a5524457d2ae70377515d91e 100644 (file)
@@ -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<DelayTaggedBucket> 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<DelayTagged>, String &);
+        Id(const RefCount<DelayTagged> &, const SBuf &);
         ~Id() override;
         int bytesWanted (int min, int max) const override;
         void bytesIn(int qty) override;