From faf6cf7ce414fd61c948058e085c9856d87edd6e Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Mon, 19 Sep 2016 20:51:10 -0400 Subject: [PATCH] loolwsd: better logging in subscribeToTileRendering Change-Id: I5b94cda02e4f0e1154de81fc7bb4380332f2eeeb Reviewed-on: https://gerrit.libreoffice.org/29070 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian --- loolwsd/TileCache.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp index c7dfd6ef9..ba20c8d31 100644 --- a/loolwsd/TileCache.cpp +++ b/loolwsd/TileCache.cpp @@ -423,26 +423,30 @@ void TileCache::saveLastModified(const Timestamp& timestamp) // FIXME: to be further simplified when we centralize tile messages. int TileCache::subscribeToTileRendering(const TileDesc& tile, const std::shared_ptr &subscriber) { + assert(subscriber->getKind() == LOOLSession::Kind::ToClient); + std::unique_lock lock(_tilesBeingRenderedMutex); std::shared_ptr tileBeingRendered = findTileBeingRendered(tile); + std::ostringstream oss; + oss << '(' << tile.getPart() << ',' << tile.getTilePosX() << ',' << tile.getTilePosY() << ')'; + const auto name = oss.str(); + if (tileBeingRendered) { - Log::debug() << "Subscribing to tile (" << tile.getPart() << ',' << tile.getTilePosX() << ',' - << tile.getTilePosY() << ") which has " - << tileBeingRendered->_subscribers.size() - << " subscribers already. Adding one more." << Log::end; - assert(subscriber->getKind() == LOOLSession::Kind::ToClient); - for (const auto &s : tileBeingRendered->_subscribers) { if (s.lock().get() == subscriber.get()) { - Log::debug("Redundant request to re-subscribe on a tile"); + Log::debug("Redundant request to subscribe on tile " + name); return 0; } } + + Log::debug() << "Subscribing to tile " << name << " which has " + << tileBeingRendered->_subscribers.size() + << " subscribers already. Adding one more." << Log::end; tileBeingRendered->_subscribers.push_back(subscriber); const auto duration = (std::chrono::steady_clock::now() - tileBeingRendered->getStartTime()); @@ -456,8 +460,7 @@ int TileCache::subscribeToTileRendering(const TileDesc& tile, const std::shared_ } else { - Log::debug() << "Subscribing to tile (" << tile.getPart() << ',' << tile.getTilePosX() << ',' - << tile.getTilePosY() << ") which has no subscribers. Subscribing for ver: " + Log::debug() << "Subscribing to tile " << name << " which has no subscribers. Subscribing for ver: " << tile.getVersion() << "." << Log::end; const std::string cachedName = cacheFileName(tile);