loolwsd.xml.in | 2 ++ wsd/DocumentBroker.cpp | 4 ++++ wsd/LOOLWSD.cpp | 4 ++++ wsd/LOOLWSD.hpp | 1 + wsd/TileCache.cpp | 9 +++++++-- wsd/TileCache.hpp | 3 +++ 6 files changed, 21 insertions(+), 2 deletions(-)
New commits: commit ba3b32aad1f7fa262990a195241067ac7c7745a0 Author: Jan Holesovsky <[email protected]> Date: Wed Apr 12 20:04:30 2017 +0200 Clean the cache even when the document was not modified. And rename the option, to match better the existing tile cache setting. Change-Id: Iea5c2c5628a403dd2dc3e2943cd858f40e2a2ebc diff --git a/loolwsd.xml.in b/loolwsd.xml.in index db871747..5640d08f 100644 --- a/loolwsd.xml.in +++ b/loolwsd.xml.in @@ -16,8 +16,6 @@ <max_concurrency desc="The maximum number of threads to use while processing a document." type="uint" default="4">4</max_concurrency> </per_document> - <clean_cache_on_doc_close desc="We need to remove tiles from cache when the last session editing a document is removed." type="bool" default="false">false</clean_cache_on_doc_close> - <loleaflet_html desc="Allows UI customization by replacing the single endpoint of loleaflet.html" type="string" default="loleaflet.html">loleaflet.html</loleaflet_html> <logging> @@ -79,6 +77,8 @@ </webdav> </storage> + <tile_cache_persistent desc="Should the tiles persist between two editing sessions of the given document?" type="bool" default="true">true</tile_cache_persistent> + <admin_console desc="Web admin console settings."> <username desc="The username of the admin console. Must be set."></username> <password desc="The password of the admin console. Must be set."></password> diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 50fc4fbe..3cac2e70 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -539,12 +539,6 @@ bool DocumentBroker::saveToStorage(const std::string& sessionId, // We've saved and can safely destroy. removeSessionInternal(sessionId); - // Remove all tiles related to this document from the cache. - if (LOOLWSD::CleanCacheOnDocClose) - { - invalidateTiles("invalidatetiles: EMPTY"); - } - // Stop so we get cleaned up and removed. _stop = true; } @@ -1204,6 +1198,10 @@ void DocumentBroker::destroyIfLastEditor(const std::string& id) _markToDestroy = (_sessions.size() <= 1); LOG_DBG("startDestroy on session [" << id << "] on docKey [" << _docKey << "], markToDestroy: " << _markToDestroy << ", lastEditableSession: " << _lastEditableSession); + + // Remove all tiles related to this document from the cache. + if (_markToDestroy && !LOOLWSD::TileCachePersistent) + _tileCache->completeCleanup(); } void DocumentBroker::setModified(const bool value) diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index cd9a725c..9d3c62fe 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -553,7 +553,7 @@ static std::string UnitTestLibrary; unsigned int LOOLWSD::NumPreSpawnedChildren = 0; std::atomic<unsigned> LOOLWSD::NumConnections; -bool LOOLWSD::CleanCacheOnDocClose = false; +bool LOOLWSD::TileCachePersistent = true; std::unique_ptr<TraceFileWriter> LOOLWSD::TraceDumper; /// This thread polls basic web serving, and handling of @@ -611,6 +611,7 @@ void LOOLWSD::initialize(Application& self) // Add default values of new entries here. static const std::map<std::string, std::string> DefAppConfig = { { "tile_cache_path", LOOLWSD_CACHEDIR }, + { "tile_cache_persistent", "true" }, { "sys_template_path", "systemplate" }, { "lo_template_path", LO_PATH }, { "child_root_path", "jails" }, @@ -619,7 +620,6 @@ void LOOLWSD::initialize(Application& self) { "file_server_root_path", "loleaflet/.." }, { "num_prespawn_children", "1" }, { "per_document.max_concurrency", "4" }, - { "clean_cache_on_doc_close", "false" }, { "loleaflet_html", "loleaflet.html" }, { "logging.color", "true" }, { "logging.level", "trace" }, @@ -764,7 +764,7 @@ void LOOLWSD::initialize(Application& self) LOOLWSD::NumConnections = 0; - CleanCacheOnDocClose = getConfigValue<bool>(conf, "clean_cache_on_doc_close", false); + TileCachePersistent = getConfigValue<bool>(conf, "tile_cache_persistent", true); // Command Tracing. if (getConfigValue<bool>(conf, "trace[@enable]", false)) diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp index 6fb0ff8f..72c3a9a1 100644 --- a/wsd/LOOLWSD.hpp +++ b/wsd/LOOLWSD.hpp @@ -53,7 +53,7 @@ public: static std::string FileServerRoot; static std::string LOKitVersion; static std::atomic<unsigned> NumConnections; - static bool CleanCacheOnDocClose; + static bool TileCachePersistent; static std::unique_ptr<TraceFileWriter> TraceDumper; /// Flag to shutdown the server. diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp index b744eded..ff30710f 100644 --- a/wsd/TileCache.cpp +++ b/wsd/TileCache.cpp @@ -63,8 +63,7 @@ TileCache::TileCache(const std::string& docURL, getTextFile("unsaved.txt", unsaved))) { // Document changed externally or modifications were not saved after all. Cache not useful. - FileUtil::removeFile(_cacheDir, true); - LOG_INF("Completely cleared tile cache: " << _cacheDir); + completeCleanup(); } File(_cacheDir).createDirectories(); @@ -77,6 +76,12 @@ TileCache::~TileCache() LOG_INF("~TileCache dtor for uri [" << _docURL << "]."); } +void TileCache::completeCleanup() const +{ + FileUtil::removeFile(_cacheDir, true); + LOG_INF("Completely cleared tile cache: " << _cacheDir); +} + /// Tracks the rendering of a given tile /// to avoid duplication and help clock /// rendering latency. diff --git a/wsd/TileCache.hpp b/wsd/TileCache.hpp index 96b5a5b3..9f86cc72 100644 --- a/wsd/TileCache.hpp +++ b/wsd/TileCache.hpp @@ -36,6 +36,9 @@ public: TileCache(const std::string& docURL, const Poco::Timestamp& modifiedTime, const std::string& cacheDir); ~TileCache(); + /// Remove the entire cache directory. + void completeCleanup() const; + TileCache(const TileCache&) = delete; /// Subscribes if no subscription exists and returns the version number. commit c651a694856f986c074bb47844958d57f5cbb9a9 Author: Marco Cecchetti <[email protected]> Date: Wed Apr 12 12:32:59 2017 +0200 wsd - implemented an option to clean cache on doc close Change-Id: I0bdb373efb93546527a168df2ed1c75539e95fe4 diff --git a/loolwsd.xml.in b/loolwsd.xml.in index 511b5479..db871747 100644 --- a/loolwsd.xml.in +++ b/loolwsd.xml.in @@ -16,6 +16,8 @@ <max_concurrency desc="The maximum number of threads to use while processing a document." type="uint" default="4">4</max_concurrency> </per_document> + <clean_cache_on_doc_close desc="We need to remove tiles from cache when the last session editing a document is removed." type="bool" default="false">false</clean_cache_on_doc_close> + <loleaflet_html desc="Allows UI customization by replacing the single endpoint of loleaflet.html" type="string" default="loleaflet.html">loleaflet.html</loleaflet_html> <logging> diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index e041db70..50fc4fbe 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -539,6 +539,12 @@ bool DocumentBroker::saveToStorage(const std::string& sessionId, // We've saved and can safely destroy. removeSessionInternal(sessionId); + // Remove all tiles related to this document from the cache. + if (LOOLWSD::CleanCacheOnDocClose) + { + invalidateTiles("invalidatetiles: EMPTY"); + } + // Stop so we get cleaned up and removed. _stop = true; } diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 57c63523..cd9a725c 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -553,6 +553,7 @@ static std::string UnitTestLibrary; unsigned int LOOLWSD::NumPreSpawnedChildren = 0; std::atomic<unsigned> LOOLWSD::NumConnections; +bool LOOLWSD::CleanCacheOnDocClose = false; std::unique_ptr<TraceFileWriter> LOOLWSD::TraceDumper; /// This thread polls basic web serving, and handling of @@ -618,6 +619,7 @@ void LOOLWSD::initialize(Application& self) { "file_server_root_path", "loleaflet/.." }, { "num_prespawn_children", "1" }, { "per_document.max_concurrency", "4" }, + { "clean_cache_on_doc_close", "false" }, { "loleaflet_html", "loleaflet.html" }, { "logging.color", "true" }, { "logging.level", "trace" }, @@ -762,6 +764,8 @@ void LOOLWSD::initialize(Application& self) LOOLWSD::NumConnections = 0; + CleanCacheOnDocClose = getConfigValue<bool>(conf, "clean_cache_on_doc_close", false); + // Command Tracing. if (getConfigValue<bool>(conf, "trace[@enable]", false)) { diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp index 072a4a88..6fb0ff8f 100644 --- a/wsd/LOOLWSD.hpp +++ b/wsd/LOOLWSD.hpp @@ -53,6 +53,7 @@ public: static std::string FileServerRoot; static std::string LOKitVersion; static std::atomic<unsigned> NumConnections; + static bool CleanCacheOnDocClose; static std::unique_ptr<TraceFileWriter> TraceDumper; /// Flag to shutdown the server. _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
