From 6225b1240ca3cec74d39005ebdd1e9d9aad3334b Mon Sep 17 00:00:00 2001 From: Jeff Elsloo Date: Thu, 21 Jul 2022 08:30:59 -0600 Subject: [PATCH] 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 1c42f20fcf8..0882c2baf39 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;