]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
More RequestFlags getters/setters.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 12 Sep 2012 17:01:17 +0000 (19:01 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 12 Sep 2012 17:01:17 +0000 (19:01 +0200)
src/RequestFlags.h
src/auth/Acl.cc
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc
src/http.cc
src/refresh.cc

index c9a98e51f193563e8842c8528892cf2055ccd536..6eae0cb658cf528fd99d2edf3fc57fd65eb45501 100644 (file)
@@ -38,7 +38,7 @@ public:
         nocache(0), ims(0), auth(0), cachable(0),
         hierarchical(0), loopdetect(0), proxy_keepalive(0), proxying(0),
         refresh(0), redirected(0), need_validation(0),
-        fail_on_validation_err(0), stale_if_hit(0), nocache_hack(0), accelerated(0),
+        fail_on_validation_err(0), stale_if_hit(0), nocache_hack(false), accelerated_(false),
         ignore_cc(false), intercepted_(false), hostVerified_(false), spoof_client_ip(false),
         internal(false), internalclient(false), must_keepalive(false), connection_auth_wanted(false), connection_auth_disabled(false), connection_proxy_auth(false), pinned_(false),
         canRePin_(false), authSent_(false), noDirect_(false), chunkedReply_(false),
@@ -62,8 +62,6 @@ public:
     unsigned int fail_on_validation_err :1; ///< whether we should fail if validation fails
     unsigned int stale_if_hit :1; ///< reply is stale if it is a hit
     /* for changing/ignoring no-cache requests. Unused unless USE_HTTP_VIOLATIONS */
-    unsigned int nocache_hack :1;
-    unsigned int accelerated :1;
 
     // When adding new flags, please update cloneAdaptationImmune() as needed.
     bool resetTCP() const;
@@ -146,11 +144,21 @@ public:
 
     bool ignoringCacheControl() const { return ignore_cc; }
     void ignoreCacheControl() { ignore_cc=true; }
+
+    bool accelerated() const { return accelerated_; }
+    void markAccelerated() { accelerated_ = true; }
+
+    /* nocache_hack is only enabled if USE_HTTP_VIOLATIONS is set at build-time.
+     * Compilers will have an easy time optimizing to a NOP otherwise. */
+    void hackNocache() { if (USE_HTTP_VIOLATIONS) nocache_hack=true; }
+    bool noCacheHackEnabled() const { return USE_HTTP_VIOLATIONS && nocache_hack; }
 private:
-    bool ignore_cc :1;
+    bool nocache_hack :1;
+    bool accelerated_ :1; ///<request is accelerated
+    bool ignore_cc :1; ///< ignore Cache-Control
     bool intercepted_ :1; ///< intercepted request
     bool hostVerified_ :1; ///< whether the Host: header passed verification
-    bool spoof_client_ip :1; /**< spoof client ip if possible */
+    bool spoof_client_ip :1; ///< spoof client ip if possible
     bool internal :1;
     bool internalclient :1;
     bool must_keepalive :1;
index 30229a8aa67fe20b6b935939a96851ec4b611ef6..62299b4ea2532f147c560e36c9c92f173f49234f 100644 (file)
@@ -31,7 +31,7 @@ AuthenticateAcl(ACLChecklist *ch)
             return ACCESS_ALLOWED;
         else
             return ACCESS_DENIED;
-    } else if (request->flags.accelerated) {
+    } else if (request->flags.accelerated()) {
         /* WWW authorization on accelerated requests */
         headertype = HDR_AUTHORIZATION;
     } else if (request->flags.intercepted() || request->flags.spoofClientIp()) {
index d47e2fb48bc403351bb21b63718bb5315b0007eb..fb1f919efcba43576b11a25b1defc92a36c37f8b 100644 (file)
@@ -2652,14 +2652,15 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c
 
     request->clientConnectionManager = conn;
 
-    request->flags.accelerated = http->flags.accel;
+    if (http->flags.accel)
+        request->flags.markAccelerated();
     request->flags.setSslBumped(conn->switchedToHttps());
     if (request->flags.sslBumped() && conn->pinning.pinned)
         request->flags.allowRepinning();
     if (conn->port->ignore_cc)
         request->flags.ignoreCacheControl();
     // TODO: decouple http->flags.accel from request->flags.sslBumped
-    if (request->flags.accelerated && !request->flags.sslBumped())
+    if (request->flags.accelerated() && !request->flags.sslBumped())
         if (!conn->port->allow_direct)
             request->flags.setNoDirect();
 #if USE_AUTH
index 7348f35a8b9e055c5fbe6967b90c3e3ff052c1ec..b4e178d4936d6ede8e1595877a09428a80fb25fd 100644 (file)
@@ -541,10 +541,7 @@ clientReplyContext::cacheHit(StoreIOBuffer result)
         return;
     }
 
-    if (e->checkNegativeHit()
-#if USE_HTTP_VIOLATIONS
-            && !r->flags.nocache_hack
-#endif
+    if (e->checkNegativeHit() && !r->flags.noCacheHackEnabled()
        ) {
         http->logType = LOG_TCP_NEGATIVE_HIT;
         sendMoreData(result);
@@ -1406,7 +1403,7 @@ clientReplyContext::buildReplyHeader()
                         continue;
                     }
                     request->flags.setMustKeepalive();
-                    if (!request->flags.accelerated && !request->flags.intercepted()) {
+                    if (!request->flags.accelerated() && !request->flags.intercepted()) {
                         httpHeaderPutStrf(hdr, HDR_PROXY_SUPPORT, "Session-Based-Authentication");
                         /*
                           We send "[Proxy-]Connection: Proxy-Support" header to mark
@@ -1595,19 +1592,13 @@ clientReplyContext::identifyFoundObject(StoreEntry *newEntry)
 
     }
 
-#if USE_HTTP_VIOLATIONS
-
-    else if (r->flags.nocache_hack) {
-
+    else if (r->flags.noCacheHackEnabled()) {
 #if USE_DNSHELPER
         ipcacheInvalidate(r->GetHost());
 #else
         ipcacheInvalidateNegative(r->GetHost());
 #endif /* USE_DNSHELPER */
-
     }
-
-#endif /* USE_HTTP_VIOLATIONS */
 #if USE_CACHE_DIGESTS
 
     lookup_type = http->storeEntry() ? "HIT" : "MISS";
index 453a7032b12fb464d15afa62f78e6b2b5310ce1b..ad43e353fec93a0c1761820a8d9b78b6c299ef05 100644 (file)
@@ -387,7 +387,8 @@ clientBeginRequest(const HttpRequestMethod& method, char const *url, CSCB * stre
     /*
      * build new header list *? TODO
      */
-    request->flags.accelerated = http->flags.accel;
+    if (http->flags.accel)
+        request->flags.markAccelerated();
 
     request->flags.setInternalClient();
 
@@ -1091,9 +1092,9 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
 #if USE_HTTP_VIOLATIONS
 
         if (Config.onoff.reload_into_ims)
-            request->flags.nocache_hack = 1;
+            request->flags.hackNocache();
         else if (refresh_nocache_hack)
-            request->flags.nocache_hack = 1;
+            request->flags.hackNocache();
         else
 #endif
 
index 7cf181c63dc8e363410e3f94a150877618b08be1..fa1edf0c68cb4795f7240273a85c6c08f6c861c2 100644 (file)
@@ -297,7 +297,7 @@ httpMaybeRemovePublic(StoreEntry * e, http_status status)
 void
 HttpStateData::processSurrogateControl(HttpReply *reply)
 {
-    if (request->flags.accelerated && reply->surrogate_control) {
+    if (request->flags.accelerated() && reply->surrogate_control) {
         HttpHdrScTarget *sctusable = reply->surrogate_control->getMergedTarget(Config.Accel.surrogate_id);
 
         if (sctusable) {
@@ -1237,7 +1237,7 @@ HttpStateData::continueAfterParsingHeader()
             debugs(11, DBG_IMPORTANT, "WARNING: HTTP: Invalid Response: Headers did not parse at all for " << entry->url() << " AKA " << request->GetHost() << request->urlpath.termedBuf() );
         } else {
             error = ERR_ZERO_SIZE_OBJECT;
-            debugs(11, (request->flags.accelerated?DBG_IMPORTANT:2), "WARNING: HTTP: Invalid Response: No object data received for " <<
+            debugs(11, (request->flags.accelerated()?DBG_IMPORTANT:2), "WARNING: HTTP: Invalid Response: No object data received for " <<
                    entry->url() << " AKA " << request->GetHost() << request->urlpath.termedBuf() );
         }
     }
@@ -1667,7 +1667,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
         strVia.clean();
     }
 
-    if (request->flags.accelerated) {
+    if (request->flags.accelerated()) {
         /* Append Surrogate-Capabilities */
         String strSurrogate(hdr_in->getList(HDR_SURROGATE_CAPABILITY));
 #if USE_SQUID_ESI
index df2e58c2a7251a5c998a05757ebc3456070e945f..4cac5a0fe6c87ac8726f8c07837fa3eb2ccc594a 100644 (file)
@@ -319,7 +319,7 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta)
 
 #if USE_HTTP_VIOLATIONS
 
-        if (!request->flags.nocache_hack) {
+        if (!request->flags.noCacheHackEnabled()) {
             (void) 0;
         } else if (R->flags.ignore_reload) {
             /* The clients no-cache header is ignored */