summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2012-07-18 01:10:22 +0000
committerrandomdan <randomdan@localhost>2012-07-18 01:10:22 +0000
commit1bd5a61d9cab284359bec4de4a9040a86869c97a (patch)
tree7cebf549c49f0df09b9de509a6bf6a8d05646c5d
parentMigrate all stuff to stricter compilations/links and C++0x builds (diff)
downloadproject2-1bd5a61d9cab284359bec4de4a9040a86869c97a.tar.bz2
project2-1bd5a61d9cab284359bec4de4a9040a86869c97a.tar.xz
project2-1bd5a61d9cab284359bec4de4a9040a86869c97a.zip
Regig output flow in CGI app engine to serve cached content when first created, addresses bug23
Minor tweak to file presenter cache to allow reopening of just generated content
-rw-r--r--project2/cgi/cgiAppEngine.cpp26
-rw-r--r--project2/files/presenterCache.cpp11
2 files changed, 24 insertions, 13 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index d9948e4..28600b3 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -107,11 +107,6 @@ CgiApplicationEngine::process() const
if (TransformSourcePtr ts = currentStage.get<2>()) {
TransformSourcePtr final = finalTransformSource(ts);
ScopeObject emptyFinal([final] { final->clearTargets(); });
- final->addTarget(new CgiResult(header, IO,
- rs && rs->outputOptions ? rs->outputOptions->Encoding().as<std::string>() : OutputOptions::encoding), NULL);
- BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
- final->addTarget(p, NULL);
- }
boost::shared_ptr<std::fstream> ddd;
ostreamWrapper * osw = NULL;
ScopeObject removeDdd([ts, &osw] { if (osw) { ts->removeTarget(osw); } });
@@ -124,10 +119,25 @@ CgiApplicationEngine::process() const
ddd.reset();
}
}
- ts->doTransforms();
- BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
- p->flushCache();
+ if (outputCachingActive) {
+ BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
+ final->addTarget(p, NULL);
+ }
+ ts->doTransforms();
+ BOOST_FOREACH(const PresenterCachePtr & p, rs->caches) {
+ p->flushCache();
+ }
+ if (rs->caches.front()->check(0)) {
+ ScopeObject emptyFinal([rs] { rs->caches.front()->clearTargets(); });
+ rs->caches.front()->addTarget(new CgiResult(header, IO,
+ rs && rs->outputOptions ? rs->outputOptions->Encoding().as<std::string>() : OutputOptions::encoding), NULL);
+ rs->caches.front()->doTransforms();
+ return;
+ }
}
+ final->addTarget(new CgiResult(header, IO,
+ rs && rs->outputOptions ? rs->outputOptions->Encoding().as<std::string>() : OutputOptions::encoding), NULL);
+ ts->doTransforms();
}
else {
header->render(IO);
diff --git a/project2/files/presenterCache.cpp b/project2/files/presenterCache.cpp
index 90c2bc9..6c21580 100644
--- a/project2/files/presenterCache.cpp
+++ b/project2/files/presenterCache.cpp
@@ -104,11 +104,12 @@ class FilePresenterCache : public PresenterCache {
f = openCacheFile(key);
safesys<StatCacheFile>(-1, fstat(*f, &st));
}
- if ((st.st_mtime < (time(NULL) - FilePresenterCache::CacheLife)) || (st.st_mtime < scriptMtime)) {
- unlink(getCacheFile().string().c_str());
- openCaches.erase(key);
- f.reset();
- return false;
+ if (scriptMtime != 0) {
+ if ((st.st_mtime < (time(NULL) - FilePresenterCache::CacheLife)) || (st.st_mtime < scriptMtime)) {
+ unlink(getCacheFile().string().c_str());
+ openCaches.erase(key);
+ return false;
+ }
}
myCache = f;
return true;