diff options
author | Aaron Brashears <aaronb@lindenlab.com> | 2009-05-18 23:38:35 +0000 |
---|---|---|
committer | Aaron Brashears <aaronb@lindenlab.com> | 2009-05-18 23:38:35 +0000 |
commit | 6df2755ba6b24d0cefd52ce175b0212dd46c9b10 (patch) | |
tree | 833bc29e7bd5438eb89f34119ae157efe6258b2c /indra/llcommon/lllivefile.cpp | |
parent | 0257214763203708e8e29d09346e777b95cdfce6 (diff) |
Result of svn merge -r119432:120464 svn+ssh://svn/svn/linden/branches/http_database/merge-03 into trunk. QAR-1462
Diffstat (limited to 'indra/llcommon/lllivefile.cpp')
-rw-r--r-- | indra/llcommon/lllivefile.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp index b6f458cb3e..effda6c49c 100644 --- a/indra/llcommon/lllivefile.cpp +++ b/indra/llcommon/lllivefile.cpp @@ -35,14 +35,17 @@ #include "llframetimer.h" #include "lltimer.h" +const F32 DEFAULT_CONFIG_FILE_REFRESH = 5.0f; + + class LLLiveFile::Impl { public: - Impl(const std::string &filename, const F32 refresh_period); + Impl(const std::string& filename, const F32 refresh_period); ~Impl(); bool check(); - + void changed(); bool mForceCheck; F32 mRefreshPeriod; @@ -50,16 +53,19 @@ public: std::string mFilename; time_t mLastModTime; + time_t mLastStatTime; bool mLastExists; LLEventTimer* mEventTimer; }; -LLLiveFile::Impl::Impl(const std::string &filename, const F32 refresh_period) - : mForceCheck(true), +LLLiveFile::Impl::Impl(const std::string& filename, const F32 refresh_period) + : + mForceCheck(true), mRefreshPeriod(refresh_period), mFilename(filename), mLastModTime(0), + mLastStatTime(0), mLastExists(false), mEventTimer(NULL) { @@ -70,7 +76,7 @@ LLLiveFile::Impl::~Impl() delete mEventTimer; } -LLLiveFile::LLLiveFile(const std::string &filename, const F32 refresh_period) +LLLiveFile::LLLiveFile(const std::string& filename, const F32 refresh_period) : impl(* new Impl(filename, refresh_period)) { } @@ -121,17 +127,30 @@ bool LLLiveFile::Impl::check() // We want to read the file. Update status info for the file. mLastExists = true; - mLastModTime = stat_data.st_mtime; - + mLastStatTime = stat_data.st_mtime; return true; } +void LLLiveFile::Impl::changed() +{ + // we wanted to read this file, and we were successful. + mLastModTime = mLastStatTime; +} + bool LLLiveFile::checkAndReload() { bool changed = impl.check(); if (changed) { - loadFile(); + if(loadFile()) + { + impl.changed(); + this->changed(); + } + else + { + changed = false; + } } return changed; } |