--------------------- PatchSet 3124 Date: 2006/05/18 23:22:00 Author: hno Branch: collapsed_forwarding Tag: (none) Log: indented Members: src/MemObject.cc:1.13.2.3->1.13.2.4 src/MemObject.h:1.9.2.3->1.9.2.4 src/client_side_reply.cc:1.52.2.4->1.52.2.5 src/http.cc:1.35.2.5->1.35.2.6 src/refresh.cc:1.8.4.3->1.8.4.4 src/store.cc:1.26.2.4->1.26.2.5 src/structs.h:1.55.2.4->1.55.2.5 Index: squid3/src/MemObject.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/MemObject.cc,v retrieving revision 1.13.2.3 retrieving revision 1.13.2.4 diff -u -r1.13.2.3 -r1.13.2.4 --- squid3/src/MemObject.cc 18 May 2006 22:35:11 -0000 1.13.2.3 +++ squid3/src/MemObject.cc 18 May 2006 23:22:00 -0000 1.13.2.4 @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.13.2.3 2006/05/18 22:35:11 hno Exp $ + * $Id: MemObject.cc,v 1.13.2.4 2006/05/18 23:22:00 hno Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -121,7 +121,7 @@ storeUnlockObject(ims_entry); ims_entry = NULL; } - + HTTPMSGUNLOCK(_reply); HTTPMSGUNLOCK(request); Index: squid3/src/MemObject.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/MemObject.h,v retrieving revision 1.9.2.3 retrieving revision 1.9.2.4 diff -u -r1.9.2.3 -r1.9.2.4 --- squid3/src/MemObject.h 18 May 2006 22:35:11 -0000 1.9.2.3 +++ squid3/src/MemObject.h 18 May 2006 23:22:00 -0000 1.9.2.4 @@ -1,6 +1,6 @@ /* - * $Id: MemObject.h,v 1.9.2.3 2006/05/18 22:35:11 hno Exp $ + * $Id: MemObject.h,v 1.9.2.4 2006/05/18 23:22:00 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -137,8 +137,8 @@ const char *vary_headers; - StoreEntry *ims_entry; - time_t refresh_timestamp; + StoreEntry *ims_entry; + time_t refresh_timestamp; void delayRead(DeferredRead const &); void kickReads(); Index: squid3/src/client_side_reply.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_reply.cc,v retrieving revision 1.52.2.4 retrieving revision 1.52.2.5 diff -u -r1.52.2.4 -r1.52.2.5 --- squid3/src/client_side_reply.cc 18 May 2006 22:35:11 -0000 1.52.2.4 +++ squid3/src/client_side_reply.cc 18 May 2006 23:22:00 -0000 1.52.2.5 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.52.2.4 2006/05/18 22:35:11 hno Exp $ + * $Id: client_side_reply.cc,v 1.52.2.5 2006/05/18 23:22:00 hno Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -76,16 +76,19 @@ */ removeClientStoreReference(&sc, http); - if (old_entry && old_entry->mem_obj && old_entry->mem_obj->ims_entry && old_entry->mem_obj->ims_entry == http->storeEntry()) { - storeUnlockObject(old_entry->mem_obj->ims_entry); - old_entry->mem_obj->ims_entry = NULL; - } - + if (old_entry && old_entry->mem_obj && old_entry->mem_obj->ims_entry && old_entry->mem_obj->ims_entry == http->storeEntry()) { + storeUnlockObject(old_entry->mem_obj->ims_entry); + old_entry->mem_obj->ims_entry = NULL; + } + /* old_entry might still be set if we didn't yet get the reply * code in HandleIMSReply() */ removeStoreReference(&old_sc, &old_entry); + safe_free(tempBuffer.data); + cbdataReferenceDone(http); + HTTPMSGUNLOCK(reply); } @@ -239,7 +242,7 @@ { char *url = http->uri; StoreEntry *entry = NULL; - int hit = 0; + int hit = 0; debug(88, 3)("clientReplyContext::processExpired: '%s'", http->uri); assert(http->storeEntry()->lastmod >= 0); /* @@ -262,62 +265,72 @@ /* Prepare to make a new temporary request */ saveState(); - if (http->storeEntry()->mem_obj && http->storeEntry()->mem_obj->ims_entry) { - entry = http->storeEntry()->mem_obj->ims_entry; - debug(88, 5) ("clientProcessExpired: collapsed request\n"); - if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { - debug(88, 1) ("clientProcessExpired: collapsed request ABORTED!\n"); - entry = NULL; - } else if (http->storeEntry()->mem_obj->refresh_timestamp + 30 < squid_curtime) { - debug(88, 1) ("clientProcessExpired: collapsed request STALE!\n"); - entry = NULL; - } - if (entry) { - storeLockObject(entry); - hit = 1; - } else { - storeUnlockObject(http->storeEntry()->mem_obj->ims_entry); - http->storeEntry()->mem_obj->ims_entry = NULL; - } - } - if (!entry) { - entry = storeCreateEntry(url, - http->log_uri, - http->request->flags, - http->request->method); - if (http->storeEntry()->mem_obj) { - http->storeEntry()->mem_obj->refresh_timestamp = squid_curtime; - if (Config.onoff.collapsed_forwarding) { - debug(88, 1) ("clientProcessExpired: collapsed request forwarding\n"); /* # */ - http->storeEntry()->mem_obj->ims_entry = entry; - storeLockObject(http->storeEntry()->mem_obj->ims_entry); - } - } - } - + if (http->storeEntry()->mem_obj && http->storeEntry()->mem_obj->ims_entry) { + entry = http->storeEntry()->mem_obj->ims_entry; + debug(88, 5) ("clientProcessExpired: collapsed request\n"); + + if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { + debug(88, 1) ("clientProcessExpired: collapsed request ABORTED!\n"); + entry = NULL; + } else if (http->storeEntry()->mem_obj->refresh_timestamp + 30 < squid_curtime) { + debug(88, 1) ("clientProcessExpired: collapsed request STALE!\n"); + entry = NULL; + } + + if (entry) { + storeLockObject(entry); + hit = 1; + } else { + storeUnlockObject(http->storeEntry()->mem_obj->ims_entry); + http->storeEntry()->mem_obj->ims_entry = NULL; + } + } + + if (!entry) { + entry = storeCreateEntry(url, + http->log_uri, + http->request->flags, + http->request->method); + + if (http->storeEntry()->mem_obj) { + http->storeEntry()->mem_obj->refresh_timestamp = squid_curtime; + + if (Config.onoff.collapsed_forwarding) { + debug(88, 1) ("clientProcessExpired: collapsed request forwarding\n"); /* # */ + http->storeEntry()->mem_obj->ims_entry = entry; + storeLockObject(http->storeEntry()->mem_obj->ims_entry); + } + } + } + /* NOTE, don't call storeLockObject(), storeCreateEntry() does it */ sc = storeClientListAdd(entry, this); + #if DELAY_POOLS /* delay_id is already set on original store client */ sc->setDelayId(DelayId::DelayClient(http)); + #endif http->request->lastmod = old_entry->lastmod; + debug(88, 5)("clientReplyContext::processExpired : lastmod %ld", (long int) entry->lastmod); + http->storeEntry(entry); + assert(http->out.offset == 0); if (!hit) { - /* - * A refcounted pointer so that FwdState stays around as long as - * this clientReplyContext does - */ - FwdState::fwdStart(http->getConn().getRaw() != NULL ? http->getConn()->fd : -1, - http->storeEntry(), - http->request); + /* + * A refcounted pointer so that FwdState stays around as long as + * this clientReplyContext does + */ + FwdState::fwdStart(http->getConn().getRaw() != NULL ? http->getConn()->fd : -1, + http->storeEntry(), + http->request); } else { - debug(88, 0) ("clientReplyContext::processExpired: HIT2"); + debug(88, 0) ("clientReplyContext::processExpired: HIT2"); } /* Register with storage manager to receive updates when data comes in. */ @@ -569,11 +582,11 @@ storeUrl(http->storeEntry()), (long unsigned) result.length); - if (old_entry && old_entry->mem_obj && old_entry->mem_obj->ims_entry) { - storeUnlockObject(old_entry->mem_obj->ims_entry); - old_entry->mem_obj->ims_entry = NULL; - } - + if (old_entry && old_entry->mem_obj && old_entry->mem_obj->ims_entry) { + storeUnlockObject(old_entry->mem_obj->ims_entry); + old_entry->mem_obj->ims_entry = NULL; + } + if (http->storeEntry() == NULL) return; @@ -727,15 +740,15 @@ ) { http->logType = LOG_TCP_NEGATIVE_HIT; sendMoreData(result); - return; + return; } - if (Config.refresh_stale_window > 0 && e->mem_obj && e->mem_obj->refresh_timestamp + Config.refresh_stale_window > squid_curtime && !refreshCheckHTTPStale(e, r)) { - debug(88, 2) ("clientProcessHit: refresh_stale HIT\n"); - goto hit; - } - - if (!Config.onoff.offline && refreshCheckHTTP(e, r) && !http->flags.internal) { + if (Config.refresh_stale_window > 0 && e->mem_obj && e->mem_obj->refresh_timestamp + Config.refresh_stale_window > squid_curtime && !refreshCheckHTTPStale(e, r)) { + debug(88, 2) ("clientProcessHit: refresh_stale HIT\n"); + goto hit; + } + + if (!Config.onoff.offline && refreshCheckHTTP(e, r) && !http->flags.internal) { debug(88, 5) ("clientCacheHit: in refreshCheck() block\n"); /* * We hold a stale copy; it needs to be validated @@ -779,11 +792,12 @@ processMiss(); } - return; + return; } hit: - if (r->flags.ims) { + + if (r->flags.ims) { /* * Handle If-Modified-Since requests from the client */ @@ -818,21 +832,21 @@ triggerInitialStoreRead(); } - return; - } + return; + } + + /* + * plain ol' cache hit + */ - /* - * plain ol' cache hit - */ - - if (e->store_status != STORE_OK) - http->logType = LOG_TCP_MISS; - else if (e->mem_status == IN_MEMORY) - http->logType = LOG_TCP_MEM_HIT; - else if (Config.onoff.offline) - http->logType = LOG_TCP_OFFLINE_HIT; + if (e->store_status != STORE_OK) + http->logType = LOG_TCP_MISS; + else if (e->mem_status == IN_MEMORY) + http->logType = LOG_TCP_MEM_HIT; + else if (Config.onoff.offline) + http->logType = LOG_TCP_OFFLINE_HIT; - sendMoreData(result); + sendMoreData(result); } /* @@ -859,11 +873,11 @@ storeEntryDump(http->storeEntry(), 1); } - /* touch timestamp for refresh_stale_hit */ - if (http->storeEntry()->mem_obj) - http->storeEntry()->mem_obj->refresh_timestamp = squid_curtime; + /* touch timestamp for refresh_stale_hit */ + if (http->storeEntry()->mem_obj) + http->storeEntry()->mem_obj->refresh_timestamp = squid_curtime; - removeClientStoreReference(&sc, http); + removeClientStoreReference(&sc, http); } if (r->method == METHOD_PURGE) { @@ -890,23 +904,24 @@ return; } else { assert(http->out.offset == 0); - + createStoreEntry(r->method, r->flags); - debug(88, 0) ("clientProcessMiss: createStoreEntry.\n"); + debug(88, 0) ("clientProcessMiss: createStoreEntry.\n"); + + if (Config.onoff.collapsed_forwarding && r->flags.cachable && !r->flags.need_validation && (METHOD_GET == r->method || METHOD_HEAD == r->method)) { + /* touch timestamp for refresh_stale_hit */ + + if (http->storeEntry()->mem_obj) + http->storeEntry()->mem_obj->refresh_timestamp = squid_curtime; - if (Config.onoff.collapsed_forwarding && r->flags.cachable && !r->flags.need_validation && (METHOD_GET == r->method || METHOD_HEAD == r->method)) - { - /* touch timestamp for refresh_stale_hit */ - if (http->storeEntry()->mem_obj) - http->storeEntry()->mem_obj->refresh_timestamp = squid_curtime; - - storeSetPublicKey(http->storeEntry()); - - debug(88, 0) ("clientProcessMiss: storeSetPublicKey.\n"); - storeEntryDump(http->storeEntry(), 1); - } - - triggerInitialStoreRead(); + storeSetPublicKey(http->storeEntry()); + + debug(88, 0) ("clientProcessMiss: storeSetPublicKey.\n"); + + storeEntryDump(http->storeEntry(), 1); + } + + triggerInitialStoreRead(); if (http->redirect.status) { HttpReply *rep = new HttpReply; @@ -1765,12 +1780,12 @@ StoreIOBuffer tempBuffer; storeLockObject(http->storeEntry()); - if (http->storeEntry()->store_status == STORE_PENDING && http->storeEntry()->mem_obj) { - if (http->storeEntry()->mem_obj->request) - http->request->hier = http->storeEntry()->mem_obj->request->hier; - }; + if (http->storeEntry()->store_status == STORE_PENDING && http->storeEntry()->mem_obj) { + if (http->storeEntry()->mem_obj->request) + http->request->hier = http->storeEntry()->mem_obj->request->hier; + }; - if (http->storeEntry()->mem_obj == NULL) { + if (http->storeEntry()->mem_obj == NULL) { /* * This if-block exists because we don't want to clobber * a preexiting mem_obj->method value if the mem_obj Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.35.2.5 retrieving revision 1.35.2.6 diff -u -r1.35.2.5 -r1.35.2.6 --- squid3/src/http.cc 18 May 2006 23:15:33 -0000 1.35.2.5 +++ squid3/src/http.cc 18 May 2006 23:22:00 -0000 1.35.2.6 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.35.2.5 2006/05/18 23:15:33 hno Exp $ + * $Id: http.cc,v 1.35.2.6 2006/05/18 23:22:00 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1407,17 +1407,17 @@ /* append X-Forwarded-For */ if (opt_forwarded_for) { - strFwd = hdr_in->getList(HDR_X_FORWARDED_FOR); + strFwd = hdr_in->getList(HDR_X_FORWARDED_FOR); - if (orig_request->client_addr.s_addr != no_addr.s_addr) - strListAdd(&strFwd, inet_ntoa(orig_request->client_addr), ','); - else - strListAdd(&strFwd, "unknown", ','); + if (orig_request->client_addr.s_addr != no_addr.s_addr) + strListAdd(&strFwd, inet_ntoa(orig_request->client_addr), ','); + else + strListAdd(&strFwd, "unknown", ','); - hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.buf()); + hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.buf()); - strFwd.clean(); - } + strFwd.clean(); + } /* append Host if not there already */ if (!hdr_out->has(HDR_HOST)) { @@ -1658,9 +1658,10 @@ break; case HDR_X_FORWARDED_FOR: - if (!opt_forwarded_for) - hdr_out->addEntry(e->clone()); - break; + if (!opt_forwarded_for) + hdr_out->addEntry(e->clone()); + + break; case HDR_RANGE: Index: squid3/src/refresh.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/refresh.cc,v retrieving revision 1.8.4.3 retrieving revision 1.8.4.4 diff -u -r1.8.4.3 -r1.8.4.4 --- squid3/src/refresh.cc 18 May 2006 22:35:12 -0000 1.8.4.3 +++ squid3/src/refresh.cc 18 May 2006 23:22:00 -0000 1.8.4.4 @@ -1,6 +1,6 @@ /* - * $Id: refresh.cc,v 1.8.4.3 2006/05/18 22:35:12 hno Exp $ + * $Id: refresh.cc,v 1.8.4.4 2006/05/18 23:22:00 hno Exp $ * * DEBUG: section 22 Refresh Calculation * AUTHOR: Harvest Derived @@ -439,8 +439,8 @@ int refreshCheckHTTPStale(const StoreEntry * entry, HttpRequest * request) { - int reason = refreshCheck(entry, request, -Config.refresh_stale_window); - return (reason < 200) ? 0 : 1; + int reason = refreshCheck(entry, request, -Config.refresh_stale_window); + return (reason < 200) ? 0 : 1; } int Index: squid3/src/store.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store.cc,v retrieving revision 1.26.2.4 retrieving revision 1.26.2.5 diff -u -r1.26.2.4 -r1.26.2.5 --- squid3/src/store.cc 18 May 2006 23:15:34 -0000 1.26.2.4 +++ squid3/src/store.cc 18 May 2006 23:22:00 -0000 1.26.2.5 @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.26.2.4 2006/05/18 23:15:34 hno Exp $ + * $Id: store.cc,v 1.26.2.5 2006/05/18 23:22:00 hno Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -893,7 +893,7 @@ assert(store_status == STORE_PENDING); mem_obj->refresh_timestamp = squid_curtime; - + StoreIOBuffer tempBuffer; tempBuffer.data = (char *)buf; tempBuffer.length = len; @@ -1554,11 +1554,11 @@ if (EBIT_TEST(e->flags, ENTRY_ABORTED)) return 0; - /* Entries which seem to have got stuck are not valid to be sent to new clients */ - if ((e->store_status == STORE_PENDING) - && (!e->mem_obj || e->mem_obj->refresh_timestamp + 30 < squid_curtime)) - return 0; - + /* Entries which seem to have got stuck are not valid to be sent to new clients */ + if ((e->store_status == STORE_PENDING) + && (!e->mem_obj || e->mem_obj->refresh_timestamp + 30 < squid_curtime)) + return 0; + return 1; } Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v retrieving revision 1.55.2.4 retrieving revision 1.55.2.5 diff -u -r1.55.2.4 -r1.55.2.5 --- squid3/src/structs.h 18 May 2006 22:35:12 -0000 1.55.2.4 +++ squid3/src/structs.h 18 May 2006 23:22:00 -0000 1.55.2.5 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.55.2.4 2006/05/18 22:35:12 hno Exp $ + * $Id: structs.h,v 1.55.2.5 2006/05/18 23:22:00 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -726,7 +726,7 @@ ssl_client; #endif - time_t refresh_stale_window; + time_t refresh_stale_window; }; struct _SquidConfig2