[Libreoffice-commits] online.git: loolwsd/IoUtil.cpp loolwsd/TileCache.cpp loolwsd/TileCache.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue Apr 5 02:59:30 UTC 2016
loolwsd/IoUtil.cpp | 2 +-
loolwsd/TileCache.cpp | 31 +++++++++++++++----------------
loolwsd/TileCache.hpp | 2 +-
3 files changed, 17 insertions(+), 18 deletions(-)
New commits:
commit 3499878fae0adbae763659ce7bb5509cb716f890
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Apr 4 20:59:46 2016 -0400
loolwsd: logging and cleanups
Change-Id: I0664be51da54d2e374808256e6598ba025f0324e
Reviewed-on: https://gerrit.libreoffice.org/23822
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/IoUtil.cpp b/loolwsd/IoUtil.cpp
index f1e6a05..36d5d90 100644
--- a/loolwsd/IoUtil.cpp
+++ b/loolwsd/IoUtil.cpp
@@ -167,7 +167,7 @@ void SocketProcessor(std::shared_ptr<WebSocket> ws,
Log::debug() << name << "Finishing SocketProcessor. TerminationFlag: " << stop
<< ", payload size: " << payload.size()
<< ", flags: " << std::hex << flags << Log::end;
- if (!payload.empty())
+ if (payload.size() > 1)
{
Log::warn(name + "Last message will not be processed: [" +
LOOLProtocol::getFirstLine(payload.data(), payload.size()) + "].");
diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index 3e9e408..da50309 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -15,6 +15,7 @@
#include <fstream>
#include <iostream>
#include <memory>
+#include <mutex>
#include <sstream>
#include <string>
@@ -90,7 +91,7 @@ std::unique_ptr<std::fstream> TileCache::lookupTile(int part, int width, int hei
if (dir.exists() && dir.isDirectory() && File(fileName).exists())
{
- Log::debug("Found editing tile: " + cachedName);
+ Log::trace("Found editing tile: " + cachedName);
std::unique_ptr<std::fstream> result(new std::fstream(fileName, std::ios::in));
return result;
}
@@ -112,7 +113,7 @@ std::unique_ptr<std::fstream> TileCache::lookupTile(int part, int width, int hei
}
const std::string fileName = _persCacheDir + "/" + cachedName;
- Log::debug("Found persistent tile: " + fileName);
+ Log::trace("Found persistent tile: " + fileName);
std::unique_ptr<std::fstream> result(new std::fstream(fileName, std::ios::in));
return result;
@@ -129,7 +130,7 @@ void TileCache::saveTile(int part, int width, int height, int tilePosX, int tile
File(dirName).createDirectories();
const std::string fileName = dirName + "/" + cacheFileName(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight);
- Log::debug() << "Saving "
+ Log::trace() << "Saving "
<< (_hasUnsavedChanges ? "editing" : "persistent") <<
" tile: " << fileName << Log::end;
@@ -182,7 +183,7 @@ std::string TileCache::getTextFile(std::string fileName)
void TileCache::documentSaved()
{
- Log::debug("Persisting editing tiles.");
+ Log::trace("Persisting editing tiles.");
// first remove the invalidated tiles from the Persistent cache
for (const auto& it : _toBeRemoved)
@@ -190,14 +191,22 @@ void TileCache::documentSaved()
Util::removeFile(_persCacheDir + "/" + it);
}
- _cacheMutex.lock();
+ _toBeRemoved.clear();
+
// then move the new tiles from the Editing cache to Persistent
try
{
+ std::unique_lock<std::mutex> lock(_cacheMutex);
for (auto tileIterator = DirectoryIterator(_editCacheDir); tileIterator != DirectoryIterator(); ++tileIterator)
{
tileIterator->moveTo(_persCacheDir);
}
+
+ // update status
+ _hasUnsavedChanges = false;
+
+ // FIXME should we take the exact time of the file for the local files?
+ saveLastModified(Timestamp());
}
catch (const FileException& exc)
{
@@ -206,15 +215,6 @@ void TileCache::documentSaved()
<< (exc.nested() ? " (" + exc.nested()->displayText() + ")" : "")
<< Log::end;
}
-
- _cacheMutex.unlock();
-
- // update status
- _toBeRemoved.clear();
- _hasUnsavedChanges = false;
-
- // FIXME should we take the exact time of the file for the local files?
- saveLastModified(Timestamp());
}
void TileCache::setEditing(bool editing)
@@ -275,7 +275,7 @@ void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
File editingDir(_editCacheDir);
if (editingDir.exists() && editingDir.isDirectory())
{
- _cacheMutex.lock();
+ std::unique_lock<std::mutex> lock(_cacheMutex);
for (auto tileIterator = DirectoryIterator(editingDir); tileIterator != DirectoryIterator(); ++tileIterator)
{
const std::string fileName = tileIterator.path().getFileName();
@@ -284,7 +284,6 @@ void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
Util::removeFile(tileIterator.path());
}
}
- _cacheMutex.unlock();
}
// in the Persistent cache, add to _toBeRemoved for removal on save
diff --git a/loolwsd/TileCache.hpp b/loolwsd/TileCache.hpp
index bb25d62..70beabc 100644
--- a/loolwsd/TileCache.hpp
+++ b/loolwsd/TileCache.hpp
@@ -97,7 +97,7 @@ 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;
+ std::mutex _cacheMutex;
};
#endif
More information about the Libreoffice-commits
mailing list