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

elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


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

commit 6225b1240ca3cec74d39005ebdd1e9d9aad3334b
Author: Jeff Elsloo <[email protected]>
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
---
 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;

Reply via email to