--------------------- PatchSet 11691 Date: 2007/09/22 16:01:30 Author: adrian Branch: HEAD Tag: (none) Log: revert changeset 11108 - reinstate MEM_CLIENT_SOCK_BUF, make it non-zeroable Members: src/client_side.c:1.738->1.739 src/mem.c:1.75->1.76 src/structs.h:1.525->1.526 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid/squid/src/client_side.c,v retrieving revision 1.738 retrieving revision 1.739 diff -u -r1.738 -r1.739 --- squid/src/client_side.c 10 Sep 2007 04:19:49 -0000 1.738 +++ squid/src/client_side.c 22 Sep 2007 16:01:30 -0000 1.739 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.738 2007/09/10 04:19:49 hno Exp $ + * $Id: client_side.c,v 1.739 2007/09/22 16:01:30 adrian Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -399,7 +399,7 @@ if (h->log_type != LOG_TCP_DENIED) delaySetStoreClient(h->sc, delayClient(h)); #endif - storeClientCopy(h->sc, e, 0, 0, CLIENT_SOCK_SZ, h->readbuf, clientSendMoreHeaderData, h); + storeClientCopy(h->sc, e, 0, 0, CLIENT_SOCK_SZ, memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreHeaderData, h); return e; } @@ -699,9 +699,11 @@ 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; } @@ -709,6 +711,7 @@ 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; } @@ -717,6 +720,7 @@ 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, @@ -731,6 +735,7 @@ } 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); @@ -775,7 +780,8 @@ storeClientCopy(http->sc, entry, http->out.offset, http->out.offset, - CLIENT_SOCK_SZ, http->readbuf, + CLIENT_SOCK_SZ, + memAllocate(MEM_CLIENT_SOCK_BUF), clientHandleETagReply, http); } @@ -859,7 +865,8 @@ storeClientCopy(http->sc, entry, http->out.offset, http->out.offset, - CLIENT_SOCK_SZ, http->readbuf, + CLIENT_SOCK_SZ, + memAllocate(MEM_CLIENT_SOCK_BUF), clientHandleIMSReply, http); } @@ -939,9 +946,11 @@ 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; @@ -1110,7 +1119,8 @@ storeClientCopy(http->sc, http->entry, http->out.offset, http->out.offset, - CLIENT_SOCK_SZ, http->readbuf, + CLIENT_SOCK_SZ, + memAllocate(MEM_CLIENT_SOCK_BUF), clientCacheHit, http); return; @@ -2117,10 +2127,12 @@ 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; clientProcessMiss(http); @@ -2131,11 +2143,13 @@ assert(!EBIT_TEST(e->flags, ENTRY_ABORTED)); if (!memHaveHeaders(mem)) { debug(33, 1) ("clientCacheHit: No reply headers in '%s'?\n", e->mem_obj->url); + memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } if (strcmp(mem->url, urlCanonical(r)) != 0) { debug(33, 1) ("clientCacheHit: URL mismatch '%s' != '%s'?\n", e->mem_obj->url, urlCanonical(r)); + memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } @@ -2171,6 +2185,7 @@ * so we only get here once. (it also takes care of cancelling loops) */ debug(33, 2) ("clientProcessHit: Vary detected!\n"); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } case VARY_RESTART: @@ -2180,11 +2195,13 @@ safe_free(r->vary_hdr); safe_free(r->vary_headers); clientProcessRequest(http); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; case VARY_CANCEL: /* varyEvaluateMatch found a object loop. Process as miss */ debug(33, 1) ("clientProcessHit: Vary object loop!\n"); clientProcessMiss(http); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } if (r->method == METHOD_PURGE) { @@ -2193,6 +2210,7 @@ http->sc = NULL; storeUnlockObject(e); clientPurgeRequest(http); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } http->flags.hit = 1; @@ -2206,6 +2224,7 @@ clientSendMoreHeaderData(data, buf, size); } else { http->log_type = LOG_TCP_MISS; + memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); } return; @@ -2223,6 +2242,7 @@ * Query the origin to see what should be done. */ http->log_type = LOG_TCP_MISS; + memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } @@ -2235,6 +2255,7 @@ debug(33, 4) ("clientCacheHit: Reply code %d != 200\n", mem->reply->sline.status); http->log_type = LOG_TCP_MISS; + memFree(buf, MEM_CLIENT_SOCK_BUF); clientProcessMiss(http); return; } @@ -2300,6 +2321,7 @@ } else { clientProcessExpired(http); } + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } if (is_modified == 0) { @@ -2321,6 +2343,7 @@ storeAppend(e, mb.buf, mb.size); memBufClean(&mb); storeComplete(e); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } /* @@ -2606,21 +2629,26 @@ if (DLINK_HEAD(conn->reqs) != 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) { comm_reset_close(fd); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } else if (entry && EBIT_TEST(entry->flags, ENTRY_ABORTED)) { /* call clientWriteComplete so the client socket gets closed */ + memFree(buf, MEM_CLIENT_SOCK_BUF); clientWriteComplete(fd, NULL, 0, COMM_OK, http); 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); @@ -2633,6 +2661,7 @@ http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); errorAppendEntry(http->entry, err); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } clientMaxBodySize(http->request, http, rep); @@ -2645,6 +2674,7 @@ http->entry = clientCreateStoreEntry(http, http->request->method, null_request_flags); errorAppendEntry(http->entry, err); + memFree(buf, MEM_CLIENT_SOCK_BUF); return; } /* @@ -2659,6 +2689,7 @@ */ http->range_iter.prefix_size = rep->hdr_sz; debug(33, 3) ("clientSendMoreHeaderData: %d bytes of headers\n", rep->hdr_sz); + memFree(buf, MEM_CLIENT_SOCK_BUF); clientHttpLocationRewriteCheck(http); } @@ -2858,7 +2889,7 @@ storeClientCopy(http->sc, http->entry, http->out.offset, http->out.offset, - CLIENT_SOCK_SZ, http->readbuf, + CLIENT_SOCK_SZ, memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, http); } @@ -2888,18 +2919,22 @@ if (DLINK_HEAD(conn->reqs) != 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) { @@ -2940,6 +2975,7 @@ } /* write body */ comm_write_mbuf(fd, mb, clientWriteComplete, http); + memFree(buf, MEM_CLIENT_SOCK_BUF); } /* @@ -2955,6 +2991,7 @@ * NOTE: clientWriteComplete doesn't currently use its "buf" * (second) argument, so we pass in NULL. */ + memFree(buf, MEM_CLIENT_SOCK_BUF); clientWriteComplete(fd, NULL, size, errflag, data); } @@ -3005,7 +3042,8 @@ storeClientCopy(http->sc, entry, http->out.offset, http->out.offset, - CLIENT_SOCK_SZ, http->readbuf, + CLIENT_SOCK_SZ, + memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreHeaderData, http); } @@ -3089,7 +3127,7 @@ storeClientCopy(http->sc, entry, http->out.offset, http->out.offset, - CLIENT_SOCK_SZ, http->readbuf, + CLIENT_SOCK_SZ, memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, http); } @@ -3314,7 +3352,8 @@ storeClientCopy(http->sc, http->entry, http->out.offset, http->out.offset, - CLIENT_SOCK_SZ, http->readbuf, + CLIENT_SOCK_SZ, + memAllocate(MEM_CLIENT_SOCK_BUF), clientCacheHit, http); } else { Index: squid/src/mem.c =================================================================== RCS file: /cvsroot/squid/squid/src/mem.c,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- squid/src/mem.c 21 Sep 2007 14:17:14 -0000 1.75 +++ squid/src/mem.c 22 Sep 2007 16:01:31 -0000 1.76 @@ -1,6 +1,6 @@ /* - * $Id: mem.c,v 1.75 2007/09/21 14:17:14 hno Exp $ + * $Id: mem.c,v 1.76 2007/09/22 16:01:31 adrian Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -312,6 +312,7 @@ memDataInit(MEM_64K_BUF, "64K Buffer", 65536, 10); memDataNonZero(MEM_64K_BUF); memDataInit(MEM_CLIENT_SOCK_BUF, "Client Socket Buffer", CLIENT_SOCK_SZ, 0); + memDataNonZero(MEM_CLIENT_SOCK_BUF); memDataInit(MEM_ACL, "acl", sizeof(acl), 0); memDataInit(MEM_ACL_DENY_INFO_LIST, "acl_deny_info_list", sizeof(acl_deny_info_list), 0); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.525 retrieving revision 1.526 diff -u -r1.525 -r1.526 --- squid/src/structs.h 21 Sep 2007 09:35:42 -0000 1.525 +++ squid/src/structs.h 22 Sep 2007 16:01:31 -0000 1.526 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.525 2007/09/21 09:35:42 adrian Exp $ + * $Id: structs.h,v 1.526 2007/09/22 16:01:31 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1238,12 +1238,6 @@ } redirect; dlink_node active; squid_off_t maxBodySize; - /* - * This can be changed into a pointer later on when the memory allocator - * has been taught the difference between buffers to zero and buffers not to - * zero.. [ahc] - */ - char readbuf[CLIENT_SOCK_SZ]; }; struct _ConnStateData {