loolwsd/DocumentBroker.cpp | 20 +++++++++----------- loolwsd/TileCache.cpp | 15 ++++++--------- loolwsd/TileCache.hpp | 2 +- loolwsd/test/TileCacheTests.cpp | 2 +- 4 files changed, 17 insertions(+), 22 deletions(-)
New commits: commit f6a9de1b2d9646ace933cad17b5a9661da06997e Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Sep 25 11:33:37 2016 -0400 Revert "loolwsd: TileCache is told to save or not before... This reverts commit 01718c5c68bad8d324dfcc1b93d3c49055c90873. Change-Id: I6fa49f8d1f5c6ba7bdcd8cfa0866e0e15380607d Reviewed-on: https://gerrit.libreoffice.org/29281 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index c241594..989e056 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -587,15 +587,14 @@ void DocumentBroker::handleTileResponse(const std::vector<char>& payload) try { auto tile = TileDesc::parse(firstLine); - - + const auto buffer = payload.data(); const auto length = payload.size(); + if (firstLine.size() < static_cast<std::string::size_type>(length) - 1) { - const auto buffer = payload.data(); - tileCache().notifySubscribers( + tileCache().saveTileAndNotify( tile, buffer + firstLine.size() + 1, - length - firstLine.size() - 1, true); + length - firstLine.size() - 1); } else { @@ -620,22 +619,21 @@ void DocumentBroker::handleTileCombinedResponse(const std::vector<char>& payload try { auto tileCombined = TileCombined::parse(firstLine); - - + const auto buffer = payload.data(); const auto length = payload.size(); + auto offset = firstLine.size() + 1; + if (firstLine.size() < static_cast<std::string::size_type>(length) - 1) { - const auto buffer = payload.data(); - auto offset = firstLine.size() + 1; for (const auto& tile : tileCombined.getTiles()) { - tileCache().notifySubscribers(tile, buffer + offset, tile.getImgSize(), true); + tileCache().saveTileAndNotify(tile, buffer + offset, tile.getImgSize()); offset += tile.getImgSize(); } } else { - Log::debug() << "Render request declined for " << firstLine << Log::end; + Log::error() << "Render request failed for " << firstLine << Log::end; std::unique_lock<std::mutex> tileBeingRenderedLock(tileCache().getTilesBeingRenderedLock()); for (const auto& tile : tileCombined.getTiles()) { diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp index 6924e30..ce74945 100644 --- a/loolwsd/TileCache.cpp +++ b/loolwsd/TileCache.cpp @@ -142,7 +142,7 @@ std::unique_ptr<std::fstream> TileCache::lookupTile(const TileDesc& tile) return nullptr; } -void TileCache::notifySubscribers(const TileDesc& tile, const char *data, const size_t size, const bool save) +void TileCache::saveTileAndNotify(const TileDesc& tile, const char *data, const size_t size) { std::unique_lock<std::mutex> lock(_tilesBeingRenderedMutex); @@ -151,14 +151,11 @@ void TileCache::notifySubscribers(const TileDesc& tile, const char *data, const // Save to disk. const auto cachedName = (tileBeingRendered ? tileBeingRendered->getCacheName() : cacheFileName(tile)); - if (save) - { - const auto fileName = _cacheDir + "/" + cachedName; - Log::trace() << "Saving cache tile: " << fileName << Log::end; - std::fstream outStream(fileName, std::ios::out); - outStream.write(data, size); - outStream.close(); - } + const auto fileName = _cacheDir + "/" + cachedName; + Log::trace() << "Saving cache tile: " << fileName << Log::end; + std::fstream outStream(fileName, std::ios::out); + outStream.write(data, size); + outStream.close(); // Notify subscribers, if any. if (tileBeingRendered) diff --git a/loolwsd/TileCache.hpp b/loolwsd/TileCache.hpp index 206603b..fc0210b 100644 --- a/loolwsd/TileCache.hpp +++ b/loolwsd/TileCache.hpp @@ -47,7 +47,7 @@ public: std::unique_ptr<std::fstream> lookupTile(const TileDesc& tile); - void notifySubscribers(const TileDesc& tile, const char *data, const size_t size, const bool save); + void saveTileAndNotify(const TileDesc& tile, const char *data, const size_t size); std::string getTextFile(const std::string& fileName); diff --git a/loolwsd/test/TileCacheTests.cpp b/loolwsd/test/TileCacheTests.cpp index 9081675..f2d7f3d 100644 --- a/loolwsd/test/TileCacheTests.cpp +++ b/loolwsd/test/TileCacheTests.cpp @@ -167,7 +167,7 @@ void TileCacheTests::testSimple() // Cache Tile const auto size = 1024; const auto data = genRandomData(size); - tc.notifySubscribers(tile, data.data(), size, true); + tc.saveTileAndNotify(tile, data.data(), size); // Find Tile file = tc.lookupTile(tile); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits