wsd/ClientSession.cpp | 20 ++++++++++++++++---- wsd/ClientSession.hpp | 5 +++-- 2 files changed, 19 insertions(+), 6 deletions(-)
New commits: commit 185b933353c670ef4639ada323ed2f803f209e70 Author: Tamás Zolnai <tamas.zol...@collabora.com> AuthorDate: Thu Aug 23 13:27:47 2018 +0200 Commit: Tamás Zolnai <tamas.zol...@collabora.com> CommitDate: Thu Aug 23 13:44:39 2018 +0200 Go back using list for tilesOnFly It can handle duplicates which we need to have. Change-Id: Ia4cd813dd173bc538dd27953c4886d460b5b1c49 diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 406e24255..588a17ad5 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -343,8 +343,15 @@ bool ClientSession::_handleInput(const char *buffer, int length) return false; } - size_t retValue = _tilesOnFly.erase(tileID); - if(retValue == 0) + auto iter = std::find_if(_tilesOnFly.begin(), _tilesOnFly.end(), + [&tileID](const std::pair<std::string, std::chrono::steady_clock::time_point>& curTile) + { + return curTile.first == tileID; + }); + + if(iter != _tilesOnFly.end()) + _tilesOnFly.erase(iter); + else LOG_WRN("Tileprocessed message with an unknown tile ID"); docBroker->sendRequestedTiles(shared_from_this()); @@ -1041,7 +1048,7 @@ Authorization ClientSession::getAuthorization() const void ClientSession::addTileOnFly(const TileDesc& tile) { - _tilesOnFly.insert({generateTileID(tile), std::chrono::steady_clock::now()}); + _tilesOnFly.push_back({generateTileID(tile), std::chrono::steady_clock::now()}); } void ClientSession::clearTilesOnFly() @@ -1051,14 +1058,19 @@ void ClientSession::clearTilesOnFly() void ClientSession::removeOutdatedTilesOnFly() { - for(auto tileIter = _tilesOnFly.begin(); tileIter != _tilesOnFly.end(); ++tileIter) + // Check only the beginning of the list, tiles are ordered by timestamp + bool continueLoop = true; + while(!_tilesOnFly.empty() && continueLoop) { + auto tileIter = _tilesOnFly.begin(); double elapsedTimeMs = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - tileIter->second).count(); if(elapsedTimeMs > 3000) { LOG_WRN("Tracker tileID was dropped because of time out. Tileprocessed message did not arrive"); _tilesOnFly.erase(tileIter); } + else + continueLoop = false; } } diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp index 6f55494b2..b4835cfd9 100644 --- a/wsd/ClientSession.hpp +++ b/wsd/ClientSession.hpp @@ -19,7 +19,8 @@ #include <Rectangle.hpp> #include <deque> #include <map> -#include <unordered_map> +#include <list> +#include <utility> #include <unordered_set> class DocumentBroker; @@ -232,7 +233,7 @@ private: bool _isTextDocument; /// TileID's of the sent tiles. Push by sending and pop by tileprocessed message from the client. - std::unordered_map<std::string, std::chrono::steady_clock::time_point> _tilesOnFly; + std::list<std::pair<std::string, std::chrono::steady_clock::time_point>> _tilesOnFly; /// Names of tiles requested from kit, which this session is subsrcibed to /// Track only non-thumbnail tiles (getId() == -1) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits