StoreEntry->lock() method.
/*
- * $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
{
fwd = theFwdState;
entry = fwd->entry;
- storeLockObject(entry);
+
+ entry->lock()
+
+ ;
request = HTTPMSGLOCK(fwd->request);
}
/*
- * $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/
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 *);
/*
- * $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
asState->sc = storeClientListAdd(e, asState);
FwdState::fwdStart(-1, e, asState->request);
} else {
- storeLockObject(e);
+
+ e->lock()
+
+ ;
asState->sc = storeClientListAdd(e, asState);
}
/*
- * $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
}
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) {
/*
- * $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)
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 */
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);
}
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) {
/*
/*
- * $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)
loggingEntry_ = newEntry;
if (loggingEntry_)
- storeLockObject(loggingEntry_);
+ loggingEntry_->lock()
+
+ ;
}
/*
/*
- * $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
}
}
- 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);
}
/*
- * $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
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
}
/*
- * $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
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))
/*
- * $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
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);
}
/*
- * $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
#endif
if (psstate->entry)
- storeLockObject(psstate->entry);
+ psstate->entry->lock()
+
+ ;
peerSelectFoo(psstate);
}
/*
- * $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
entry = (StoreEntry *)heap_extractmin(heap->theHeap);
if (storeEntryLocked(entry)) {
- storeLockObject(entry);
+
+ entry->lock()
+
+ ;
linklistPush(&heap_walker->locked_entries, entry);
+
goto try_again;
}
/*
- * $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
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);
}
/*
- * $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
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.
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);
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()
* the object length is inappropriate to set.
*/
mem->object_sz = mem->endOffset();
+
/* Notify the server side */
if (mem->abort.callback) {
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();
/*
- * $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
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);
}
/*
- * $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
debug(52, 3) ("urnStart: '%s'\n", storeUrl(e));
entry = e;
request = HTTPMSGLOCK(r);
- storeLockObject(entry);
+
+ entry->lock()
+
+ ;
setUriResFromRequest(r);
if (urlres_r == NULL)
sc = storeClientListAdd(urlres_e, this);
FwdState::fwdStart(-1, urlres_e, urlres_r);
} else {
- storeLockObject(urlres_e);
+
+ urlres_e->lock()
+
+ ;
sc = storeClientListAdd(urlres_e, this);
}
/*
- * $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
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);
}
/*
- * $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
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);
}