trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject [trafficserver] 04/07: Review comments.
Date Tue, 10 Dec 2019 23:02:30 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit bd73be1a1b0f525706219298bc74ef26efbbc03a
Author: bneradt <bneradt@verizonmedia.com>
AuthorDate: Wed Nov 20 15:48:46 2019 +0000

    Review comments.
    
    (cherry picked from commit 745d38f63441f0a6eec64cc81a29f39b9333b8fe)
---
 proxy/logging/LogConfig.cc |  5 ++---
 proxy/logging/LogUtils.cc  | 35 ++++++++++++++---------------------
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index efc6011..816206d 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -616,9 +616,8 @@ LogConfig::update_space_used()
         //
         // then check if the candidate belongs to any given log type
         //
-        ts::TextView rolled_filename(entry->d_name, strlen(entry->d_name));
-        auto type_name = LogUtils::get_unrolled_filename(rolled_filename);
-        auto iter      = deleting_info.find(type_name);
+        std::string_view rolled_filename(entry->d_name, strlen(entry->d_name));
+        auto iter = deleting_info.find(LogUtils::get_unrolled_filename(rolled_filename));
         if (iter == deleting_info.end()) {
           // We won't delete the log if its name doesn't match any give type.
           continue;
diff --git a/proxy/logging/LogUtils.cc b/proxy/logging/LogUtils.cc
index 2a314d7..4ec68e9 100644
--- a/proxy/logging/LogUtils.cc
+++ b/proxy/logging/LogUtils.cc
@@ -489,28 +489,21 @@ LogUtils::get_unrolled_filename(ts::TextView rolled_filename)
 
   suffix.remove_prefix_at('.');
   // Using the above squid.log example, suffix now looks like:
-  //   log_some.hostname.com.20191029.18h15m02s-20191029.18h30m02s.ol
-
-  if (suffix.find('_') != std::string::npos) {
-    suffix.remove_prefix_at('_');
-    // suffix now looks like:
-    //   some.hostname.com.20191029.18h15m02s-20191029.18h30m02s.ol
-  } else if (suffix.find('.') != std::string::npos) {
-    // There was no underscore in the file after the first '.'.
-    // Some logs have the following format (without the hostname):
-    // diags.log.20191114.21h43m16s-20191114.21h43m17s.old
-
-    suffix.remove_prefix_at('.');
-    // Using the diags.log from our above example, suffix now looks like:
-    //   log.20191114.21h43m16s-20191114.21h43m17s.old
-  } else {
-    // If there isn't a '.' or an '_' after the first '.', then this
-    // doesn't look like a rolled file.
-    return rolled_filename;
-  }
+  //   log_some.hostname.com.20191029.18h15m02s-20191029.18h30m02s.old
 
-  // ' + 1' to remove the '_' or second '.':
-  return unrolled_name.remove_suffix(suffix.size() + 1);
+  // Some suffixes do not have the hostname.  Rolled diags.log files will look
+  // something like this, for example:
+  //   diags.log.20191114.21h43m16s-20191114.21h43m17s.old
+  //
+  // For these, the second delimeter will be a period. For this reason, we also
+  // split_prefix_at with a period as well.
+  if (suffix.split_prefix_at('_') || suffix.split_prefix_at('.')) {
+    // ' + 1' to remove the '_' or second '.':
+    return unrolled_name.remove_suffix(suffix.size() + 1);
+  }
+  // If there isn't a '.' or an '_' after the first '.', then this
+  // doesn't look like a rolled file.
+  return rolled_filename;
 }
 
 // Checks if the file pointed to by full_filename either is a regular


Mime
View raw message