diff options
author | unknown <dli@dev3-76.dev.cn.tlan> | 2006-09-01 15:32:40 +0800 |
---|---|---|
committer | unknown <dli@dev3-76.dev.cn.tlan> | 2006-09-01 15:32:40 +0800 |
commit | efeafb2536b7d0df4d2cd886fa5540e34292da38 (patch) | |
tree | c35e0950bc0a18b9c49a70c52c8d40e85b718b3f /ndb | |
parent | bfdbb780c26aae2705cf0d7e3048b5c0e40f59e1 (diff) | |
download | mariadb-git-efeafb2536b7d0df4d2cd886fa5540e34292da38.tar.gz |
Fix for BUG#21345, Error in cluster logfile rotation.
Fixed the cluster logfile rotation code, let the cluster logfile be renamed correctly when the main logfile exceeds the configured maximum size.
ndb/include/util/File.hpp:
Fix for BUG#21345, Error in cluster logfile rotation.
ndb/src/common/logger/FileLogHandler.cpp:
Fix for BUG#21345, Error in cluster logfile rotation.
ndb/src/common/util/File.cpp:
Fix for BUG#21345, Error in cluster logfile rotation.
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/include/util/File.hpp | 8 | ||||
-rw-r--r-- | ndb/src/common/logger/FileLogHandler.cpp | 11 | ||||
-rw-r--r-- | ndb/src/common/util/File.cpp | 12 |
3 files changed, 30 insertions, 1 deletions
diff --git a/ndb/include/util/File.hpp b/ndb/include/util/File.hpp index 3ed0ad7a6f9..52b00f575f4 100644 --- a/ndb/include/util/File.hpp +++ b/ndb/include/util/File.hpp @@ -29,6 +29,14 @@ class File_class { public: /** + * Returns time for last contents modification of a file. + * + * @param aFileName a filename to check. + * @return the time for last contents modificaton of the file. + */ + static time_t mtime(const char* aFileName); + + /** * Returns true if the file exist. * * @param aFileName a filename to check. diff --git a/ndb/src/common/logger/FileLogHandler.cpp b/ndb/src/common/logger/FileLogHandler.cpp index 3d29e63ac1f..b8859630406 100644 --- a/ndb/src/common/logger/FileLogHandler.cpp +++ b/ndb/src/common/logger/FileLogHandler.cpp @@ -147,6 +147,7 @@ FileLogHandler::createNewFile() bool rc = true; int fileNo = 1; char newName[PATH_MAX]; + time_t newMtime, preMtime = 0; do { @@ -159,7 +160,15 @@ FileLogHandler::createNewFile() } BaseString::snprintf(newName, sizeof(newName), "%s.%d", m_pLogFile->getName(), fileNo++); - + newMtime = File_class::mtime(newName); + if (newMtime < preMtime) + { + break; + } + else + { + preMtime = newMtime; + } } while (File_class::exists(newName)); m_pLogFile->close(); diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index e514ad8e122..12626f29e7d 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -24,6 +24,18 @@ // // PUBLIC // +time_t +File_class::mtime(const char* aFileName) +{ + MY_STAT stmp; + time_t rc = 0; + + if (my_stat(aFileName, &stmp, MYF(0)) != NULL) { + rc = stmp.st_mtime; + } + + return rc; +} bool File_class::exists(const char* aFileName) |