From: Amos Jeffries Date: Sat, 2 Jul 2016 06:47:55 +0000 (+1200) Subject: Bug 4540: revert r14720 buffer update X-Git-Tag: SQUID_4_0_13~42 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=942b1c39a7fa75d6d440d2550c00ea0213f54f25;p=thirdparty%2Fsquid.git Bug 4540: revert r14720 buffer update --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 67573c1cb0..2e23180161 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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. diff --git a/src/cf.data.pre b/src/cf.data.pre index a00b85447b..26fe3786b0 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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 diff --git a/src/client_side.cc b/src/client_side.cc index 92d0c8bb37..784abea28a 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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 " << diff --git a/src/http/Stream.cc b/src/http/Stream.cc index f2b9211d42..ed6088f4e7 100644 --- a/src/http/Stream.cc +++ b/src/http/Stream.cc @@ -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) { diff --git a/src/http/Stream.h b/src/http/Stream.h index 21bfdc2cd3..946ff6337b 100644 --- a/src/http/Stream.h +++ b/src/http/Stream.h @@ -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 diff --git a/src/servers/FtpServer.cc b/src/servers/FtpServer.cc index c2bc795a59..2e6e32cba1 100644 --- a/src/servers/FtpServer.cc +++ b/src/servers/FtpServer.cc @@ -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;