]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4540: revert r14720 buffer update
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 2 Jul 2016 06:47:55 +0000 (18:47 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 2 Jul 2016 06:47:55 +0000 (18:47 +1200)
src/cache_cf.cc
src/cf.data.pre
src/client_side.cc
src/http/Stream.cc
src/http/Stream.h
src/servers/FtpServer.cc

index 67573c1cb06e1c6a64d26091eeb3c0c6ac7705f0..2e23180161f5b8aa6e374b56ec7e17e262eb59dd 100644 (file)
@@ -946,10 +946,6 @@ configDoConfigure(void)
         }
     }
 #endif
-
-    if (Config.readAheadGap <= 0) {
-        fatalf("read_ahead_gap must be greater than 0 bytes");
-    }
 }
 
 /** Parse a line containing an obsolete directive.
index a00b85447bfe173b8fb194a924a9a2eb67b447b5..26fe3786b0733d13518b15e6533d86d007b6516d 100644 (file)
@@ -5650,17 +5650,6 @@ DEFAULT: 16 KB
 DOC_START
        The amount of data the cache will buffer ahead of what has been
        sent to the client when retrieving an object from another server.
-       
-       This also influences the maximum network read(2)/write(2) sizes in some
-       circumstances. Reducing the size of this buffer will decrease
-       per-connection memory usage at the cost of more read(2)/write(2) calls.
-       Conversely, increasing the size of this buffer will decrease the number of
-       read(2)/write(2) calls at the cost of memory usage, potentially improving
-       performance.
-
-       Squid does not slow does the response delivery to the client in order to
-       fill the buffer.
-
 DOC_END
 
 NAME: negative_ttl
index 92d0c8bb3747efec1ab03332c2d21b5719a9193b..784abea28ae494c22f3550b24ba0ba2c4010e89b 100644 (file)
@@ -1012,9 +1012,12 @@ ConnStateData::abortRequestParsing(const char *const uri)
     http->uri = xstrdup(uri);
     setLogUri (http, uri);
     auto *context = new Http::Stream(clientConnection, http);
+    StoreIOBuffer tempBuffer;
+    tempBuffer.data = context->reqbuf;
+    tempBuffer.length = HTTP_REQBUF_SZ;
     clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
                      clientReplyStatus, new clientReplyContext(http), clientSocketRecipient,
-                     clientSocketDetach, context, context->getClientStreamBuffer());
+                     clientSocketDetach, context, tempBuffer);
     return context;
 }
 
@@ -1356,11 +1359,15 @@ parseHttpRequest(ConnStateData *csd, const Http1::RequestParserPointer &hp)
     http->req_sz = hp->messageHeaderSize();
     Http::Stream *result = new Http::Stream(csd->clientConnection, http);
 
+    StoreIOBuffer tempBuffer;
+    tempBuffer.data = result->reqbuf;
+    tempBuffer.length = HTTP_REQBUF_SZ;
+
     ClientStreamData newServer = new clientReplyContext(http);
     ClientStreamData newClient = result;
     clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
                      clientReplyStatus, newServer, clientSocketRecipient,
-                     clientSocketDetach, newClient, result->getClientStreamBuffer());
+                     clientSocketDetach, newClient, tempBuffer);
 
     /* set url */
     debugs(33,5, "Prepare absolute URL from " <<
index f2b9211d420d1e227256e87092cff7f96c30d552..ed6088f4e7673ae98b476d8527f21928557d6e8d 100644 (file)
@@ -11,7 +11,6 @@
 #include "http/Stream.h"
 #include "HttpHdrContRange.h"
 #include "HttpHeaderTools.h"
-#include "SquidConfig.h"
 #include "Store.h"
 #include "TimeOrTag.h"
 
@@ -21,10 +20,10 @@ Http::Stream::Stream(const Comm::ConnectionPointer &aConn, ClientHttpRequest *aR
     reply(nullptr),
     writtenToSocket(0),
     mayUseConnection_(false),
-    connRegistered_(false),
-    requestBuffer(nullptr)
+    connRegistered_(false)
 {
     assert(http != nullptr);
+    memset(reqbuf, '\0', sizeof (reqbuf));
     flags.deferred = 0;
     flags.parsed_ok = 0;
     deferredparams.node = nullptr;
@@ -110,10 +109,12 @@ Http::Stream::pullData()
     debugs(33, 5, reply << " written " << http->out.size << " into " << clientConnection);
 
     /* More data will be coming from the stream. */
-    StoreIOBuffer readBuffer = getClientStreamBuffer();
+    StoreIOBuffer readBuffer;
     /* XXX: Next requested byte in the range sequence */
     /* XXX: length = getmaximumrangelenfgth */
     readBuffer.offset = getNextRangeOffset();
+    readBuffer.length = HTTP_REQBUF_SZ;
+    readBuffer.data = reqbuf;
     /* we may note we have reached the end of the wanted ranges */
     clientStreamRead(getTail(), http, readBuffer);
 }
@@ -567,18 +568,6 @@ Http::Stream::deferRecipientForLater(clientStreamNode *node, HttpReply *rep, Sto
     deferredparams.queuedBuffer = receivedData;
 }
 
-StoreIOBuffer
-Http::Stream::getClientStreamBuffer()
-{
-    if (!requestBuffer) {
-        requestBuffer = new MemBlob(Config.readAheadGap);
-    }
-    StoreIOBuffer tempBuffer;
-    tempBuffer.data = requestBuffer->mem;
-    tempBuffer.length = requestBuffer->spaceSize();
-    return tempBuffer;
-}
-
 void
 Http::Stream::prepareReply(HttpReply *rep)
 {
index 21bfdc2cd3d494462dfb98bf91e9188b51f8a81a..946ff6337b531cd8d4ad2633426457c132fe08cf 100644 (file)
@@ -120,13 +120,12 @@ public:
 
     void deferRecipientForLater(clientStreamNode *, HttpReply *, StoreIOBuffer receivedData);
 
-    StoreIOBuffer getClientStreamBuffer();
-
 public: // HTTP/1.x state data
 
     Comm::ConnectionPointer clientConnection; ///< details about the client connection socket
     ClientHttpRequest *http;    /* we pretend to own that Job */
     HttpReply *reply;
+    char reqbuf[HTTP_REQBUF_SZ];
     struct {
         unsigned deferred:1; ///< This is a pipelined request waiting for the current object to complete
         unsigned parsed_ok:1; ///< Was this parsed correctly?
@@ -159,8 +158,6 @@ private:
 
     bool mayUseConnection_; /* This request may use the connection. Don't read anymore requests for now */
     bool connRegistered_;
-
-    MemBlob::Pointer requestBuffer;
 };
 
 } // namespace Http
index c2bc795a59817c603eedf837ef22d8e3bfdf44dc..2e6e32cba1d4a7511285eab84656de58c291435e 100644 (file)
@@ -759,11 +759,15 @@ Ftp::Server::parseOneRequest()
     Http::Stream *const result =
         new Http::Stream(clientConnection, http);
 
+    StoreIOBuffer tempBuffer;
+    tempBuffer.data = result->reqbuf;
+    tempBuffer.length = HTTP_REQBUF_SZ;
+
     ClientStreamData newServer = new clientReplyContext(http);
     ClientStreamData newClient = result;
     clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
                      clientReplyStatus, newServer, clientSocketRecipient,
-                     clientSocketDetach, newClient, result->getClientStreamBuffer());
+                     clientSocketDetach, newClient, tempBuffer);
 
     result->flags.parsed_ok = 1;
     return result;