trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject [trafficserver] branch 8.0.x updated: Add validation of fields in logfile for traffic_logstats
Date Mon, 25 Jun 2018 16:03:04 GMT
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
     new d5b645e  Add validation of fields in logfile for traffic_logstats
d5b645e is described below

commit d5b645e81d737187c4af1bb715ad4297c66d10bd
Author: Bryan Call <bcall@apache.org>
AuthorDate: Thu Jun 21 16:55:33 2018 -0700

    Add validation of fields in logfile for traffic_logstats
    
    (cherry picked from commit ce30c2140b0583ff40a22bca73be66d17c32ad1a)
---
 src/traffic_logstats/logstats.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/traffic_logstats/logstats.cc b/src/traffic_logstats/logstats.cc
index 9786c09..76bacdf 100644
--- a/src/traffic_logstats/logstats.cc
+++ b/src/traffic_logstats/logstats.cc
@@ -56,6 +56,7 @@
 #include <fcntl.h>
 #include <unordered_map>
 #include <unordered_set>
+#include <string_view>
 
 #ifndef _XOPEN_SOURCE
 #define _XOPEN_SOURCE 600
@@ -1253,7 +1254,7 @@ parse_log_buff(LogBufferHeader *buf_header, bool summary = false, bool
aggregate
 
   LogEntryHeader *entry;
   LogBufferIterator buf_iter(buf_header);
-  LogField *field;
+  LogField *field = nullptr;
   ParseStates state;
 
   char *read_from;
@@ -1275,6 +1276,18 @@ parse_log_buff(LogBufferHeader *buf_header, bool summary = false, bool
aggregate
     bool agg = false;
     LogFormat::parse_symbol_string(buf_header->fmt_fieldlist(), fieldlist, &agg);
   }
+
+  // Validate the fieldlist
+  field                                = fieldlist->first();
+  const std::string_view test_fields[] = {"cqtq", "ttms", "chi", "crc", "pssc", "psql", "cqhm",
"cquc", "caun", "phr", "pqsn"};
+  for (auto i : test_fields) {
+    if (i != field->symbol()) {
+      cerr << "Error parsing log file - expected field: " << i << ", but
read field: " << field->symbol() << endl;
+      return 1;
+    }
+    field = fieldlist->next(field);
+  }
+
   // Loop over all entries
   while ((entry = buf_iter.next())) {
     read_from = (char *)entry + sizeof(LogEntryHeader);


Mime
View raw message