--------------------- PatchSet 8525 Date: 2006/08/19 16:47:15 Author: adri Branch: parserwork Tag: (none) Log: Remove the extra buffer being allocated/deallocated as scratch space for every 4k page of data being written to a client; replace it with a static buffer in clientHttpRequests. Members: src/client_side.c:1.143->1.143.2.1 src/structs.h:1.128->1.128.2.1 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.143 retrieving revision 1.143.2.1 diff -u -r1.143 -r1.143.2.1 --- squid/src/client_side.c 16 Aug 2006 00:53:03 -0000 1.143 +++ squid/src/client_side.c 19 Aug 2006 16:47:15 -0000 1.143.2.1 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.143 2006/08/16 00:53:03 squidadm Exp $ + * $Id: client_side.c,v 1.143.2.1 2006/08/19 16:47:15 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -398,8 +398,7 @@ if (h->log_type != LOG_TCP_DENIED) delaySetStoreClient(h->sc, delayClient(h)); #endif - storeClientCopy(h->sc, e, 0, 0, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreHeaderData, h); + storeClientCopy(h->sc, e, 0, 0, CLIENT_SOCK_SZ, h->readbuf, clientSendMoreHeaderData, h); return e; } @@ -701,11 +700,9 @@ debug(33, 3) ("clientHandleETagReply: %s, %d bytes\n", url, (int) size); if (entry == NULL) { /* client aborted */ - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } if (size < 0 && !EBIT_TEST(entry->flags, ENTRY_ABORTED)) { - memFree(buf, MEM_CLIENT_SOCK_BUF); clientHandleETagMiss(http); return; } @@ -713,7 +710,6 @@ status = mem->reply->sline.status; if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { debug(33, 3) ("clientHandleETagReply: ABORTED '%s'\n", url); - memFree(buf, MEM_CLIENT_SOCK_BUF); clientHandleETagMiss(http); return; } @@ -722,7 +718,6 @@ if (size >= CLIENT_SOCK_SZ) { /* will not get any bigger than that */ debug(33, 3) ("clientHandleETagReply: Reply is too large '%s'\n", url); - memFree(buf, MEM_CLIENT_SOCK_BUF); clientHandleETagMiss(http); } else { storeClientCopy(http->sc, entry, @@ -737,7 +732,6 @@ } if (HTTP_NOT_MODIFIED == mem->reply->sline.status) { /* Remember the ETag and restart */ - memFree(buf, MEM_CLIENT_SOCK_BUF); if (mem->reply) { request_t *request = http->request; const char *etag = httpHeaderGetStr(&mem->reply->header, HDR_ETAG); @@ -786,7 +780,7 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), + http->readbuf, clientHandleETagReply, http); } @@ -870,7 +864,7 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), + http->readbuf, clientHandleIMSReply, http); } @@ -944,11 +938,9 @@ http->old_entry->mem_obj->ims_entry = NULL; } if (entry == NULL) { - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } if (size < 0 && !EBIT_TEST(entry->flags, ENTRY_ABORTED)) { - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } mem = entry->mem_obj; @@ -1121,7 +1113,7 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), + http->readbuf, clientCacheHit, http); return; @@ -2084,12 +2076,10 @@ debug(33, 3) ("clientCacheHit: %s, %d bytes\n", http->uri, (int) size); http->flags.hit = 0; if (http->entry == NULL) { - memFree(buf, MEM_CLIENT_SOCK_BUF); debug(33, 3) ("clientCacheHit: request aborted\n"); return; } else if (size <= 0) { /* swap in failure */ - memFree(buf, MEM_CLIENT_SOCK_BUF); debug(33, 3) ("clientCacheHit: swapin failure for %s\n", http->uri); http->log_type = LOG_TCP_SWAPFAIL_MISS; if ((e = http->entry)) { @@ -2110,10 +2100,8 @@ * punt to clientProcessMiss. */ if (e->mem_status == IN_MEMORY || e->store_status == STORE_OK) { - memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); } else if (size == CLIENT_SOCK_SZ && http->out.offset == 0) { - memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); } else { debug(33, 3) ("clientCacheHit: waiting for HTTP reply headers\n"); @@ -2146,7 +2134,6 @@ */ store_client *sc = http->sc; http->entry = NULL; /* saved in e */ - memFree(buf, MEM_CLIENT_SOCK_BUF); /* Warning: storeClientUnregister may abort the object so we must * call storeLocateVary before unregistering, and * storeLocateVary may complete immediately so we cannot @@ -2165,12 +2152,10 @@ case VARY_CANCEL: /* varyEvaluateMatch found a object loop. Process as miss */ debug(33, 1) ("clientProcessHit: Vary object loop!\n"); - memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } if (r->method == METHOD_PURGE) { - memFree(buf, MEM_CLIENT_SOCK_BUF); http->entry = NULL; storeClientUnregister(http->sc, e, http); http->sc = NULL; @@ -2206,7 +2191,6 @@ * be a hit for the requested object. */ http->log_type = LOG_TCP_MISS; - memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } @@ -2218,7 +2202,6 @@ * hit for this object. Qyery the origin. */ http->log_type = LOG_TCP_MISS; - memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } @@ -2268,7 +2251,6 @@ http->log_type = LOG_TCP_MISS; clientProcessMiss(http); } - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } hit: @@ -2279,7 +2261,6 @@ if (mem->reply->sline.status != HTTP_OK) { debug(33, 4) ("clientCacheHit: Reply code %d != 200\n", mem->reply->sline.status); - memFree(buf, MEM_CLIENT_SOCK_BUF); http->log_type = LOG_TCP_MISS; clientProcessMiss(http); return; @@ -2290,7 +2271,6 @@ * be on the safe side. */ http->log_type = LOG_TCP_MISS; - memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } @@ -2309,7 +2289,6 @@ if (mem->reply->sline.status != HTTP_OK) { debug(33, 4) ("clientCacheHit: Reply code %d != 200\n", mem->reply->sline.status); - memFree(buf, MEM_CLIENT_SOCK_BUF); http->log_type = LOG_TCP_MISS; clientProcessMiss(http); return; @@ -2324,7 +2303,6 @@ time_t timestamp = e->timestamp; MemBuf mb = httpPacked304Reply(e->mem_obj->reply); http->log_type = LOG_TCP_IMS_HIT; - memFree(buf, MEM_CLIENT_SOCK_BUF); storeClientUnregister(http->sc, e, http); http->sc = NULL; storeUnlockObject(e); @@ -2638,26 +2616,21 @@ if (conn->chr != http) { /* there is another object in progress, defer this one */ debug(33, 2) ("clientSendMoreHeaderData: Deferring %s\n", storeUrl(entry)); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (http->request->flags.reset_tcp) { - memFree(buf, MEM_CLIENT_SOCK_BUF); comm_reset_close(fd); return; } else if (entry && EBIT_TEST(entry->flags, ENTRY_ABORTED)) { /* call clientWriteComplete so the client socket gets closed */ clientWriteComplete(fd, NULL, 0, COMM_OK, http); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (size < 0) { /* call clientWriteComplete so the client socket gets closed */ clientWriteComplete(fd, NULL, 0, COMM_OK, http); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (size == 0) { /* call clientWriteComplete so the client socket gets closed */ clientWriteComplete(fd, NULL, 0, COMM_OK, http); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } assert(http->out.offset == 0); @@ -2667,7 +2640,6 @@ MemBuf mb; memBufDefInit(&mb); memBufAppend(&mb, buf, size); - memFree(buf, MEM_CLIENT_SOCK_BUF); http->out.offset += body_size; comm_write_mbuf(http->conn->fd, mb, clientWriteComplete, http); return; @@ -2688,7 +2660,6 @@ http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); errorAppendEntry(http->entry, err); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } body_size = size - rep->hdr_sz; @@ -2911,7 +2882,6 @@ static void clientCheckHeaderDone(clientCheckHeaderStateData * state) { - char *buf = state->buf; const char *body_buf = state->body_buf; ssize_t body_size = state->body_size; HttpReply *rep = state->http->reply; @@ -2952,7 +2922,6 @@ comm_write_mbuf(http->conn->fd, mb, clientWriteComplete, http); /* clean up */ aborted: - memFree(buf, MEM_CLIENT_SOCK_BUF); cbdataUnlock(http); http = NULL; } @@ -2980,22 +2949,18 @@ if (conn->chr != http) { /* there is another object in progress, defer this one */ debug(33, 1) ("clientSendMoreData: Deferring %s\n", storeUrl(entry)); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (entry && EBIT_TEST(entry->flags, ENTRY_ABORTED)) { /* call clientWriteComplete so the client socket gets closed */ clientWriteComplete(fd, NULL, 0, COMM_OK, http); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (size < 0) { /* call clientWriteComplete so the client socket gets closed */ clientWriteComplete(fd, NULL, 0, COMM_OK, http); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (size == 0) { /* call clientWriteComplete so the client socket gets closed */ clientWriteComplete(fd, NULL, 0, COMM_OK, http); - memFree(buf, MEM_CLIENT_SOCK_BUF); return; } if (!http->request->range) { @@ -3037,7 +3002,6 @@ /* write */ comm_write_mbuf(fd, mb, clientWriteComplete, http); /* if we don't do it, who will? */ - memFree(buf, MEM_CLIENT_SOCK_BUF); } /* @@ -3054,7 +3018,6 @@ * (second) argument, so we pass in NULL. */ clientWriteComplete(fd, NULL, size, errflag, data); - memFree(buf, MEM_CLIENT_SOCK_BUF); } static void @@ -3101,7 +3064,7 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), + http->readbuf, clientSendMoreHeaderData, http); } @@ -3189,7 +3152,7 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), + http->readbuf, clientSendMoreData, http); } @@ -3417,7 +3380,7 @@ http->out.offset, http->out.offset, CLIENT_SOCK_SZ, - memAllocate(MEM_CLIENT_SOCK_BUF), + http->readbuf, clientCacheHit, http); } else { Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.128 retrieving revision 1.128.2.1 diff -u -r1.128 -r1.128.2.1 --- squid/src/structs.h 18 Aug 2006 23:52:06 -0000 1.128 +++ squid/src/structs.h 19 Aug 2006 16:47:15 -0000 1.128.2.1 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.128 2006/08/18 23:52:06 squidadm Exp $ + * $Id: structs.h,v 1.128.2.1 2006/08/19 16:47:15 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1217,6 +1217,7 @@ } redirect; dlink_node active; squid_off_t maxBodySize; + char readbuf[CLIENT_SOCK_SZ]; }; struct _ConnStateData {