extern "C" CSR clientGetMoreData;
extern "C" CSD clientReplyDetach;
-/*
- * clientCacheHit should only be called until the HTTP reply headers
+/**
+ * clientReplyContext::cacheHit Should only be called until the HTTP reply headers
* have been parsed. Normally this should be a single call, but
* it might take more than one. As soon as we have the headers,
* we hand off to clientSendMoreData, processExpired, or
clientReplyContext::CacheHit(void *data, StoreIOBuffer result)
{
clientReplyContext *context = (clientReplyContext *)data;
- context->cacheHit (result);
+ context->cacheHit(result);
}
+/**
+ * Process a possible cache HIT.
+ */
void
clientReplyContext::cacheHit(StoreIOBuffer result)
{
+ /** Ignore if the HIT object is being deleted. */
if (deleting)
return;
}
}
-/*
+/**
* Prepare to fetch the object as it's a cache miss of some kind.
*/
void
HttpRequest *r = http->request;
ErrorState *err = NULL;
debugs(88, 4, "clientProcessMiss: '" << RequestMethodStr(r->method) << " " << url << "'");
- /*
+
+ /**
* We might have a left-over StoreEntry from a failed cache hit
* or IMS request.
*/
-
if (http->storeEntry()) {
if (EBIT_TEST(http->storeEntry()->flags, ENTRY_SPECIAL)) {
debugs(88, 0, "clientProcessMiss: miss on a special object (" << url << ").");
removeClientStoreReference(&sc, http);
}
+ /** Check if its a PURGE request to be actioned. */
if (r->method == METHOD_PURGE) {
purgeRequest();
return;
}
+ /** Check if its an 'OTHER' request. Purge all cached entries if so and continue. */
if (r->method == METHOD_OTHER) {
- // invalidate all cache entries
purgeAllCached();
}
+ /** Check if 'only-if-cached' flag is set. Action if so. */
if (http->onlyIfCached()) {
processOnlyIfCachedMiss();
return;
}
- /*
+ /**
* Deny loops when running in accelerator/transproxy mode.
*/
if (http->flags.accel && r->flags.loopdetect) {
return;
}
+ /** Check for internal requests. Update Protocol info if so. */
if (http->flags.internal)
r->protocol = PROTO_INTERNAL;
+ /** Start forwarding to get the new object from network */
FwdState::fwdStart(http->getConn() != NULL ? http->getConn()->fd : -1,
http->storeEntry(),
r);
}
}
-/*
+/**
* client issued a request with an only-if-cached cache-control directive;
* we did not find a cached object that can be returned without
* contacting other servers;
}
}
+/**
+ * Check state of the current StoreEntry object.
+ * to see if we can determine the final status of the request.
+ */
void
clientReplyContext::identifyFoundObject(StoreEntry *newEntry)
{
StoreEntry *e = newEntry;
HttpRequest *r = http->request;
+ /** \item If the entry received isNull() then we ignore it. */
if (e->isNull()) {
http->storeEntry(NULL);
} else {
}
e = http->storeEntry();
- /* Release IP-cache entries on reload */
+ /* Release IP-cache entries on reload */
+ /** \item If the request has no-cache flag set or some no_cache HACK in operation we
+ * 'invalidate' the cached IP entries for this request ???
+ */
if (r->flags.nocache) {
#if USE_DNSSERVERS
#endif
if (NULL == http->storeEntry()) {
- /* this object isn't in the cache */
- debugs(85, 3, "clientProcessRequest2: storeGet() MISS");
+ /** \item If no StoreEntry object is current assume this object isn't in the cache set MISS*/
+ debugs(85, 3, "clientProcessRequest2: StoreEntry is NULL - MISS");
http->logType = LOG_TCP_MISS;
doGetMoreData();
return;
}
if (Config.onoff.offline) {
+ /** \item If we are running in offline mode set to HIT */
debugs(85, 3, "clientProcessRequest2: offline HIT");
http->logType = LOG_TCP_HIT;
doGetMoreData();
}
if (http->redirect.status) {
- /* force this to be a miss */
+ /** \item If redirection status is True force this to be a MISS */
+ debugs(85, 3, "clientProcessRequest2: redirectStatus forced StoreEntry to NULL - MISS");
http->storeEntry(NULL);
http->logType = LOG_TCP_MISS;
doGetMoreData();
* the method as GET.
*/
http->storeEntry()->createMemObject(http->uri, http->log_uri);
- http->storeEntry()->mem_obj->method =
- http->request->method;
+ http->storeEntry()->mem_obj->method = http->request->method;
}
sc = storeClientListAdd(http->storeEntry(), this);
return NULL;
}
-/*
+/**
* Calculate how stale the response is (or will be at the check_time).
* Staleness calculation is based on the following: (1) response
* expiration time, (2) age greater than configured maximum, (3)
* last-modified factor, and (4) age less than configured minimum.
*
- * If the response is fresh, return -1. Otherwise return its
- * staleness. NOTE return value of 0 means the response is stale.
+ * \retval -1 If the response is fresh.
+ * \retval >0 Otherwise return it's staleness.
+ * \retval 0 NOTE return value of 0 means the response is stale.
*
* The 'stale_flags' structure is used to tell the calling function
* _why_ this response is fresh or stale. Its used, for example,
static int
refreshStaleness(const StoreEntry * entry, time_t check_time, time_t age, const refresh_t * R, stale_flags * sf)
{
- /*
- * Check for an explicit expiration time.
+ /** \par
+ * Check for an explicit expiration time (Expires: header).
*/
if (entry->expires > -1) {
}
assert(age >= 0);
- /*
+ /** \par
* Use local heuristics to determine staleness. Start with the
* max age from the refresh_pattern rule.
*/
return (age - R->max);
}
- /*
- * Try the last-modified factor algorithm.
+ /** \par
+ * Try the last-modified factor algorithm: refresh_pattern n% percentage of Last-Modified: age.
*/
if (entry->lastmod > -1 && entry->timestamp > entry->lastmod) {
/*
}
}
- /*
- * If we are here, staleness is determined by the refresh_pattern
+ /** \par
+ * Finally, if all else fails; staleness is determined by the refresh_pattern
* configured minimum age.
*/
if (age < R->min) {
return (age - R->min);
}
-/* return 1 if the entry must be revalidated within delta seconds
- * 0 otherwise
+/**
+ * \retval 1 if the entry must be revalidated within delta seconds
+ * \retval 0 otherwise
*
* note: request maybe null (e.g. for cache digests build)
*/
debugs(22, 3, "refreshCheck: '" << (uri ? uri : "<none>") << "'");
+ assert(age >= 0);
if (check_time > entry->timestamp)
age = check_time - entry->timestamp;
+ assert(age >= 0);
R = uri ? refreshLimits(uri) : refreshUncompiledPattern(".");
if (NULL == R)
memset(&sf, '\0', sizeof(sf));
+ assert(age >= 0);
staleness = refreshStaleness(entry, check_time, age, R, &sf);
debugs(22, 3, "Staleness = " << staleness);