]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix performance regressions with fastCheck() result copying (#1883)
authorAmos Jeffries <yadij@users.noreply.github.com>
Mon, 12 Aug 2024 14:26:55 +0000 (14:26 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Mon, 12 Aug 2024 16:35:53 +0000 (16:35 +0000)
Detected by Coverity. CID 1616162: Performance inefficiencies
(AUTO_CAUSES_COPY). Using the 'auto' keyword without an '&' causes the
copy of an object of type Acl::Answer.

src/Notes.cc
src/auth/UserRequest.cc
src/client_side.cc
src/http.cc
src/http/Stream.cc

index 3f77761f5c8b76ba10bb2b809c5e38f5208507fb..57c54a1a3a0dc82b435cad58b4ce5119b2f5e095 100644 (file)
@@ -76,7 +76,7 @@ Note::match(HttpRequest *request, HttpReply *reply, const AccessLogEntry::Pointe
 
     for (const auto &v: values) {
         assert(v->aclList);
-        const auto ret = ch.fastCheck(v->aclList);
+        const auto &ret = ch.fastCheck(v->aclList);
         debugs(93, 5, "Check for header name: " << theKey << ": " << v->value() <<
                ", HttpRequest: " << request << " HttpReply: " << reply << " matched: " << ret);
         if (ret.allowed()) {
index a4f0686c3775560be2065bdd78b16db9dda3cd65..bebe8a0b6faa94b4e7265c3a55a25341347f98dd 100644 (file)
@@ -480,7 +480,7 @@ schemesConfig(HttpRequest *request, HttpReply *rep)
     if (!Auth::TheConfig.schemeLists.empty() && Auth::TheConfig.schemeAccess) {
         ACLFilledChecklist ch(nullptr, request);
         ch.updateReply(rep);
-        const auto answer = ch.fastCheck(Auth::TheConfig.schemeAccess);
+        const auto &answer = ch.fastCheck(Auth::TheConfig.schemeAccess);
         if (answer.allowed())
             return Auth::TheConfig.schemeLists.at(answer.kind).authConfigs;
     }
index 38cd088e17a9c3245ae085b804c19a8dbec2f217..487d3768c1d2a563ee3dd8952010719e9123e1bf 100644 (file)
@@ -1528,7 +1528,7 @@ ConnStateData::tunnelOnError(const err_type requestError)
     ACLFilledChecklist checklist(Config.accessList.on_unsupported_protocol, nullptr);
     checklist.requestErrorType = requestError;
     fillChecklist(checklist);
-    auto answer = checklist.fastCheck();
+    const auto &answer = checklist.fastCheck();
     if (answer.allowed() && answer.kind == 1) {
         debugs(33, 3, "Request will be tunneled to server");
         const auto context = pipeline.front();
@@ -2184,7 +2184,7 @@ ConnStateData::whenClientIpKnown()
             /* pools require explicit 'allow' to assign a client into them */
             if (pools[pool]->access) {
                 ch.changeAcl(pools[pool]->access);
-                auto answer = ch.fastCheck();
+                const auto &answer = ch.fastCheck();
                 if (answer.allowed()) {
 
                     /*  request client information from db after we did all checks
index 7afef1db318e32de5ebd9c159658d70282b39792..e8f987a33a614d525477ee14ecd204e3b2bd9e51 100644 (file)
@@ -2109,7 +2109,7 @@ HttpStateData::forwardUpgrade(HttpHeader &hdrOut)
         Config.http_upgrade_request_protocols->forApplicable(offeredProto, [&ch, offeredStr, offeredStrLen, &upgradeOut] (const SBuf &cfgProto, const acl_access *guard) {
             debugs(11, 5, "checks " << cfgProto << " rule(s)");
             ch.changeAcl(guard);
-            const auto answer = ch.fastCheck();
+            const auto &answer = ch.fastCheck();
             if (answer.implicit)
                 return false; // keep looking for an explicit rule match
             if (answer.allowed())
index 17c82e540ba081d5f5c9d9f4e585d3784c79be9f..1538d69fe2c9ee72af81de03a5ef0fd78df3b539 100644 (file)
@@ -293,7 +293,7 @@ Http::Stream::sendStartOfMessage(HttpReply *rep, StoreIOBuffer bodyData)
             ACLFilledChecklist chl(pool->access, nullptr);
             clientAclChecklistFill(chl, http);
             chl.updateReply(rep);
-            const auto answer = chl.fastCheck();
+            const auto &answer = chl.fastCheck();
             if (answer.allowed()) {
                 writeQuotaHandler = pool->createBucket();
                 fd_table[clientConnection->fd].writeQuotaHandler = writeQuotaHandler;