]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Improved const-correctness of ALE-driven APIs (#904)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Tue, 28 Sep 2021 15:59:43 +0000 (15:59 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 1 Oct 2021 21:20:02 +0000 (21:20 +0000)
Also made ClientHttpRequest::al constant. This work actually started
with changing this data member, to make some ALE-related hack safer.
That change required the API fixes. We have since got rid of the hack,
but all these const-correctness changes are valuable on their own.

No functionality changes.

13 files changed:
src/AccessLogEntry.h
src/adaptation/AccessCheck.cc
src/adaptation/AccessCheck.h
src/adaptation/Iterator.cc
src/adaptation/Iterator.h
src/adaptation/icap/ModXact.cc
src/client_side.cc
src/client_side_request.cc
src/client_side_request.h
src/esi/Esi.cc
src/log/access_log.cc
src/stat.cc
src/tests/stub_liblog.cc

index 9f6310484671127a7054925cf19d167a91d5b241..d4b9cb9061b2a9197c8dc86feeac7820023e0042 100644 (file)
@@ -276,8 +276,8 @@ class ACLChecklist;
 class StoreEntry;
 
 /* Should be in 'AccessLog.h' as the driver */
-void accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist* checklist = NULL);
-void accessLogLog(AccessLogEntry::Pointer &, ACLChecklist * checklist);
+void accessLogLogTo(CustomLog *, const AccessLogEntryPointer &, ACLChecklist *checklist = nullptr);
+void accessLogLog(const AccessLogEntryPointer &, ACLChecklist *);
 void accessLogRotate(void);
 void accessLogClose(void);
 void accessLogInit(void);
index bb1947f8781ea538fbbc82519145d0b63092c99a..505a24315d8afffc3d26db85690ad8f66e75fff2 100644 (file)
@@ -29,7 +29,7 @@ cbdata_type Adaptation::AccessCheck::CBDATA_AccessCheck = CBDATA_UNKNOWN;
 bool
 Adaptation::AccessCheck::Start(Method method, VectPoint vp,
                                HttpRequest *req, HttpReply *rep,
-                               AccessLogEntry::Pointer &al, Adaptation::Initiator *initiator)
+                               const AccessLogEntryPointer &al, Adaptation::Initiator *initiator)
 {
 
     if (Config::Enabled) {
index 872650a8e536dad43380ec14e344dc4a34a0890b..aa57ec03d3c74c302cc28c015957414a49c43280 100644 (file)
@@ -9,13 +9,13 @@
 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
 #define SQUID_ADAPTATION__ACCESS_CHECK_H
 
-#include "AccessLogEntry.h"
 #include "acl/Acl.h"
 #include "adaptation/Elements.h"
 #include "adaptation/forward.h"
 #include "adaptation/Initiator.h"
 #include "adaptation/ServiceFilter.h"
 #include "base/AsyncJob.h"
+#include "log/forward.h"
 
 class HttpRequest;
 class HttpReply;
@@ -36,7 +36,7 @@ public:
 
     // use this to start async ACL checks; returns true if started
     static bool Start(Method method, VectPoint vp, HttpRequest *req,
-                      HttpReply *rep, AccessLogEntry::Pointer &al, Adaptation::Initiator *initiator);
+                      HttpReply *, const AccessLogEntryPointer &, Adaptation::Initiator *);
 
 protected:
     // use Start to start adaptation checks
index c1a2b1d36788642c3d63ac612fc9959711aac00d..b2233636340661e1f98b820e9373861dac3bbd98 100644 (file)
@@ -21,7 +21,7 @@
 
 Adaptation::Iterator::Iterator(
     Http::Message *aMsg, HttpRequest *aCause,
-    AccessLogEntry::Pointer &alp,
+    const AccessLogEntryPointer &alp,
     const ServiceGroupPointer &aGroup):
     AsyncJob("Iterator"),
     Adaptation::Initiate("Iterator"),
index 9c2be5764cf097c6e2d9f97a18875d504ea98e3f..2f8f410a0d2edc63cc865a1c9c9bb003e2c2a848 100644 (file)
@@ -9,11 +9,11 @@
 #ifndef SQUID_ADAPTATION__ITERATOR_H
 #define SQUID_ADAPTATION__ITERATOR_H
 
-#include "AccessLogEntry.h"
 #include "adaptation/Initiate.h"
 #include "adaptation/Initiator.h"
 #include "adaptation/ServiceGroups.h"
 #include "http/forward.h"
+#include "log/forward.h"
 
 namespace Adaptation
 {
@@ -34,7 +34,7 @@ class Iterator: public Initiate, public Initiator
 
 public:
     Iterator(Http::Message *virginHeader, HttpRequest *virginCause,
-             AccessLogEntry::Pointer &alp,
+             const AccessLogEntryPointer &,
              const Adaptation::ServiceGroupPointer &aGroup);
     virtual ~Iterator();
 
@@ -67,7 +67,7 @@ protected:
     ServicePlan thePlan; ///< which services to use and in what order
     Http::Message *theMsg; ///< the message being adapted (virgin for each step)
     HttpRequest *theCause; ///< the cause of the original virgin message
-    AccessLogEntry::Pointer al; ///< info for the future access.log entry
+    AccessLogEntryPointer al; ///< info for the future access.log entry
     CbcPointer<Adaptation::Initiate> theLauncher; ///< current transaction launcher
     int iterations; ///< number of steps initiated
     bool adapted; ///< whether the virgin message has been replaced
index 3fd49c312a6b3dc8e02d450814eb5a0f69be73c4..e16314c889710591fad97d8c71d3d317ee8c8239 100644 (file)
@@ -1311,7 +1311,7 @@ void Adaptation::Icap::ModXact::swanSong()
     Adaptation::Icap::Xaction::swanSong();
 }
 
-void prepareLogWithRequestDetails(HttpRequest *, AccessLogEntry::Pointer &);
+void prepareLogWithRequestDetails(HttpRequest *, const AccessLogEntryPointer &);
 
 void Adaptation::Icap::ModXact::finalizeLogInfo()
 {
index a23efb19e44c138b11baa6d3bac02a1d8d0f6be7..512796b1ea6b5ce67ae86b4d22b93b0a08aa047e 100644 (file)
@@ -186,7 +186,7 @@ static void clientUpdateStatHistCounters(const LogTags &logType, int svc_time);
 static void clientUpdateStatCounters(const LogTags &logType);
 static void clientUpdateHierCounters(HierarchyLogEntry *);
 static bool clientPingHasFinished(ping_data const *aPing);
-void prepareLogWithRequestDetails(HttpRequest *, AccessLogEntry::Pointer &);
+void prepareLogWithRequestDetails(HttpRequest *, const AccessLogEntryPointer &);
 static void ClientSocketContextPushDeferredIfNeeded(Http::StreamPointer deferredRequest, ConnStateData * conn);
 
 char *skipLeadingSpace(char *aString);
@@ -325,7 +325,7 @@ ClientHttpRequest::updateCounters()
 }
 
 void
-prepareLogWithRequestDetails(HttpRequest * request, AccessLogEntry::Pointer &aLogEntry)
+prepareLogWithRequestDetails(HttpRequest *request, const AccessLogEntryPointer &aLogEntry)
 {
     assert(request);
     assert(aLogEntry != NULL);
index 866d78db9c188c8ffc702e4962999ac5a1074209..aba646de1964462c7e6b1607f9825ddda5337721 100644 (file)
@@ -151,6 +151,7 @@ ClientHttpRequest::ClientHttpRequest(ConnStateData * aConn) :
     uri(NULL),
     log_uri(NULL),
     req_sz(0),
+    al(new AccessLogEntry()),
     calloutContext(NULL),
     maxReplyBodySize_(0),
     entry_(NULL),
@@ -164,7 +165,6 @@ ClientHttpRequest::ClientHttpRequest(ConnStateData * aConn) :
     , request_satisfaction_offset(0)
 #endif
 {
-    al = new AccessLogEntry;
     CodeContext::Reset(al);
     al->cache.start_time = current_time;
     if (aConn) {
index 55a2c63b5adf6f447e451a9004cc1e9cf2aab0bc..fe8551b299e8b9bdfe6604704a59d99ba75eda5d 100644 (file)
@@ -9,12 +9,12 @@
 #ifndef SQUID_CLIENTSIDEREQUEST_H
 #define SQUID_CLIENTSIDEREQUEST_H
 
-#include "AccessLogEntry.h"
 #include "acl/forward.h"
 #include "client_side.h"
 #include "clientStream.h"
 #include "http/forward.h"
 #include "HttpHeaderRange.h"
+#include "log/forward.h"
 #include "LogTags.h"
 #include "Store.h"
 
@@ -123,7 +123,7 @@ public:
     // NP: still an enum so each stage altering it must take care when replacing it.
     LogTags logType;
 
-    AccessLogEntry::Pointer al; ///< access.log entry
+    const AccessLogEntryPointer al; ///< access.log entry
 
     struct Flags {
         Flags() : accel(false), internal(false), done_copying(false) {}
index c67ac79c7000032c4613ed7bddc500a55e2517de..091ce3c3c5ad5a9a743533889090793e49ed9ad3 100644 (file)
@@ -37,6 +37,7 @@
 #include "HttpReply.h"
 #include "HttpRequest.h"
 #include "ip/Address.h"
+#include "log/forward.h"
 #include "MemBuf.h"
 #include "profiler/Profiler.h"
 #include "SquidConfig.h"
@@ -1412,7 +1413,7 @@ ESIContext::freeResources ()
     /* don't touch incoming, it's a pointer into buffered anyway */
 }
 
-ErrorState *clientBuildError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const AccessLogEntry::Pointer &);
+ErrorState *clientBuildError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const AccessLogEntryPointer &);
 
 /* This can ONLY be used before we have sent *any* data to the client */
 void
index 9e72c95893d7d7afa316ee3727479303ecd47581..8b811da318c150cf2e0f953c2a8b70f1ba664600 100644 (file)
@@ -75,7 +75,7 @@ static void fvdbRegisterWithCacheManager();
 int LogfileStatus = LOG_DISABLE;
 
 void
-accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist * checklist)
+accessLogLogTo(CustomLog *log, const AccessLogEntryPointer &al, ACLChecklist *checklist)
 {
 
     if (al->url.isEmpty())
@@ -145,7 +145,7 @@ accessLogLogTo(CustomLog* log, AccessLogEntry::Pointer &al, ACLChecklist * check
 }
 
 void
-accessLogLog(AccessLogEntry::Pointer &al, ACLChecklist * checklist)
+accessLogLog(const AccessLogEntryPointer &al, ACLChecklist *checklist)
 {
     if (LogfileStatus != LOG_ENABLE)
         return;
index 497b9734e97f2e930a6a23a2b0e20e88c845a420..b537396caf9beafb53239a382949c4290b05bf96 100644 (file)
@@ -9,6 +9,7 @@
 /* DEBUG: section 18    Cache Manager Statistics */
 
 #include "squid.h"
+#include "AccessLogEntry.h"
 #include "CacheDigest.h"
 #include "CachePeer.h"
 #include "client_side.h"
index b4a0b16813a6b4452aebcdadff92a4fa6b881f43..25f4a4bbaa0de9338d6d9c40157297c1858e6fad 100644 (file)
@@ -23,8 +23,8 @@ SBuf AccessLogEntry::getLogMethod() const STUB_RETVAL(SBuf())
 AccessLogEntry::SslDetails::SslDetails() {STUB}
 #endif
 */
-void accessLogLogTo(CustomLog *, AccessLogEntry::Pointer &, ACLChecklist *) STUB
-void accessLogLog(AccessLogEntry::Pointer &, ACLChecklist *) STUB
+void accessLogLogTo(CustomLog *, const AccessLogEntry::Pointer &, ACLChecklist *) STUB
+void accessLogLog(const AccessLogEntry::Pointer &, ACLChecklist *) STUB
 void accessLogRotate(void) STUB
 void accessLogClose(void) STUB
 void accessLogInit(void) STUB