From: Francesco Chemolli Date: Tue, 11 Sep 2012 16:27:49 +0000 (+0200) Subject: More RequestFlags getters/setters implemented, renamed internal variables as per... X-Git-Tag: sourceformat-review-1~6^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d36248982110c0934db410b2e163592ea250f95;p=thirdparty%2Fsquid.git More RequestFlags getters/setters implemented, renamed internal variables as per naming convention. --- diff --git a/src/RequestFlags.h b/src/RequestFlags.h index e066bf60f5..f9f21c4424 100644 --- a/src/RequestFlags.h +++ b/src/RequestFlags.h @@ -40,10 +40,10 @@ public: refresh(0), redirected(0), need_validation(0), fail_on_validation_err(0), stale_if_hit(0), accelerated(0), ignore_cc(0), intercepted(0), hostVerified(0), spoof_client_ip(0), - internal(0), internalclient(0), must_keepalive(0), pinned(0), - canRePin(0), no_direct(false), chunked_reply(false), - stream_error(false), sslPeek_(false), - done_follow_x_forwarded_for(!FOLLOW_X_FORWARDED_FOR), + internal(0), internalclient(0), must_keepalive(0), pinned(false), + canRePin_(false), authSent_(false), noDirect_(false), chunkedReply_(false), + streamError_(false), sslPeek_(false), + doneFollowXForwardedFor(!FOLLOW_X_FORWARDED_FOR), sslBumped_(false), destinationIPLookedUp_(false), resetTCP_(false), isRanged_(false) { @@ -81,9 +81,6 @@ public: unsigned int connection_auth :1; /** Request wants connection oriented auth */ unsigned int connection_auth_disabled :1; /** Connection oriented auth can not be supported */ unsigned int connection_proxy_auth :1; /** Request wants connection oriented auth */ - unsigned int pinned :1; /* Request sent on a pinned connection */ - unsigned int canRePin :1; ///< OK to reopen a failed pinned connection - unsigned int auth_sent :1; /* Authentication forwarded */ // When adding new flags, please update cloneAdaptationImmune() as needed. bool resetTCP() const; @@ -103,41 +100,53 @@ public: void setSslBumped(bool newValue=true) { sslBumped_=newValue; } void clearSslBumpeD() { sslBumped_=false; } - bool doneFollowXFF() const { return done_follow_x_forwarded_for; } + bool doneFollowXFF() const { return doneFollowXForwardedFor; } void setDoneFollowXFF() { - done_follow_x_forwarded_for = true; + doneFollowXForwardedFor = true; } void clearDoneFollowXFF() { /* do not allow clearing if FOLLOW_X_FORWARDED_FOR is unset */ - done_follow_x_forwarded_for = false || !FOLLOW_X_FORWARDED_FOR; + doneFollowXForwardedFor = false || !FOLLOW_X_FORWARDED_FOR; } bool sslPeek() const { return sslPeek_; } void setSslPeek() { sslPeek_=true; } void clearSslPeek() { sslPeek_=false; } - bool hadStreamError() const { return stream_error; } - void setStreamError() { stream_error = true; } - void clearStreamError() { stream_error = false; } + bool hadStreamError() const { return streamError_; } + void setStreamError() { streamError_ = true; } + void clearStreamError() { streamError_ = false; } - bool isReplyChunked() const { return chunked_reply; } - void markReplyChunked() { chunked_reply = true; } + bool isReplyChunked() const { return chunkedReply_; } + void markReplyChunked() { chunkedReply_ = true; } - void setNoDirect() { no_direct=true; } - bool noDirect() { return no_direct; } + void setNoDirect() { noDirect_=true; } + bool noDirect() const{ return noDirect_; } + bool authSent() const { return authSent_; } + void markAuthSent() { authSent_=true;} + + bool canRePin() const { return canRePin_; } + void allowRepinning() { canRePin_=true; } + + void markPinned() { pinned = true; } + void clearPinned() { pinned = false; } + bool connPinned() const { return pinned; } private: + bool pinned :1; ///< Request sent on a pinned connection + bool canRePin_ :1; ///< OK to reopen a failed pinned connection + bool authSent_ :1; ///< Authentication was forwarded /** Deny direct forwarding unless overriden by always_direct. * Used in accelerator mode */ - bool no_direct :1; - bool chunked_reply :1; /**< Reply with chunked transfer encoding */ - bool stream_error :1; /**< Whether stream error has occured */ + bool noDirect_ :1; + bool chunkedReply_ :1; ///< Reply with chunked transfer encoding + bool streamError_ :1; ///< Whether stream error has occured bool sslPeek_ :1; ///< internal ssl-bump request to get server cert - /* done_follow_x_forwarded_for is set by default to the opposite of + /* doneFollowXForwardedFor is set by default to the opposite of * compilation option FOLLOW_X_FORWARDED_FOR (so that it returns * always "done" if the build option is disabled). */ - bool done_follow_x_forwarded_for :1; + bool doneFollowXForwardedFor :1; bool sslBumped_ :1; /**< ssl-bumped request*/ bool destinationIPLookedUp_:1; bool resetTCP_:1; ///< request to reset the TCP stream diff --git a/src/client_side.cc b/src/client_side.cc index c6619b6a29..a2e34fcb59 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -2654,7 +2654,8 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c request->flags.accelerated = http->flags.accel; request->flags.setSslBumped(conn->switchedToHttps()); - request->flags.canRePin = request->flags.sslBumped() && conn->pinning.pinned; + if (request->flags.sslBumped() && conn->pinning.pinned) + request->flags.allowRepinning(); request->flags.ignore_cc = conn->port->ignore_cc; // TODO: decouple http->flags.accel from request->flags.sslBumped if (request->flags.accelerated && !request->flags.sslBumped()) diff --git a/src/forward.cc b/src/forward.cc index 5934d6b751..0442a4b2a8 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -876,17 +876,17 @@ FwdState::connectDone(const Comm::ConnectionPointer &conn, comm_err_t status, in peerConnectSucceded(serverConnection()->getPeer()); // some requests benefit from pinning but do not require it and can "repin" - const bool rePin = request->flags.canRePin && + const bool rePin = request->flags.canRePin() && request->clientConnectionManager.valid(); if (rePin) { debugs(17, 3, HERE << "repinning " << serverConn); request->clientConnectionManager->pinConnection(serverConn, request, serverConn->getPeer(), request->flags.auth); - request->flags.pinned = 1; + request->flags.markPinned(); } #if USE_SSL - if (!request->flags.pinned || rePin) { + if (!request->flags.connPinned() || rePin) { if ((serverConnection()->getPeer() && serverConnection()->getPeer()->use_ssl) || (!serverConnection()->getPeer() && request->protocol == AnyP::PROTO_HTTPS) || request->flags.sslPeek()) { @@ -961,7 +961,7 @@ FwdState::connectStart() return; } - request->flags.pinned = 0; // XXX: what if the ConnStateData set this to flag existing credentials? + request->flags.clearPinned(); // XXX: what if the ConnStateData set this to flag existing credentials? // XXX: answer: the peer selection *should* catch it and give us only the pinned peer. so we reverse the =0 step below. // XXX: also, logs will now lie if pinning is broken and leads to an error message. if (serverDestinations[0]->peerType == PINNED) { @@ -978,7 +978,7 @@ FwdState::connectStart() serverConn->peerType = HIER_DIRECT; #endif ++n_tries; - request->flags.pinned = 1; + request->flags.markPinned(); if (pinned_connection->pinnedAuth()) request->flags.auth = 1; comm_add_close_handler(serverConn->fd, fwdServerClosedWrapper, this); @@ -989,7 +989,7 @@ FwdState::connectStart() } /* Failure. Fall back on next path unless we can re-pin */ debugs(17,2,HERE << "Pinned connection failed: " << pinned_connection); - if (pconnRace != raceHappened || !request->flags.canRePin) { + if (pconnRace != raceHappened || !request->flags.canRePin()) { serverDestinations.shift(); pconnRace = raceImpossible; startConnectionOrFail(); diff --git a/src/http.cc b/src/http.cc index 6d0ed19a77..f811b115c9 100644 --- a/src/http.cc +++ b/src/http.cc @@ -379,7 +379,7 @@ HttpStateData::cacheableReply() } } - if (request->flags.auth || request->flags.auth_sent) { + if (request->flags.auth || request->flags.authSent()) { /* * Responses to requests with authorization may be cached * only if a Cache-Control: public reply header is present. @@ -837,7 +837,7 @@ bool HttpStateData::peerSupportsConnectionPinning() const return true; /*if the connections it is already pinned it is OK*/ - if (request->flags.pinned) + if (request->flags.connPinned()) return true; /*Allow pinned connections only if the Proxy-support header exists in @@ -1389,9 +1389,9 @@ HttpStateData::processReplyBody() if (request->flags.spoof_client_ip) client_addr = request->client_addr; - if (request->flags.pinned) { + if (request->flags.connPinned()) { ispinned = true; - } else if (request->flags.connection_auth && request->flags.auth_sent) { + } else if (request->flags.connection_auth && request->flags.authSent()) { ispinned = true; } @@ -2021,10 +2021,10 @@ HttpStateData::buildRequestPrefix(MemBuf * mb) Packer p; httpBuildRequestHeader(request, entry, fwd->al, &hdr, flags); - if (request->flags.pinned && request->flags.connection_auth) - request->flags.auth_sent = 1; + if (request->flags.connPinned() && request->flags.connection_auth) + request->flags.markAuthSent(); else if (hdr.has(HDR_AUTHORIZATION)) - request->flags.auth_sent = 1; + request->flags.markAuthSent(); packerToMemInit(&p, mb); hdr.packInto(&p);