From: Henrik Nordstrom Date: Sat, 15 Mar 2008 18:03:11 +0000 (+0100) Subject: First stab at header cloning. The motivation behind this is to get rid X-Git-Tag: BASIC_TPROXY4~3^2^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=da33c835aedeb564b25c068e8eb329ed27ca14bc;p=thirdparty%2Fsquid.git First stab at header cloning. The motivation behind this is to get rid of the need of buffering response headers in the server side code (client_side_reply). A positive sideeffect is that this should also improve performance considerably. --- diff --git a/src/HttpReply.cc b/src/HttpReply.cc index ee6718ad62..7f8ab7f449 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -551,3 +551,13 @@ HttpReply::calcMaxBodySize(HttpRequest& request) } } } + +HttpReply * +HttpReply::clone() const +{ + HttpReply *rep = new HttpReply(); + rep->header.append(&header); + rep->hdrCacheInit(); + rep->hdr_sz = hdr_sz; + return rep; +} diff --git a/src/HttpReply.h b/src/HttpReply.h index ac21e44164..16cc1834a7 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -130,6 +130,11 @@ public: void packHeadersInto(Packer * p) const; + /// Clone this reply. + /// Could be done as a copy-contructor but we do not want to + /// accidently copy a HttpReply.. + HttpReply *clone() const; + private: /* initialize */ void init(); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 38408bbbe5..b74ace1ef2 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1912,28 +1912,13 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) char *body_buf = buf; - /* This is always valid until we get the headers as metadata from - * storeClientCopy. - * Then it becomes reqofs == next->readBuffer.offset() - */ - assert(reqofs == 0 || flags.storelogiccomplete); - - if (flags.headersSent && buf != result.data) { + if (buf != result.data) { /* we've got to copy some data */ assert(result.length <= next()->readBuffer.length); xmemcpy(buf, result.data, result.length); body_buf = buf; - } else if (!flags.headersSent && - buf + reqofs !=result.data) { - /* we've got to copy some data */ - assert(result.length + reqofs <= next()->readBuffer.length); - xmemcpy(buf + reqofs, result.data, result.length); - body_buf = buf; } - /* We've got the final data to start pushing... */ - flags.storelogiccomplete = 1; - reqofs += result.length; assert(reqofs <= HTTP_REQBUF_SZ || flags.headersSent); @@ -1967,8 +1952,13 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) return; } - buildReply(buf, reqofs); - + if (!reply) { + reply = entry->mem_obj->getReply()->clone(); + } + if ((long)reqofs < reply->hdr_sz) { + waitForMoreData(); + return; + } if (reply) { /* handle headers */ @@ -1987,9 +1977,6 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) processReplyAccess(); return; - } else if (reqofs < HTTP_REQBUF_SZ && entry->store_status == STORE_PENDING) { - waitForMoreData(); - return; } else { debugs(88, 0, "clientReplyContext::sendMoreData: Unable to parse reply headers within a single HTTP_REQBUF_SZ length buffer"); StoreIOBuffer tempBuffer;