From: wessels <> Date: Fri, 19 May 2006 23:19:09 +0000 (+0000) Subject: Fully deprecated storeLockObject(). Everything now directly calls the X-Git-Tag: SQUID_3_0_PRE4~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=34266cde62fbe93fe487048c9b5291a68769fbc8;p=thirdparty%2Fsquid.git Fully deprecated storeLockObject(). Everything now directly calls the StoreEntry->lock() method. --- diff --git a/src/Server.cc b/src/Server.cc index a8e571bbb5..a3a489bbc2 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -1,5 +1,5 @@ /* - * $Id: Server.cc,v 1.4 2006/05/19 17:05:18 wessels Exp $ + * $Id: Server.cc,v 1.5 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: * AUTHOR: Duane Wessels @@ -45,7 +45,10 @@ ServerStateData::ServerStateData(FwdState *theFwdState) { fwd = theFwdState; entry = fwd->entry; - storeLockObject(entry); + + entry->lock() + + ; request = HTTPMSGLOCK(fwd->request); } diff --git a/src/Store.h b/src/Store.h index d13aea3132..195315c15f 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.21 2006/05/19 17:05:18 wessels Exp $ + * $Id: Store.h,v 1.22 2006/05/19 17:19:09 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -283,7 +283,6 @@ SQUIDCEXTERN void storeCreateMemObject(StoreEntry *, const char *, const char *) SQUIDCEXTERN void storeInit(void); SQUIDCEXTERN void storeAbort(StoreEntry *); SQUIDCEXTERN void storeAppend(StoreEntry *, const char *, int); -SQUIDCEXTERN void storeLockObject(StoreEntry *); SQUIDCEXTERN void storeRelease(StoreEntry *); SQUIDCEXTERN void storeExpireNow(StoreEntry *); SQUIDCEXTERN void storeReleaseRequest(StoreEntry *); diff --git a/src/asn.cc b/src/asn.cc index d32783ed3f..248c608c98 100644 --- a/src/asn.cc +++ b/src/asn.cc @@ -1,6 +1,6 @@ /* - * $Id: asn.cc,v 1.106 2006/05/19 17:05:18 wessels Exp $ + * $Id: asn.cc,v 1.107 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -244,7 +244,10 @@ asnCacheStart(int as) asState->sc = storeClientListAdd(e, asState); FwdState::fwdStart(-1, e, asState->request); } else { - storeLockObject(e); + + e->lock() + + ; asState->sc = storeClientListAdd(e, asState); } diff --git a/src/cache_manager.cc b/src/cache_manager.cc index f4c6fc0469..8c29a0c3dc 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.cc,v 1.41 2006/05/19 17:05:18 wessels Exp $ + * $Id: cache_manager.cc,v 1.42 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -260,12 +260,18 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry) } mgr->entry = entry; - storeLockObject(entry); + + entry->lock() + + ; entry->expires = squid_curtime; + debug(16, 5) ("CACHEMGR: %s requesting '%s'\n", fd_table[fd].ipaddr, mgr->action); + /* get additional info from request headers */ cachemgrParseHeaders(mgr, request); + /* Check password */ if (cachemgrCheckPassword(mgr) != 0) { diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index bcf5d1d47e..866b1837b4 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.106 2006/05/19 17:05:18 wessels Exp $ + * $Id: client_side_reply.cc,v 1.107 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -256,7 +256,7 @@ clientReplyContext::processExpired() saveState(); entry = storeCreateEntry(url, http->log_uri, http->request->flags, http->request->method); - /* NOTE, don't call storeLockObject(), storeCreateEntry() does it */ + /* NOTE, don't call StoreEntry->lock(), storeCreateEntry() does it */ sc = storeClientListAdd(entry, this); #if DELAY_POOLS /* delay_id is already set on original store client */ @@ -927,15 +927,26 @@ clientReplyContext::purgeFoundObject(StoreEntry *entry) StoreIOBuffer tempBuffer; /* Swap in the metadata */ http->storeEntry(entry); - storeLockObject(http->storeEntry()); + + http->storeEntry()->lock() + + ; storeCreateMemObject(http->storeEntry(), http->uri, http->log_uri); + http->storeEntry()->mem_obj->method = http->request->method; + sc = storeClientListAdd(http->storeEntry(), this); + http->logType = LOG_TCP_HIT; + reqofs = 0; + tempBuffer.offset = http->out.offset; + tempBuffer.length = next()->readBuffer.length; + tempBuffer.data = next()->readBuffer.data; + storeClientCopy(sc, http->storeEntry(), tempBuffer, CacheHit, this); } @@ -1680,7 +1691,10 @@ clientReplyContext::doGetMoreData() if (http->storeEntry() != NULL) { /* someone found the object in the cache for us */ StoreIOBuffer tempBuffer; - storeLockObject(http->storeEntry()); + + http->storeEntry()->lock() + + ; if (http->storeEntry()->mem_obj == NULL) { /* diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 23d2c057a5..937bc18c83 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.67 2006/05/19 17:05:18 wessels Exp $ + * $Id: client_side_request.cc,v 1.68 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1013,7 +1013,9 @@ ClientHttpRequest::loggingEntry(StoreEntry *newEntry) loggingEntry_ = newEntry; if (loggingEntry_) - storeLockObject(loggingEntry_); + loggingEntry_->lock() + + ; } /* diff --git a/src/errorpage.cc b/src/errorpage.cc index dee998d8ec..60b45e2f3e 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.213 2006/05/19 17:05:18 wessels Exp $ + * $Id: errorpage.cc,v 1.214 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -370,22 +370,34 @@ errorAppendEntry(StoreEntry * entry, ErrorState * err) } } - storeLockObject(entry); + entry->lock() + + ; storeBuffer(entry); + rep = errorBuildReply(err); + /* Add authentication header */ /* TODO: alter errorstate to be accel on|off aware. The 0 on the next line * depends on authenticate behaviour: all schemes to date send no extra data * on 407/401 responses, and do not check the accel state on 401/407 responses */ authenticateFixHeader(rep, err->auth_user_request, err->request, 0, 1); + entry->replaceHttpReply(rep); + EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); + storeBufferFlush(entry); + entry->complete(); + storeNegativeCache(entry); + storeReleaseRequest(entry); + entry->unlock(); + errorStateFree(err); } diff --git a/src/forward.cc b/src/forward.cc index 12df4ed013..1eb90bfd21 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.143 2006/05/19 17:05:18 wessels Exp $ + * $Id: forward.cc,v 1.144 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -78,8 +78,12 @@ FwdState::FwdState(int fd, StoreEntry * e, HttpRequest * r) server_fd = -1; request = HTTPMSGLOCK(r); start_t = squid_curtime; - storeLockObject(e); + + e->lock() + + ; EBIT_SET(e->flags, ENTRY_FWD_HDR_WAIT); + self = this; // refcounted } diff --git a/src/gopher.cc b/src/gopher.cc index 3a890c3cbd..b01789b60d 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.196 2006/05/19 17:05:18 wessels Exp $ + * $Id: gopher.cc,v 1.197 2006/05/19 17:19:09 wessels Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -942,15 +942,24 @@ gopherStart(FwdState * fwd) CBDATA_INIT_TYPE(GopherStateData); gopherState = cbdataAlloc(GopherStateData); gopherState->buf = (char *)memAllocate(MEM_4K_BUF); - storeLockObject(entry); + + entry->lock() + + ; gopherState->entry = entry; + gopherState->fwd = fwd; + debug(10, 3) ("gopherStart: %s\n", storeUrl(entry)); + statCounter.server.all.requests++; + statCounter.server.other.requests++; + /* Parse url. */ gopher_request_parse(fwd->request, &gopherState->type_id, gopherState->request); + comm_add_close_handler(fd, gopherStateFree, gopherState); if (((gopherState->type_id == GOPHER_INDEX) || (gopherState->type_id == GOPHER_CSO)) diff --git a/src/peer_digest.cc b/src/peer_digest.cc index dc0ce2ba8a..f0ff2e2db9 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.114 2006/05/19 17:05:18 wessels Exp $ + * $Id: peer_digest.cc,v 1.115 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -362,8 +362,12 @@ peerDigestRequest(PeerDigest * pd) if (old_e) { debug(72, 5) ("peerDigestRequest: found old entry\n"); - storeLockObject(old_e); + + old_e->lock() + + ; storeCreateMemObject(old_e, url, url); + fetch->old_sc = storeClientListAdd(old_e, fetch); } diff --git a/src/peer_select.cc b/src/peer_select.cc index aee93190a1..3d8ae69429 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.139 2006/05/19 17:05:18 wessels Exp $ + * $Id: peer_select.cc,v 1.140 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -177,7 +177,9 @@ peerSelect(HttpRequest * request, #endif if (psstate->entry) - storeLockObject(psstate->entry); + psstate->entry->lock() + + ; peerSelectFoo(psstate); } diff --git a/src/repl/heap/store_repl_heap.cc b/src/repl/heap/store_repl_heap.cc index 20208eeb47..40a452a611 100644 --- a/src/repl/heap/store_repl_heap.cc +++ b/src/repl/heap/store_repl_heap.cc @@ -1,6 +1,6 @@ /* - * $Id: store_repl_heap.cc,v 1.19 2006/05/19 17:05:18 wessels Exp $ + * $Id: store_repl_heap.cc,v 1.20 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section ? HEAP based removal policies * AUTHOR: Henrik Nordstrom @@ -233,8 +233,12 @@ try_again: entry = (StoreEntry *)heap_extractmin(heap->theHeap); if (storeEntryLocked(entry)) { - storeLockObject(entry); + + entry->lock() + + ; linklistPush(&heap_walker->locked_entries, entry); + goto try_again; } diff --git a/src/stat.cc b/src/stat.cc index 430e186ec9..50cd5f255f 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.393 2006/05/19 17:05:18 wessels Exp $ + * $Id: stat.cc,v 1.394 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -386,8 +386,12 @@ statObjectsStart(StoreEntry * sentry, STOBJFLT * filter) StatObjectsState *state = new StatObjectsState; state->sentry = sentry; state->filter = filter; - storeLockObject(sentry); + + sentry->lock() + + ; state->theSearch = Store::Root().search(NULL, NULL); + eventAdd("statObjects", statObjects, state, 0.0, 1); } diff --git a/src/store.cc b/src/store.cc index ed8b1a8b69..532d1509b0 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.590 2006/05/19 17:05:18 wessels Exp $ + * $Id: store.cc,v 1.591 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -455,16 +455,6 @@ storePurgeMem(StoreEntry * e) storeRelease(e); } -/* DEPRECATED: please use e->lock(); */ -void -storeLockObject(StoreEntry * e) -{ - - e->lock() - - ; -} - /* RBC 20050104 this is wrong- memory ref counting * is not at all equivalent to the store 'usage' concept * which the replacement policies should be acting upon. @@ -477,7 +467,7 @@ void StoreEntry::lock() { lock_count++; - debugs(20, 3, "storeLockObject: key '" << getMD5Text() <<"' count=" << + debugs(20, 3, "StoreEntry::lock: key '" << getMD5Text() <<"' count=" << lock_count << "\n"); lastref = squid_curtime; Store::Root().reference(*this); @@ -1143,12 +1133,20 @@ storeAbort(StoreEntry * e) assert(e->store_status == STORE_PENDING); assert(mem != NULL); debug(20, 6) ("storeAbort: %s\n", e->getMD5Text()); - storeLockObject(e); /* lock while aborting */ + + e->lock() + + ; /* lock while aborting */ storeNegativeCache(e); + storeReleaseRequest(e); + EBIT_SET(e->flags, ENTRY_ABORTED); + storeSetMemStatus(e, NOT_IN_MEMORY); + e->store_status = STORE_OK; + /* * We assign an object length here. The only other place we assign * the object length is in storeComplete() @@ -1158,6 +1156,7 @@ storeAbort(StoreEntry * e) * the object length is inappropriate to set. */ mem->object_sz = mem->endOffset(); + /* Notify the server side */ if (mem->abort.callback) { @@ -1301,8 +1300,8 @@ storeRelease(StoreEntry * e) if (e->swap_filen > -1) { /* - * Fake a call to storeLockObject(). When rebuilding is done, - * we'll just call e->unlock() on these. + * Fake a call to StoreEntry->lock() When rebuilding is done, + * we'll just call StoreEntry->unlock() on these. */ e->lock_count++; e->setReleaseFlag(); diff --git a/src/store_swapout.cc b/src/store_swapout.cc index bcf6fd7042..e4d2c626d0 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.cc,v 1.102 2006/05/19 17:05:18 wessels Exp $ + * $Id: store_swapout.cc,v 1.103 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -76,19 +76,26 @@ storeSwapOutStart(StoreEntry * e) mem->swapout.sio = sio; /* Don't lock until after create, or the replacement * code might get confused */ - storeLockObject(e); + + e->lock() + + ; /* Pick up the file number if it was assigned immediately */ e->swap_filen = mem->swapout.sio->swap_filen; + e->swap_dirn = mem->swapout.sio->swap_dirn; + /* write out the swap metadata */ /* TODO: make some sort of data,size refcounted immutable buffer * for use by this sort of function. */ char const *buf = e->getSerialisedMetaData (); + /* If we start swapping out with out of band metadata, this assert * will catch it - this code needs to be adjusted if that happens */ assert (buf); + storeIOWrite(mem->swapout.sio, buf, mem->swap_hdr_sz, 0, xfree); } diff --git a/src/urn.cc b/src/urn.cc index 4a3b683866..9a59b06dfd 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,6 +1,6 @@ /* - * $Id: urn.cc,v 1.100 2006/05/19 17:05:18 wessels Exp $ + * $Id: urn.cc,v 1.101 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -245,7 +245,10 @@ UrnState::start(HttpRequest * r, StoreEntry * e) debug(52, 3) ("urnStart: '%s'\n", storeUrl(e)); entry = e; request = HTTPMSGLOCK(r); - storeLockObject(entry); + + entry->lock() + + ; setUriResFromRequest(r); if (urlres_r == NULL) @@ -264,7 +267,10 @@ UrnState::created(StoreEntry *newEntry) sc = storeClientListAdd(urlres_e, this); FwdState::fwdStart(-1, urlres_e, urlres_r); } else { - storeLockObject(urlres_e); + + urlres_e->lock() + + ; sc = storeClientListAdd(urlres_e, this); } diff --git a/src/wais.cc b/src/wais.cc index 2f5646836e..29af70d6f0 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -1,6 +1,6 @@ /* - * $Id: wais.cc,v 1.159 2006/05/19 17:05:18 wessels Exp $ + * $Id: wais.cc,v 1.160 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 24 WAIS Relay * AUTHOR: Harvest Derived @@ -266,7 +266,11 @@ waisStart(FwdState * fwd) waisState->request = HTTPMSGLOCK(request); waisState->fwd = fwd; comm_add_close_handler(waisState->fd, waisStateFree, waisState); - storeLockObject(entry); + + entry->lock() + + ; commSetTimeout(fd, Config.Timeout.read, waisTimeout, waisState); + waisSendRequest(fd, waisState); } diff --git a/src/whois.cc b/src/whois.cc index e8b0ddebd1..30f9a61119 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -1,6 +1,6 @@ /* - * $Id: whois.cc,v 1.34 2006/05/19 17:05:18 wessels Exp $ + * $Id: whois.cc,v 1.35 2006/05/19 17:19:10 wessels Exp $ * * DEBUG: section 75 WHOIS protocol * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -89,13 +89,22 @@ whoisStart(FwdState * fwd) p->entry = fwd->entry; p->fwd = fwd; p->dataWritten = 0; - storeLockObject(p->entry); + + p->entry->lock() + + ; comm_add_close_handler(fd, whoisClose, p); + l = p->request->urlpath.size() + 3; + buf = (char *)xmalloc(l); + snprintf(buf, l, "%s\r\n", p->request->urlpath.buf() + 1); + comm_write(fd, buf, strlen(buf), whoisWriteComplete, p); + comm_read(fd, p->buf, BUFSIZ, whoisReadReply, p); + commSetTimeout(fd, Config.Timeout.read, whoisTimeout, p); }