]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Refactored some RequestFlags with getters and setters.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 11 Sep 2012 15:11:33 +0000 (17:11 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 11 Sep 2012 15:11:33 +0000 (17:11 +0200)
src/RequestFlags.h
src/client_side.cc
src/client_side_reply.cc
src/peer_select.cc

index 027274c62b9ebefc8427dd8ba1ebe6221f0e21a9..e066bf60f5f24c3d09a1de5b0b113c673f0d2e22 100644 (file)
@@ -41,10 +41,12 @@ public:
         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), chunked_reply(0), stream_error(0), sslPeek_(false),
+        canRePin(0), no_direct(false), chunked_reply(false),
+        stream_error(false), sslPeek_(false),
         done_follow_x_forwarded_for(!FOLLOW_X_FORWARDED_FOR),
         sslBumped_(false), destinationIPLookedUp_(false), resetTCP_(false),
-        isRanged_(false) {
+        isRanged_(false)
+    {
 #if USE_HTTP_VIOLATIONS
         nocache_hack = 0;
 #endif
@@ -82,13 +84,6 @@ public:
     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 */
-    unsigned int no_direct :1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
-    unsigned int chunked_reply :1; /**< Reply with chunked transfer encoding */
-    unsigned int stream_error :1; /**< Whether stream error has occured */
-
-#if FOLLOW_X_FORWARDED_FOR
-    /* TODO: move from conditional definition to conditional setting */
-#endif /* FOLLOW_X_FORWARDED_FOR */
 
     // When adding new flags, please update cloneAdaptationImmune() as needed.
     bool resetTCP() const;
@@ -120,8 +115,23 @@ public:
     bool sslPeek() const { return sslPeek_; }
     void setSslPeek() { sslPeek_=true; }
     void clearSslPeek() { sslPeek_=false; }
-private:
 
+    bool hadStreamError() const { return stream_error; }
+    void setStreamError() { stream_error = true; }
+    void clearStreamError() { stream_error = false; }
+
+    bool isReplyChunked() const { return chunked_reply; }
+    void markReplyChunked() { chunked_reply = true; }
+
+    void setNoDirect() { no_direct=true; }
+    bool noDirect() { return no_direct; }
+
+private:
+    /** 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 sslPeek_ :1; ///< internal ssl-bump request to get server cert
     /* done_follow_x_forwarded_for is set by default to the opposite of
      * compilation option FOLLOW_X_FORWARDED_FOR (so that it returns
index 009c43d6ac3ba96a20711424c062e559271f8960..c6619b6a29c4e64bf502e55d57c318554f2e1b03 100644 (file)
@@ -985,7 +985,7 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData)
 {
     assert(rep == NULL);
 
-    if (!multipartRangeRequest() && !http->request->flags.chunked_reply) {
+    if (!multipartRangeRequest() && !http->request->flags.isReplyChunked()) {
         size_t length = lengthToSend(bodyData.range());
         noteSentBodyBytes (length);
         AsyncCall::Pointer call = commCbCall(33, 5, "clientWriteBodyComplete",
@@ -1394,7 +1394,7 @@ ClientSocketContext::sendStartOfMessage(HttpReply * rep, StoreIOBuffer bodyData)
     if (bodyData.data && bodyData.length) {
         if (multipartRangeRequest())
             packRange(bodyData, mb);
-        else if (http->request->flags.chunked_reply) {
+        else if (http->request->flags.isReplyChunked()) {
             packChunk(bodyData, *mb);
         } else {
             size_t length = lengthToSend(bodyData.range());
@@ -1449,8 +1449,9 @@ clientSocketRecipient(clientStreamNode * node, ClientHttpRequest * http,
 
     // After sending Transfer-Encoding: chunked (at least), always send
     // the last-chunk if there was no error, ignoring responseFinishedOrFailed.
-    const bool mustSendLastChunk = http->request->flags.chunked_reply &&
-                                   !http->request->flags.stream_error && !context->startOfOutput();
+    const bool mustSendLastChunk = http->request->flags.isReplyChunked() &&
+                                   !http->request->flags.hadStreamError() &&
+                                   !context->startOfOutput();
     if (responseFinishedOrFailed(rep, receivedData) && !mustSendLastChunk) {
         context->writeComplete(context->clientConnection, NULL, 0, COMM_OK);
         PROF_stop(clientSocketRecipient);
@@ -2656,8 +2657,9 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c
     request->flags.canRePin = request->flags.sslBumped() && conn->pinning.pinned;
     request->flags.ignore_cc = conn->port->ignore_cc;
     // TODO: decouple http->flags.accel from request->flags.sslBumped
-    request->flags.no_direct = (request->flags.accelerated && !request->flags.sslBumped()) ?
-                               !conn->port->allow_direct : 0;
+    if (request->flags.accelerated && !request->flags.sslBumped())
+        if (!conn->port->allow_direct)
+            request->flags.setNoDirect();
 #if USE_AUTH
     if (request->flags.sslBumped()) {
         if (conn->auth_user_request != NULL)
index 64fd47d9f8d3c2d8bd428681180a0fd5018cc3f9..9bc6519e2bc15a4d609673f3bb060aa2cba3b9a3 100644 (file)
@@ -1042,7 +1042,7 @@ clientReplyContext::checkTransferDone()
     if (http->flags.done_copying)
         return 1;
 
-    if (http->request->flags.chunked_reply && !flags.complete) {
+    if (http->request->flags.isReplyChunked() && !flags.complete) {
         // last-chunk was not sent
         return 0;
     }
@@ -1488,7 +1488,7 @@ clientReplyContext::buildReplyHeader()
             request->flags.proxy_keepalive &&
             reply->bodySize(request->method) < 0) {
         debugs(88, 3, "clientBuildReplyHeader: chunked reply");
-        request->flags.chunked_reply = 1;
+        request->flags.markReplyChunked();
         hdr->putStr(HDR_TRANSFER_ENCODING, "chunked");
     }
 
@@ -1825,7 +1825,7 @@ clientReplyContext::sendStreamError(StoreIOBuffer const &result)
     debugs(88, 5, "clientReplyContext::sendStreamError: A stream error has occured, marking as complete and sending no data.");
     StoreIOBuffer localTempBuffer;
     flags.complete = 1;
-    http->request->flags.stream_error = 1;
+    http->request->flags.setStreamError();
     localTempBuffer.flags.error = result.flags.error;
     clientStreamCallback((clientStreamNode*)http->client_stream.head->data, http, NULL,
                          localTempBuffer);
index ae61be4fafc08905605f21f481a9d595df9446b2..f965ee2059887bc359476312d42d9624dd3ac6d5 100644 (file)
@@ -443,7 +443,7 @@ peerSelectFoo(ps_state * ps)
             ps->acl_checklist = new ACLFilledChecklist(Config.accessList.NeverDirect, request, NULL);
             ps->acl_checklist->nonBlockingCheck(peerCheckNeverDirectDone, ps);
             return;
-        } else if (request->flags.no_direct) {
+        } else if (request->flags.noDirect()) {
             /** if we are accelerating, direct is not an option. */
             ps->direct = DIRECT_NO;
             debugs(44, 3, "peerSelectFoo: direct = " << DirectStr[ps->direct] << " (forced non-direct)");