You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2022/07/26 22:31:28 UTC

[trafficserver] branch 9.2.x updated: Fixes issue with file size calculation for existing logs (#8971)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.2.x by this push:
     new eedf85395 Fixes issue with file size calculation for existing logs (#8971)
eedf85395 is described below

commit eedf8539524ed5b285f89bf190280cd62c517649
Author: Jeff Elsloo <el...@users.noreply.github.com>
AuthorDate: Thu Jul 21 08:30:59 2022 -0600

    Fixes issue with file size calculation for existing logs (#8971)
    
    * Issue arises with existing log files at startup
    
    * Because the existing bytes are not accounted for, log rolling does not occur at the correct time
    
    * Existing code can lead to logging being suspended indefinitely without manual intervention if thresholds are exceeded and no rolled log files can be deleted
    
    * Corner case more evident when other data not rolled by ATS is present in the logging directory
    
    (cherry picked from commit 6225b1240ca3cec74d39005ebdd1e9d9aad3334b)
---
 src/tscore/BaseLogFile.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/tscore/BaseLogFile.cc b/src/tscore/BaseLogFile.cc
index 1c42f20fc..0882c2baf 100644
--- a/src/tscore/BaseLogFile.cc
+++ b/src/tscore/BaseLogFile.cc
@@ -333,7 +333,8 @@ BaseLogFile::open_file(int perm)
   }
 
   // set m_bytes_written to force the rolling based on file size.
-  m_bytes_written = fseek(m_fp, 0, SEEK_CUR);
+  fseek(m_fp, 0, SEEK_END);
+  m_bytes_written = ftell(m_fp);
 
   log_log_trace("BaseLogFile %s is now open (fd=%d)\n", m_name.get(), fileno(m_fp));
   m_is_init = true;