From: wessels <> Date: Thu, 11 May 2000 09:15:51 +0000 (+0000) Subject: DW: X-Git-Tag: SQUID_3_0_PRE1~1984 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4f278b53978e1d4bc579d7e668a379879ad420a;p=thirdparty%2Fsquid.git DW: - Adrian's idea for skipping buffer copy on non-range, non-header writes to clients. --- diff --git a/src/client_side.cc b/src/client_side.cc index 4732b67737..dda19b0ab5 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.481 2000/05/11 03:05:23 wessels Exp $ + * $Id: client_side.cc,v 1.482 2000/05/11 03:15:51 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -72,6 +72,7 @@ static const char *const crlf = "\r\n"; /* Local functions */ static CWCB clientWriteComplete; +static CWCB clientWriteBodyComplete; static PF clientReadRequest; static PF connStateFree; static PF requestTimeout; @@ -1702,6 +1703,13 @@ clientSendMoreData(void *data, char *buf, ssize_t size) } /* reset range iterator */ http->range_iter.pos = HttpHdrRangeInitPos; + } else if (!http->request->range) { + /* Avoid copying to MemBuf for non-range requests */ + /* Note, if we're here, then 'rep' is known to be NULL */ + http->out.offset += body_size; + comm_write(fd, buf, size, clientWriteBodyComplete, http, NULL); + /* NULL because clientWriteBodyComplete frees it */ + return; } if (http->request->method == METHOD_HEAD) { if (rep) { @@ -1756,6 +1764,23 @@ clientSendMoreData(void *data, char *buf, ssize_t size) memFree(buf, MEM_CLIENT_SOCK_BUF); } +/* + * clientWriteBodyComplete is called for MEM_CLIENT_SOCK_BUF's + * written directly to the client socket, versus copying to a MemBuf + * and going through comm_write_mbuf. Most non-range responses after + * the headers probably go through here. + */ +static void +clientWriteBodyComplete(int fd, char *buf, size_t size, int errflag, void *data) +{ + /* + * NOTE: clientWriteComplete doesn't currently use its "buf" + * (second) argument, so we pass in NULL. + */ + clientWriteComplete(fd, NULL, size, errflag, data); + memFree(buf, MEM_CLIENT_SOCK_BUF); +} + static void clientKeepaliveNextRequest(clientHttpRequest * http) {