From: Amos Jeffries Date: Mon, 11 Nov 2013 12:09:44 +0000 (-0700) Subject: Update class MessageCounters to MessageSizes X-Git-Tag: SQUID_3_5_0_1~522 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc0ca3b912b649072d19b7c1518cfb556ab216ee;p=thirdparty%2Fsquid.git Update class MessageCounters to MessageSizes Also, renaming polish after audit feedback. --- diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index 44008a54c1..2263198cd7 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -40,7 +40,7 @@ #include "icp_opcode.h" #include "ip/Address.h" #include "LogTags.h" -#include "MessageCounters.h" +#include "MessageSizes.h" #include "Notes.h" #if ICAP_CLIENT #include "adaptation/icap/Elements.h" @@ -87,7 +87,8 @@ public: HttpDetails() : method(Http::METHOD_NONE), code(0), content_type(NULL), timedout(false), aborted(false), - clientRequest() {} + clientRequestSz(), + clientReplySz() {} HttpRequestMethod method; int code; @@ -104,12 +105,12 @@ public: /// counters for the original request received from client // TODO calculate header and payload better (by parser) // XXX payload encoding overheads not calculated at all yet. - MessageCounters clientRequest; + MessageSizes clientRequestSz; /// counters for the response sent to client // TODO calculate header and payload better (by parser) // XXX payload encoding overheads not calculated at all yet. - MessageCounters adaptedReply; + MessageSizes clientReplySz; } http; diff --git a/src/Makefile.am b/src/Makefile.am index 15ab4098c3..bc66e7e57c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -442,7 +442,7 @@ squid_SOURCES = \ MemBuf.cc \ MemObject.cc \ MemObject.h \ - MessageCounters.h \ + MessageSizes.h \ mime.h \ mime.cc \ mime_header.h \ diff --git a/src/MessageCounters.h b/src/MessageCounters.h deleted file mode 100644 index b1b86efd35..0000000000 --- a/src/MessageCounters.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SQUID_SRC_MESSAGECOUNTERS_H -#define SQUID_SRC_MESSAGECOUNTERS_H - -/** - * Counters used to collate the traffic size measurements - * for a transaction message. - */ -class MessageCounters -{ -public: - MessageCounters() : headerSz(0), payloadDataSz(0), payloadTeSz(0) {} - - /// size of message header block (if any) - uint64_t headerSz; - - /// total size of payload block(s) excluding transfer encoding overheads - uint64_t payloadDataSz; - - /// total size of extra bytes added by transfer encoding - uint64_t payloadTeSz; - - // total message size - uint64_t total() const {return headerSz + payloadDataSz + payloadTeSz;} - - /// total payload size including transfer encoding overheads - uint64_t payloadTotal() const {return payloadDataSz + payloadTeSz;} -}; - -#endif /* SQUID_SRC_MESSAGECOUNTERS_H */ diff --git a/src/MessageSizes.h b/src/MessageSizes.h new file mode 100644 index 0000000000..69220c4aaf --- /dev/null +++ b/src/MessageSizes.h @@ -0,0 +1,24 @@ +#ifndef SQUID_SRC_MESSAGESIZES_H +#define SQUID_SRC_MESSAGESIZES_H + +/** + * Counters used to collate the traffic size measurements + * for a transaction message. + */ +class MessageSizes +{ +public: + MessageSizes() : header(0), payloadData(0) {} + + /// size of message header block (if any) + /// including message Request-Line or Start-Line. + uint64_t header; + + /// total size of payload block(s) excluding transfer encoding overheads + uint64_t payloadData; + + /// total message size + uint64_t messageTotal() const {return header + payloadData;} +}; + +#endif /* SQUID_SRC_MESSAGESIZES_H */ diff --git a/src/adaptation/icap/ModXact.cc b/src/adaptation/icap/ModXact.cc index fc038df289..20a85b5f2c 100644 --- a/src/adaptation/icap/ModXact.cc +++ b/src/adaptation/icap/ModXact.cc @@ -1290,7 +1290,7 @@ void Adaptation::Icap::ModXact::finalizeLogInfo() #endif al.cache.code = h->logType; // XXX: should use icap-specific counters instead ? - al.http.clientRequest.payloadDataSz = h->req_sz; + al.http.clientRequestSz.payloadData = h->req_sz; // leave al.icap.bodyBytesRead negative if no body if (replyHttpHeaderSize >= 0 || replyHttpBodySize >= 0) { @@ -1304,8 +1304,8 @@ void Adaptation::Icap::ModXact::finalizeLogInfo() al.http.content_type = reply_->content_type.termedBuf(); if (replyHttpBodySize >= 0) { // XXX: should use icap-specific counters instead ? - al.http.adaptedReply.payloadDataSz = replyHttpBodySize; - al.http.adaptedReply.headerSz = reply_->hdr_sz; + al.http.clientReplySz.payloadData = replyHttpBodySize; + al.http.clientReplySz.header = reply_->hdr_sz; al.cache.highOffset = replyHttpBodySize; } //don't set al.cache.objectSize because it hasn't exist yet diff --git a/src/client_side.cc b/src/client_side.cc index cdd086dd14..7edf6c199e 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -597,7 +597,7 @@ prepareLogWithRequestDetails(HttpRequest * request, AccessLogEntry::Pointer &aLo aLogEntry->http.version = request->http_ver; aLogEntry->hier = request->hier; if (request->content_length > 0) // negative when no body or unknown length - aLogEntry->http.clientRequest.payloadDataSz += request->content_length; // XXX: actually adaptedRequest payload size ?? + aLogEntry->http.clientRequestSz.payloadData += request->content_length; // XXX: actually adaptedRequest payload size ?? aLogEntry->cache.extuser = request->extacl_user.termedBuf(); // Adapted request, if any, inherits and then collects all the stats, but @@ -640,10 +640,10 @@ ClientHttpRequest::logRequest() al->cache.port = cbdataReference(getConn()->port); } - al->http.clientRequest.headerSz = req_sz; - al->http.adaptedReply.headerSz = out.headers_sz; + al->http.clientRequestSz.header = req_sz; + al->http.clientReplySz.header = out.headers_sz; // XXX: calculate without payload encoding or headers !! - al->http.adaptedReply.payloadDataSz = out.size - out.headers_sz; // pretend its all un-encoded data for now. + al->http.clientReplySz.payloadData = out.size - out.headers_sz; // pretend its all un-encoded data for now. al->cache.highOffset = out.offset; diff --git a/src/format/Format.cc b/src/format/Format.cc index 25a7b1b7a9..70c79aa62c 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -983,12 +983,12 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS break; case LFT_CLIENT_REQUEST_SIZE_TOTAL: - outoff = al->http.clientRequest.total(); + outoff = al->http.clientRequestSz.messageTotal(); dooff = 1; break; case LFT_CLIENT_REQUEST_SIZE_HEADERS: - outoff = al->http.clientRequest.headerSz; + outoff = al->http.clientRequestSz.header; dooff =1; break; @@ -996,7 +996,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS /*case LFT_REQUEST_SIZE_BODY_NO_TE: */ case LFT_ADAPTED_REPLY_SIZE_TOTAL: - outoff = al->http.adaptedReply.total(); + outoff = al->http.clientReplySz.messageTotal(); dooff = 1; break; @@ -1015,7 +1015,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS break; case LFT_ADAPTED_REPLY_SIZE_HEADERS: - outint = al->http.adaptedReply.headerSz; + outint = al->http.clientReplySz.header; doint = 1; break; @@ -1023,7 +1023,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS /*case LFT_REPLY_SIZE_BODY_NO_TE: */ case LFT_CLIENT_IO_SIZE_TOTAL: - outint = al->http.clientRequest.total() + al->http.adaptedReply.total(); + outint = al->http.clientRequestSz.messageTotal() + al->http.clientReplySz.messageTotal(); doint = 1; break; /*case LFT_SERVER_IO_SIZE_TOTAL: */ diff --git a/src/icp_v2.cc b/src/icp_v2.cc index edd0934c5e..6f1317d573 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -223,7 +223,7 @@ icpLogIcp(const Ip::Address &caddr, LogTags logcode, int len, const char *url, i al->cache.caddr = caddr; // XXX: move to use icp.clientReply instead - al->http.adaptedReply.payloadDataSz = len; + al->http.clientReplySz.payloadData = len; al->cache.code = logcode; diff --git a/src/log/FormatHttpdCombined.cc b/src/log/FormatHttpdCombined.cc index efb1a5e344..4c19d3e3ec 100644 --- a/src/log/FormatHttpdCombined.cc +++ b/src/log/FormatHttpdCombined.cc @@ -77,7 +77,7 @@ Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile) AnyP::ProtocolType_str[al->http.version.protocol], al->http.version.major, al->http.version.minor, al->http.code, - al->http.adaptedReply.total(), + al->http.clientReplySz.messageTotal(), referer, agent, LogTags_str[al->cache.code], diff --git a/src/log/FormatHttpdCommon.cc b/src/log/FormatHttpdCommon.cc index 590882f5a6..401d46ec1e 100644 --- a/src/log/FormatHttpdCommon.cc +++ b/src/log/FormatHttpdCommon.cc @@ -64,7 +64,7 @@ Log::Format::HttpdCommon(const AccessLogEntry::Pointer &al, Logfile * logfile) AnyP::ProtocolType_str[al->http.version.protocol], al->http.version.major, al->http.version.minor, al->http.code, - al->http.adaptedReply.total(), + al->http.clientReplySz.messageTotal(), LogTags_str[al->cache.code], al->http.statusSfx(), hier_code_str[al->hier.code], diff --git a/src/log/FormatSquidNative.cc b/src/log/FormatSquidNative.cc index e10a84f866..6cc0dbaf52 100644 --- a/src/log/FormatSquidNative.cc +++ b/src/log/FormatSquidNative.cc @@ -78,7 +78,7 @@ Log::Format::SquidNative(const AccessLogEntry::Pointer &al, Logfile * logfile) LogTags_str[al->cache.code], al->http.statusSfx(), al->http.code, - al->http.adaptedReply.total(), + al->http.clientReplySz.messageTotal(), al->_private.method_str, al->url, user ? user : dash_str,