summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/cgi/cgiStagePresent.cpp2
-rw-r--r--project2/common/presenterCache.h2
-rw-r--r--project2/common/scripts.h1
-rw-r--r--project2/files/presenterCache.cpp4
-rw-r--r--project2/xml/xmlScriptParser.cpp8
-rw-r--r--project2/xml/xmlScriptParser.h1
6 files changed, 14 insertions, 4 deletions
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index 9574e84..b6bb11e 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -23,7 +23,7 @@ CgiApplicationEngine::PresentStage::run()
runChecks();
PresenterCaches backFill;
BOOST_FOREACH(const PresenterCachePtr & pc, caches) {
- if (pc->check()) {
+ if (pc->check(root->script->modifiedTime())) {
CacheHitStage * chs = new CacheHitStage(root, pc);
chs->caches = backFill;
return NextStage(NULL, chs, pc, NULL);
diff --git a/project2/common/presenterCache.h b/project2/common/presenterCache.h
index 85aafab..63ff9f0 100644
--- a/project2/common/presenterCache.h
+++ b/project2/common/presenterCache.h
@@ -8,7 +8,7 @@
class PresenterCache : public SourceObject, public virtual TransformSource, public IHaveParameters {
public:
PresenterCache(ScriptNodePtr);
- virtual bool check() const = 0;
+ virtual bool check(time_t scriptMtime) const = 0;
virtual std::ostream & writeCache(const std::string & ct, const std::string & encoding) = 0;
virtual void flushCache();
diff --git a/project2/common/scripts.h b/project2/common/scripts.h
index ba5a8e9..0f1a1a6 100644
--- a/project2/common/scripts.h
+++ b/project2/common/scripts.h
@@ -53,6 +53,7 @@ class ScriptReader : public virtual IntrusivePtrBase {
virtual ScriptNodePtr root() const = 0;
virtual void load(const CommonObjects *, bool childrenOnly) const;
virtual bool isCurrent() const = 0;
+ virtual time_t modifiedTime() const = 0;
mutable LoaderBase loader;
};
diff --git a/project2/files/presenterCache.cpp b/project2/files/presenterCache.cpp
index e203fc4..9505496 100644
--- a/project2/files/presenterCache.cpp
+++ b/project2/files/presenterCache.cpp
@@ -41,7 +41,7 @@ class FilePresenterCache : public PresenterCache, public StaticContent, public S
}
delete writecache;
}
- bool check() const
+ bool check(time_t scriptMtime) const
{
try {
if (readcachefd == 0) {
@@ -54,7 +54,7 @@ class FilePresenterCache : public PresenterCache, public StaticContent, public S
readcachefd = 0;
readcachefd = safesys<OpenCacheFile>(-1, open(getCacheFile().string().c_str(), O_RDONLY));
}
- if (st.st_mtime < time(NULL) - FilePresenterCache::CacheLife) {
+ if ((st.st_mtime < (time(NULL) - FilePresenterCache::CacheLife)) || (st.st_mtime < scriptMtime)) {
unlink(getCacheFile().string().c_str());
close(readcachefd);
readcachefd = 0;
diff --git a/project2/xml/xmlScriptParser.cpp b/project2/xml/xmlScriptParser.cpp
index f65e7d5..ece6701 100644
--- a/project2/xml/xmlScriptParser.cpp
+++ b/project2/xml/xmlScriptParser.cpp
@@ -64,6 +64,14 @@ XmlScriptParser::load(const CommonObjects * co, bool childrenOnly) const
ScriptReader::load(co, childrenOnly);
}
+time_t
+XmlScriptParser::modifiedTime() const
+{
+ return std::max_element(files.begin(), files.end(), [](const Files::value_type & a, const Files::value_type & b) {
+ return a.second < b.second;
+ } )->second;
+}
+
bool
XmlScriptParser::isCurrent() const
{
diff --git a/project2/xml/xmlScriptParser.h b/project2/xml/xmlScriptParser.h
index 0ea2a37..0f391a1 100644
--- a/project2/xml/xmlScriptParser.h
+++ b/project2/xml/xmlScriptParser.h
@@ -42,6 +42,7 @@ class XmlScriptParser : public xmlpp::DomParser, public ScriptReader {
ScriptNodePtr root() const;
void load(const CommonObjects *, bool childrenOnly) const;
bool isCurrent() const;
+ time_t modifiedTime() const;
private:
mutable ScriptNodePtr _root;
void doIncludes(xmlpp::Element * e, const boost::filesystem::path & f);