{
public:
- HttpDetails() : method(Http::METHOD_NONE), code(0), content_type(NULL),
+ HttpDetails() :
+ method(Http::METHOD_NONE),
+ code(0),
+ content_type(NULL),
timedout(false),
aborted(false),
clientRequestSz(),
CacheDetails() : caddr(),
highOffset(0),
objectSize(0),
- code (LOG_TAG_NONE),
+ code(LOG_TAG_NONE),
rfc931 (NULL),
extuser(NULL),
#if USE_OPENSSL
#include "LogTags.h"
// old deprecated tag strings
-const char * LogTags_str[] = {
+const char * LogTags::Str_[] = {
"TAG_NONE",
"TCP_HIT",
"TCP_MISS",
"ICP_QUERY",
"TYPE_MAX"
};
+
+const char *
+LogTags::c_str() const
+{
+ return Str_[oldType];
+}
+
+bool
+LogTags::isTcpHit() const
+{
+ return
+ (oldType == LOG_TCP_HIT) ||
+ (oldType == LOG_TCP_IMS_HIT) ||
+ (oldType == LOG_TCP_REFRESH_FAIL_OLD) ||
+ (oldType == LOG_TCP_REFRESH_UNMODIFIED) ||
+ (oldType == LOG_TCP_NEGATIVE_HIT) ||
+ (oldType == LOG_TCP_MEM_HIT) ||
+ (oldType == LOG_TCP_OFFLINE_HIT);
+}
LOG_UDP_MISS_NOFETCH,
LOG_ICP_QUERY,
LOG_TYPE_MAX
-} LogTags;
+} LogTags_ot;
-/// list of string representations for LogTags
-extern const char *LogTags_str[];
-
-/// determine if the log tag code indicates a cache HIT
-inline bool logTypeIsATcpHit(LogTags code)
+class LogTags
{
- return
- (code == LOG_TCP_HIT) ||
- (code == LOG_TCP_IMS_HIT) ||
- (code == LOG_TCP_REFRESH_FAIL_OLD) ||
- (code == LOG_TCP_REFRESH_UNMODIFIED) ||
- (code == LOG_TCP_NEGATIVE_HIT) ||
- (code == LOG_TCP_MEM_HIT) ||
- (code == LOG_TCP_OFFLINE_HIT);
-}
+public:
+ LogTags(LogTags_ot t) : oldType(t) {assert(oldType < LOG_TYPE_MAX);}
+ LogTags &operator =(const LogTags_ot &t) {assert(t < LOG_TYPE_MAX); oldType = t; return *this;}
+
+ const char *c_str() const;
+
+ /// determine if the log tag code indicates a cache HIT
+ bool isTcpHit() const;
+
+private:
+ /// list of string representations for LogTags_ot
+ static const char *Str_[];
+
+public: // XXX: only until client_db.cc stats are redesigned.
+
+ // deprecated LogTag enum value
+ LogTags_ot oldType;
+};
-/// iterator for LogTags enumeration
-inline LogTags &operator++ (LogTags &aLogType)
+/// iterator for LogTags_ot enumeration
+inline LogTags_ot &operator++ (LogTags_ot &aLogType)
{
int tmp = (int)aLogType;
- aLogType = (LogTags)(++tmp);
+ aLogType = (LogTags_ot)(++tmp);
return aLogType;
}
}
#endif
void
-clientdbUpdate(const Ip::Address &addr, LogTags ltype, AnyP::ProtocolType p, size_t size)
+clientdbUpdate(const Ip::Address &addr, const LogTags <ype, AnyP::ProtocolType p, size_t size)
{
char key[MAX_IPSTRLEN];
ClientInfo *c;
if (p == AnyP::PROTO_HTTP) {
++ c->Http.n_requests;
- ++ c->Http.result_hist[ltype];
+ ++ c->Http.result_hist[ltype.oldType];
kb_incr(&c->Http.kbytes_out, size);
- if (logTypeIsATcpHit(ltype))
+ if (ltype.isTcpHit())
kb_incr(&c->Http.hit_kbytes_out, size);
} else if (p == AnyP::PROTO_ICP) {
++ c->Icp.n_requests;
- ++ c->Icp.result_hist[ltype];
+ ++ c->Icp.result_hist[ltype.oldType];
kb_incr(&c->Icp.kbytes_out, size);
- if (LOG_UDP_HIT == ltype)
+ if (LOG_UDP_HIT == ltype.oldType)
kb_incr(&c->Icp.hit_kbytes_out, size);
}
storeAppendPrintf(sentry, " ICP Requests %d\n",
c->Icp.n_requests);
- for (LogTags l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
+ for (LogTags_ot l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
if (c->Icp.result_hist[l] == 0)
continue;
if (LOG_UDP_HIT == l)
icp_hits += c->Icp.result_hist[l];
- storeAppendPrintf(sentry, " %-20.20s %7d %3d%%\n",LogTags_str[l], c->Icp.result_hist[l], Math::intPercent(c->Icp.result_hist[l], c->Icp.n_requests));
+ storeAppendPrintf(sentry, " %-20.20s %7d %3d%%\n", LogTags(l).c_str(), c->Icp.result_hist[l], Math::intPercent(c->Icp.result_hist[l], c->Icp.n_requests));
}
storeAppendPrintf(sentry, " HTTP Requests %d\n", c->Http.n_requests);
- for (LogTags l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
+ for (LogTags_ot l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
if (c->Http.result_hist[l] == 0)
continue;
http_total += c->Http.result_hist[l];
- if (logTypeIsATcpHit(l))
+ if (LogTags(l).isTcpHit())
http_hits += c->Http.result_hist[l];
storeAppendPrintf(sentry,
" %-20.20s %7d %3d%%\n",
- LogTags_str[l],
+ LogTags(l).c_str(),
c->Http.result_hist[l],
Math::intPercent(c->Http.result_hist[l], c->Http.n_requests));
}
case MESH_CTBL_HTHITS:
aggr = 0;
- for (LogTags l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
- if (logTypeIsATcpHit(l))
+ for (LogTags_ot l = LOG_TAG_NONE; l < LOG_TYPE_MAX; ++l) {
+ if (LogTags(l).isTcpHit())
aggr += c->Http.result_hist[l];
}
class StoreEntry;
class ClientInfo;
-void clientdbUpdate(const Ip::Address &, LogTags, AnyP::ProtocolType, size_t);
+void clientdbUpdate(const Ip::Address &, const LogTags &, AnyP::ProtocolType, size_t);
int clientdbCutoffDenied(const Ip::Address &);
void clientdbDump(StoreEntry *);
void clientdbFreeMemory(void);
static int clientIsContentLengthValid(HttpRequest * r);
static int clientIsRequestBodyTooLargeForPolicy(int64_t bodyLength);
-static void clientUpdateStatHistCounters(LogTags logType, int svc_time);
-static void clientUpdateStatCounters(LogTags logType);
+static void clientUpdateStatHistCounters(const LogTags &logType, int svc_time);
+static void clientUpdateStatCounters(const LogTags &logType);
static void clientUpdateHierCounters(HierarchyLogEntry *);
static bool clientPingHasFinished(ping_data const *aPing);
void prepareLogWithRequestDetails(HttpRequest *, AccessLogEntry::Pointer &);
static void ClientSocketContextPushDeferredIfNeeded(ClientSocketContext::Pointer deferredRequest, ConnStateData * conn);
-static void clientUpdateSocketStats(LogTags logType, size_t size);
+static void clientUpdateSocketStats(const LogTags &logType, size_t size);
char *skipLeadingSpace(char *aString);
#endif
void
-clientUpdateStatCounters(LogTags logType)
+clientUpdateStatCounters(const LogTags &logType)
{
++statCounter.client_http.requests;
- if (logTypeIsATcpHit(logType))
+ if (logType.isTcpHit())
++statCounter.client_http.hits;
- if (logType == LOG_TCP_HIT)
+ if (logType.oldType == LOG_TCP_HIT)
++statCounter.client_http.disk_hits;
- else if (logType == LOG_TCP_MEM_HIT)
+ else if (logType.oldType == LOG_TCP_MEM_HIT)
++statCounter.client_http.mem_hits;
}
void
-clientUpdateStatHistCounters(LogTags logType, int svc_time)
+clientUpdateStatHistCounters(const LogTags &logType, int svc_time)
{
statCounter.client_http.allSvcTime.count(svc_time);
/**
* (we *tried* to validate it, but failed).
*/
- switch (logType) {
+ switch (logType.oldType) {
case LOG_TCP_REFRESH_UNMODIFIED:
statCounter.client_http.nearHitSvcTime.count(svc_time);
void
ClientHttpRequest::logRequest()
{
- if (!out.size && !logType)
- debugs(33, 5, HERE << "logging half-baked transaction: " << log_uri);
+ if (!out.size && logType.oldType == LOG_TAG_NONE)
+ debugs(33, 5, "logging half-baked transaction: " << log_uri);
al->icp.opcode = ICP_INVALID;
al->url = log_uri;
/* hits only - upstream CachePeer determines correct behaviour on misses, and client_side_reply determines
* hits candidates
*/
- else if (logTypeIsATcpHit(http->logType) && http->request->header.has(HDR_IF_RANGE) && !clientIfRangeMatch(http, rep))
+ else if (http->logType.isTcpHit() && http->request->header.has(HDR_IF_RANGE) && !clientIfRangeMatch(http, rep))
range_err = "If-Range match failed";
else if (!http->request->range->canonize(rep))
range_err = "canonization failed";
else if (http->request->range->isComplex())
range_err = "too complex range header";
- else if (!logTypeIsATcpHit(http->logType) && http->request->range->offsetLimitExceeded(roffLimit))
+ else if (!http->logType.isTcpHit() && http->request->range->offsetLimitExceeded(roffLimit))
range_err = "range outside range_offset_limit";
/* get rid of our range specs on error */
}
void
-clientUpdateSocketStats(LogTags logType, size_t size)
+clientUpdateSocketStats(const LogTags &logType, size_t size)
{
if (size == 0)
return;
kb_incr(&statCounter.client_http.kbytes_out, size);
- if (logTypeIsATcpHit(logType))
+ if (logType.isTcpHit())
kb_incr(&statCounter.client_http.hit_kbytes_out, size);
}
/*
* Got the headers, now grok them
*/
- assert(http->logType == LOG_TCP_HIT);
+ assert(http->logType.oldType == LOG_TCP_HIT);
if (strcmp(e->mem_obj->storeId(), http->request->storeId()) != 0) {
debugs(33, DBG_IMPORTANT, "clientProcessHit: URL mismatch, '" << e->mem_obj->storeId() << "' != '" << http->request->storeId() << "'");
if (http->storeEntry()) {
if (EBIT_TEST(http->storeEntry()->flags, ENTRY_SPECIAL)) {
debugs(88, DBG_CRITICAL, "clientProcessMiss: miss on a special object (" << url << ").");
- debugs(88, DBG_CRITICAL, "\tlog_type = " << LogTags_str[http->logType]);
+ debugs(88, DBG_CRITICAL, "\tlog_type = " << http->logType.c_str());
http->storeEntry()->dump(1);
}
clientReplyContext::buildReplyHeader()
{
HttpHeader *hdr = &reply->header;
- int is_hit = logTypeIsATcpHit(http->logType);
+ const bool is_hit = http->logType.isTcpHit();
HttpRequest *request = http->request;
#if DONT_FILTER_THESE
/* but you might want to if you run Squid as an HTTP accelerator */
}
// add Warnings required by RFC 2616 if serving a stale hit
- if (http->request->flags.staleIfHit && logTypeIsATcpHit(http->logType)) {
+ if (http->request->flags.staleIfHit && http->logType.isTcpHit()) {
hdr->putWarning(110, "Response is stale");
if (http->request->flags.needValidation)
hdr->putWarning(111, "Revalidation failed");
}
/* Filter unproxyable authentication types */
- if (http->logType != LOG_TCP_DENIED &&
+ if (http->logType.oldType != LOG_TCP_DENIED &&
hdr->has(HDR_WWW_AUTHENTICATE)) {
HttpHeaderPos pos = HttpHeaderInitPos;
HttpHeaderEntry *e;
#if USE_AUTH
/* Handle authentication headers */
- if (http->logType == LOG_TCP_DENIED &&
+ if (http->logType.oldType == LOG_TCP_DENIED &&
( reply->sline.status() == Http::scProxyAuthenticationRequired ||
reply->sline.status() == Http::scUnauthorized)
) {
sc->setDelayId(DelayId::DelayClient(http));
#endif
- assert(http->logType == LOG_TCP_HIT);
+ assert(http->logType.oldType == LOG_TCP_HIT);
reqofs = 0;
/* guarantee nothing has been sent yet! */
assert(http->out.size == 0);
assert(reply);
/** Don't block our own responses or HTTP status messages */
- if (http->logType == LOG_TCP_DENIED ||
- http->logType == LOG_TCP_DENIED_REPLY ||
+ if (http->logType.oldType == LOG_TCP_DENIED ||
+ http->logType.oldType == LOG_TCP_DENIED_REPLY ||
alwaysAllowResponse(reply->sline.status())) {
headers_sz = reply->hdr_sz;
processReplyAccessResult(ACCESS_ALLOWED);
memcpy(buf, result.data, result.length);
}
- if (reqofs==0 && !logTypeIsATcpHit(http->logType) && Comm::IsConnOpen(conn->clientConnection)) {
+ if (reqofs==0 && !http->logType.isTcpHit() && Comm::IsConnOpen(conn->clientConnection)) {
if (Ip::Qos::TheConfig.isHitTosActive()) {
Ip::Qos::doTosLocalMiss(conn->clientConnection, http->request->hier.code);
}
/* the ICP check here was erroneous
* - StoreEntry::releaseRequest was always called if entry was valid
*/
- assert(logType < LOG_TYPE_MAX);
logRequest();
{
PROF_start(httpStart);
logType = LOG_TAG_NONE;
- debugs(85, 4, LogTags_str[logType] << " for '" << uri << "'");
+ debugs(85, 4, logType.c_str() << " for '" << uri << "'");
/* no one should have touched this */
assert(out.offset == 0);
case LFT_SQUID_STATUS:
if (al->http.timedout || al->http.aborted) {
- snprintf(tmp, sizeof(tmp), "%s%s", LogTags_str[al->cache.code],
- al->http.statusSfx());
+ snprintf(tmp, sizeof(tmp), "%s%s", al->cache.code.c_str(), al->http.statusSfx());
out = tmp;
} else {
- out = LogTags_str[al->cache.code];
+ out = al->cache.code.c_str();
}
break;
htcpLogHtcp(Ip::Address &caddr, int opcode, LogTags logcode, const char *url)
{
AccessLogEntry::Pointer al = new AccessLogEntry;
- if (LOG_TAG_NONE == logcode)
+ if (LOG_TAG_NONE == logcode.oldType)
return;
if (!Config.onoff.log_udp)
return;
static void icpIncomingConnectionOpened(const Comm::ConnectionPointer &conn, int errNo);
/// \ingroup ServerProtocolICPInternal2
-static void icpLogIcp(const Ip::Address &, LogTags, int, const char *, int);
+static void icpLogIcp(const Ip::Address &, const LogTags &, int, const char *, int);
/// \ingroup ServerProtocolICPInternal2
static void icpHandleIcpV2(int, Ip::Address &, char *, int);
/// \ingroup ServerProtocolICPInternal2
static void
-icpLogIcp(const Ip::Address &caddr, LogTags logcode, int len, const char *url, int delay)
+icpLogIcp(const Ip::Address &caddr, const LogTags &logcode, int len, const char *url, int delay)
{
AccessLogEntry::Pointer al = new AccessLogEntry();
- if (LOG_TAG_NONE == logcode)
+ if (LOG_TAG_NONE == logcode.oldType)
return;
- if (LOG_ICP_QUERY == logcode)
+ if (LOG_ICP_QUERY == logcode.oldType)
return;
clientdbUpdate(caddr, logcode, AnyP::PROTO_ICP, len);
al->http.clientReplySz.messageTotal(),
referer,
agent,
- LogTags_str[al->cache.code],
+ al->cache.code.c_str(),
al->http.statusSfx(),
hier_code_str[al->hier.code],
(Config.onoff.log_mime_hdrs?"":"\n"));
al->http.version.major, al->http.version.minor,
al->http.code,
al->http.clientReplySz.messageTotal(),
- LogTags_str[al->cache.code],
+ al->cache.code.c_str(),
al->http.statusSfx(),
hier_code_str[al->hier.code],
(Config.onoff.log_mime_hdrs?"":"\n"));
(int) current_time.tv_usec / 1000,
tvToMsec(al->cache.trTime),
clientip,
- LogTags_str[al->cache.code],
+ al->cache.code.c_str(),
al->http.statusSfx(),
al->http.code,
al->http.clientReplySz.messageTotal(),
}
storeAppendPrintf(s, "uri %s\n", http->uri);
- storeAppendPrintf(s, "logType %s\n", LogTags_str[http->logType]);
+ storeAppendPrintf(s, "logType %s\n", http->logType.c_str());
storeAppendPrintf(s, "out.offset %ld, out.size %lu\n",
(long int) http->out.offset, (unsigned long int) http->out.size);
storeAppendPrintf(s, "req_sz %ld\n", (long int) http->req_sz);
class ClientInfo;
void clientdbInit(void) STUB
-void clientdbUpdate(const Ip::Address &, LogTags, AnyP::ProtocolType, size_t) STUB
+void clientdbUpdate(const Ip::Address &, const LogTags &, AnyP::ProtocolType, size_t) STUB
int clientdbCutoffDenied(const Ip::Address &) STUB_RETVAL(-1)
void clientdbDump(StoreEntry *) STUB
void clientdbFreeMemory(void) STUB