loolwsd/TileCache.cpp | 4 ++++ loolwsd/TileCache.hpp | 5 +++++ 2 files changed, 9 insertions(+)
New commits: commit 3e0a3d9ed6bd612e56ab38d8189f63ed2fe35af7 Author: Mihai Varga <mihai.va...@collabora.com> Date: Wed Aug 12 15:31:02 2015 +0300 loolwsd: use a mutex when moving/removing tiles form the cache diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp index 95bb2f5..01714a4 100644 --- a/loolwsd/TileCache.cpp +++ b/loolwsd/TileCache.cpp @@ -151,9 +151,11 @@ void TileCache::documentSaved() for (const auto& it : _toBeRemoved) File(persistentDirName + "/" + it).remove(); + _cacheMutex.lock(); // then move the new tiles from the Editing cache to Persistent for (auto tileIterator = DirectoryIterator(cacheDirName(true)); tileIterator != DirectoryIterator(); ++tileIterator) tileIterator->moveTo(persistentDirName); + _cacheMutex.unlock(); // update status _toBeRemoved.clear(); @@ -195,6 +197,7 @@ void TileCache::invalidateTiles(int part, int x, int y, int width, int height) File editingDir(editingDirName); if (editingDir.exists() && editingDir.isDirectory()) { + _cacheMutex.lock(); for (auto tileIterator = DirectoryIterator(editingDir); tileIterator != DirectoryIterator(); ++tileIterator) { std::string fileName = tileIterator.path().getFileName(); @@ -203,6 +206,7 @@ void TileCache::invalidateTiles(int part, int x, int y, int width, int height) File(tileIterator.path()).remove(); } } + _cacheMutex.unlock(); } // in the Persistent cache, add to _toBeRemoved for removal on save diff --git a/loolwsd/TileCache.hpp b/loolwsd/TileCache.hpp index ca3a51f..1e01078 100644 --- a/loolwsd/TileCache.hpp +++ b/loolwsd/TileCache.hpp @@ -17,6 +17,9 @@ #include <Poco/File.h> #include <Poco/Timestamp.h> +#include <Poco/Mutex.h> + +using Poco::FastMutex; /** Handles the cache for tiles of one document. @@ -86,6 +89,8 @@ private: /// Set of tiles that we want to remove from the Persistent cache on the next save. std::set<std::string> _toBeRemoved; + + Poco::FastMutex _cacheMutex; }; #endif _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits