]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Shuffle _TIMEOUT and _ABORTED flags into class LogTags
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 12 Jul 2015 10:04:45 +0000 (03:04 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 12 Jul 2015 10:04:45 +0000 (03:04 -0700)
src/AccessLogEntry.h
src/LogTags.cc
src/LogTags.h
src/client_side.cc
src/format/Format.cc
src/log/FormatHttpdCombined.cc
src/log/FormatHttpdCommon.cc
src/log/FormatSquidNative.cc

index 30f45f1fb7040f7d37e6e2d106936a4c11c7819a..f9dbd917cdd8098c563a3d08c59eb503ad6bfb4c 100644 (file)
@@ -67,8 +67,6 @@ public:
             method(Http::METHOD_NONE),
             code(0),
             content_type(NULL),
-            timedout(false),
-            aborted(false),
             clientRequestSz(),
             clientReplySz() {}
 
@@ -76,13 +74,6 @@ public:
         int code;
         const char *content_type;
         AnyP::ProtocolVersion version;
-        bool timedout; ///< terminated due to a lifetime or I/O timeout
-        bool aborted; ///< other abnormal termination (e.g., I/O error)
-
-        /// compute suffix for the status access.log field
-        const char *statusSfx() const {
-            return timedout ? "_TIMEDOUT" : (aborted ? "_ABORTED" : "");
-        }
 
         /// counters for the original request received from client
         // TODO calculate header and payload better (by parser)
index 1a3e5f56c857ed4720c4f90392f7c97e5758b4ca..8f4d30eb60076b3e64d5918619d80bc0d115e398 100644 (file)
@@ -37,10 +37,30 @@ const char * LogTags::Str_[] = {
        "TYPE_MAX"
 };
 
+/*
+ * This method is documented in http://wiki.squid-cache.org/SquidFaq/SquidLogs#Squid_result_codes
+ * Please keep the wiki up to date
+ */
 const char *
 LogTags::c_str() const
 {
-    return Str_[oldType];
+    static char buf[1024];
+    *buf = 0;
+    int pos = 0;
+
+    // source tags
+    if (oldType && oldType < LOG_TYPE_MAX)
+        pos += snprintf(buf, sizeof(buf), "%s",Str_[oldType]);
+    else
+        pos += snprintf(buf, sizeof(buf), "NONE");
+
+    // error tags
+    if (err.timedout)
+        pos += snprintf(buf+pos,sizeof(buf)-pos, "_TIMEDOUT");
+    if (err.aborted)
+        pos += snprintf(buf+pos,sizeof(buf)-pos, "_ABORTED");
+
+    return buf;
 }
 
 bool
index bc50befbcaef198c8d216a4e7c7616665e0e8bc1..788cf830ab33313b01e6ed5d1c761312cd8533e7 100644 (file)
@@ -50,11 +50,20 @@ 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;}
 
+    /// compute the status access.log field
     const char *c_str() const;
 
     /// determine if the log tag code indicates a cache HIT
     bool isTcpHit() const;
 
+    /// error states terminating the transaction
+    struct Errors {
+        Errors() : timedout(false), aborted(false) {}
+
+        bool timedout; ///< tag: TIMEDOUT - terminated due to a lifetime or I/O timeout
+        bool aborted;  ///< tag: ABORTED  - other abnormal termination (e.g., I/O error)
+    } err;
+
 private:
     /// list of string representations for LogTags_ot
     static const char *Str_[];
index 9fe2f14ca3c6f24edab94dbd97edc99a4329429d..eb3c12c85d8e789df62eb44fcd21385759b0bb7c 100644 (file)
@@ -1771,10 +1771,9 @@ void
 ClientSocketContext::noteIoError(const int xerrno)
 {
     if (http) {
-        if (xerrno == ETIMEDOUT)
-            http->al->http.timedout = true;
-        else // even if xerrno is zero (which means read abort/eof)
-            http->al->http.aborted = true;
+        http->logType.err.timedout = (xerrno == ETIMEDOUT);
+        // aborted even if xerrno is zero (which means read abort/eof)
+        http->logType.err.aborted = (xerrno != ETIMEDOUT);
     }
 }
 
@@ -3361,7 +3360,7 @@ clientLifetimeTimeout(const CommTimeoutCbParams &io)
     ClientHttpRequest *http = static_cast<ClientHttpRequest *>(io.data);
     debugs(33, DBG_IMPORTANT, "WARNING: Closing client connection due to lifetime timeout");
     debugs(33, DBG_IMPORTANT, "\t" << http->uri);
-    http->al->http.timedout = true;
+    http->logType.err.timedout = true;
     if (Comm::IsConnOpen(io.conn))
         io.conn->close();
 }
index 7273cb3e5c8330d07194524cc5275028574ed9f2..ca5fd9e5957e12dc56a0e31fb5aedff7adcf0d3d 100644 (file)
@@ -877,13 +877,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS
             break;
 
         case LFT_SQUID_STATUS:
-            if (al->http.timedout || al->http.aborted) {
-                snprintf(tmp, sizeof(tmp), "%s%s", al->cache.code.c_str(), al->http.statusSfx());
-                out = tmp;
-            } else {
-                out = al->cache.code.c_str();
-            }
-
+            out = al->cache.code.c_str();
             break;
 
         case LFT_SQUID_ERROR:
index d57382b2e529d90afab23dbed7698066daa05a62..03b4607a26085cd92280e51fdfa120174dfcdf48 100644 (file)
@@ -51,7 +51,7 @@ Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile)
     else
         method = al->http.method.image();
 
-    logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s%s:%s%s",
+    logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s:%s%s",
                   clientip,
                   user_ident ? user_ident : dash_str,
                   user_auth ? user_auth : dash_str,
@@ -65,7 +65,6 @@ Log::Format::HttpdCombined(const AccessLogEntry::Pointer &al, Logfile * logfile)
                   referer,
                   agent,
                   al->cache.code.c_str(),
-                  al->http.statusSfx(),
                   hier_code_str[al->hier.code],
                   (Config.onoff.log_mime_hdrs?"":"\n"));
 
index bddb71fc6ae26277046f5ca6ba34aeaf1ef28430..3421d03b1e171f9db95bbd498e0e102d7e35dd93 100644 (file)
@@ -38,7 +38,7 @@ Log::Format::HttpdCommon(const AccessLogEntry::Pointer &al, Logfile * logfile)
     else
         method = al->http.method.image();
 
-    logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " %s%s:%s%s",
+    logfilePrintf(logfile, "%s %s %s [%s] \"" SQUIDSBUFPH " %s %s/%d.%d\" %d %" PRId64 " %s:%s%s",
                   clientip,
                   user_ident ? user_ident : dash_str,
                   user_auth ? user_auth : dash_str,
@@ -50,7 +50,6 @@ Log::Format::HttpdCommon(const AccessLogEntry::Pointer &al, Logfile * logfile)
                   al->http.code,
                   al->http.clientReplySz.messageTotal(),
                   al->cache.code.c_str(),
-                  al->http.statusSfx(),
                   hier_code_str[al->hier.code],
                   (Config.onoff.log_mime_hdrs?"":"\n"));
 
index e22164312086dab10de1d2e89e5ef58876ddb147..59ccc6edb59a9d6907e3faf915630509284e7bfb 100644 (file)
@@ -54,13 +54,12 @@ Log::Format::SquidNative(const AccessLogEntry::Pointer &al, Logfile * logfile)
     else
         method = al->http.method.image();
 
-    logfilePrintf(logfile, "%9ld.%03d %6ld %s %s%s/%03d %" PRId64 " " SQUIDSBUFPH " %s %s %s%s/%s %s%s",
+    logfilePrintf(logfile, "%9ld.%03d %6ld %s %s/%03d %" PRId64 " " SQUIDSBUFPH " %s %s %s%s/%s %s%s",
                   (long int) current_time.tv_sec,
                   (int) current_time.tv_usec / 1000,
                   tvToMsec(al->cache.trTime),
                   clientip,
                   al->cache.code.c_str(),
-                  al->http.statusSfx(),
                   al->http.code,
                   al->http.clientReplySz.messageTotal(),
                   SQUIDSBUFPRINT(method),