From: Francesco Chemolli Date: Wed, 12 Sep 2012 17:01:17 +0000 (+0200) Subject: More RequestFlags getters/setters. X-Git-Tag: sourceformat-review-1~6^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2552223c5cb9b8ba26861a78a72d197ba240e1e;p=thirdparty%2Fsquid.git More RequestFlags getters/setters. --- diff --git a/src/RequestFlags.h b/src/RequestFlags.h index c9a98e51f1..6eae0cb658 100644 --- a/src/RequestFlags.h +++ b/src/RequestFlags.h @@ -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; ///flags.accelerated) { + } else if (request->flags.accelerated()) { /* WWW authorization on accelerated requests */ headertype = HDR_AUTHORIZATION; } else if (request->flags.intercepted() || request->flags.spoofClientIp()) { diff --git a/src/client_side.cc b/src/client_side.cc index d47e2fb48b..fb1f919efc 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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 diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 7348f35a8b..b4e178d493 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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"; diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 453a7032b1..ad43e353fe 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -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 diff --git a/src/http.cc b/src/http.cc index 7cf181c63d..fa1edf0c68 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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 diff --git a/src/refresh.cc b/src/refresh.cc index df2e58c2a7..4cac5a0fe6 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -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 */