--------------------- PatchSet 10362 Date: 2008/01/03 16:38:01 Author: adri Branch: s27_adri Tag: (none) Log: Convert the rest of the (applicable) storeAppend() calls to storeAppendRef(). The data path now from the read reply to the client doesn't involve any copies to get data in and out of stmem. It still requires allocation and memcpy()'s for the various strings (esp headers); these will be addressed once the current code is stable and tidy. Members: src/http.c:1.63.2.3.4.30->1.63.2.3.4.31 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.3.4.30 retrieving revision 1.63.2.3.4.31 diff -u -r1.63.2.3.4.30 -r1.63.2.3.4.31 --- squid/src/http.c 3 Jan 2008 13:26:45 -0000 1.63.2.3.4.30 +++ squid/src/http.c 3 Jan 2008 16:38:01 -0000 1.63.2.3.4.31 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.3.4.30 2008/01/03 13:26:45 adri Exp $ + * $Id: http.c,v 1.63.2.3.4.31 2008/01/03 16:38:01 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -456,7 +456,7 @@ hdr_len = hdr_size; if (hdr_len > Config.maxReplyHeaderSize) { debug(11, 1) ("httpProcessReplyHeader: Too large reply header\n"); - storeAppend(entry, buf_buf(b) + parse_start, buf_len(b) - parse_start); + storeAppendRef(entry, b, parse_start, buf_len(b) - parse_start); reply->sline.status = HTTP_HEADER_TOO_LARGE; httpState->reply_hdr_state += 2; ctx_exit(ctx); @@ -492,7 +492,7 @@ else return hdr_size; } - storeAppend(entry, buf_buf(b) + parse_start, hdr_size); + storeAppendRef(entry, b, parse_start, hdr_size); if (reply->sline.status >= HTTP_INVALID_HEADER) { debug(11, 3) ("httpProcessReplyHeader: Non-HTTP-compliant header: '%.*s'\n", (int) hdr_size, buf_buf(b) + parse_start); ctx_exit(ctx); @@ -663,11 +663,9 @@ int complete = httpState->eof; int keep_alive = !httpState->eof; - const char *buf = NULL; ssize_t len = 0; if (b) { - buf = buf_buf(b) + offset; len = buf_len(b) - offset; } @@ -680,22 +678,22 @@ if (size > httpState->chunk_size) size = httpState->chunk_size; httpState->chunk_size -= size; - storeAppend(httpState->entry, buf, size); + storeAppendRef(httpState->entry, b, offset, size); debug(11, 2) ("httpAppendBody: FD %d: appended %d bytes\n", httpState->fd, (int) size); - buf += size; + offset += size; len -= size; } else if (httpState->chunk_size < 0) { /* non-chunked without content-length */ - storeAppend(httpState->entry, buf, len); + storeAppendRef(httpState->entry, b, offset, len); debug(11, 2) ("httpAppendBody: FD %d: appended %d bytes\n", httpState->fd, (int) len); len = 0; } else if (httpState->flags.chunked) { - char *eol = memchr(buf, '\n', len); - size_t size = eol - buf + 1; + char *eol = memchr(buf_buf(b) + offset, '\n', len); + size_t size = eol - buf_buf(b) + offset + 1; if (!eol) size = len; - stringAppend(&httpState->chunkhdr, buf, size); - buf += size; + stringAppend(&httpState->chunkhdr, buf_buf(b) + offset, size); + offset += size; len -= size; if (strLen2(httpState->chunkhdr) > 256) { debug(11, 1) ("Oversized chunk header on port %d, url %s\n", comm_local_port(fd), entry->mem_obj->url); @@ -1020,7 +1018,7 @@ mb = httpReplyPack(reply); storeAppend(entry, mb.buf, mb.size); assert(buf_start < buf_len(httpState->replybuf)); - storeAppend(entry, buf_buf(httpState->replybuf) + buf_start, buf_len(httpState->replybuf) - buf_start); + storeAppendRef(entry, httpState->replybuf, buf_start, buf_len(httpState->replybuf) - buf_start); httpReplyReset(reply); httpReplyParse(reply, mb.buf, mb.size); memBufClean(&mb);