[Libreoffice-commits] online.git: wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Aug 23 10:48:51 UTC 2018
wsd/ClientSession.cpp | 26 ++++++++++++++++++++------
wsd/ClientSession.hpp | 4 +++-
wsd/DocumentBroker.cpp | 2 ++
3 files changed, 25 insertions(+), 7 deletions(-)
New commits:
commit 759d1fe72294b22669f19dabf28a4fcf4922af8c
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Aug 23 12:46:49 2018 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Thu Aug 23 12:47:52 2018 +0200
Drop too old tileID's from tiles-on-fly list
So we can avoid that tile sending stop working because server is
waiting for tileprocessed messages which will not arrive.
Change-Id: I545346c50d49340999608aadac32b5190ede43c5
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 4635bd57f..99ed308ea 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -52,7 +52,6 @@ ClientSession::ClientSession(const std::string& id,
_tileWidthTwips(0),
_tileHeightTwips(0),
_isTextDocument(false),
- _tilesOnFly(0),
_tilesBeingRendered(0)
{
const size_t curConnections = ++LOOLWSD::NumConnections;
@@ -343,10 +342,9 @@ bool ClientSession::_handleInput(const char *buffer, int length)
sendTextFrame("error: cmd=tileprocessed kind=syntax");
return false;
}
- auto iter = std::find(_tilesOnFly.begin(), _tilesOnFly.end(), tileID);
- if(iter != _tilesOnFly.end())
- _tilesOnFly.erase(iter);
- else
+
+ size_t retValue = _tilesOnFly.erase(tileID);
+ if(retValue == 0)
LOG_WRN("Tileprocessed message with an unknown tile ID");
docBroker->sendRequestedTiles(shared_from_this());
@@ -1043,7 +1041,7 @@ Authorization ClientSession::getAuthorization() const
void ClientSession::addTileOnFly(const TileDesc& tile)
{
- _tilesOnFly.push_back(generateTileID(tile));
+ _tilesOnFly.insert({generateTileID(tile), std::chrono::steady_clock::now()});
}
void ClientSession::clearTilesOnFly()
@@ -1051,6 +1049,19 @@ void ClientSession::clearTilesOnFly()
_tilesOnFly.clear();
}
+void ClientSession::removeOutdatedTilesOnFly()
+{
+ for(auto tileIter = _tilesOnFly.begin(); tileIter != _tilesOnFly.begin(); ++tileIter)
+ {
+ 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);
+ }
+ }
+}
+
void ClientSession::onDisconnect()
{
LOG_INF(getName() << " Disconnected, current number of connections: " << LOOLWSD::NumConnections);
@@ -1245,7 +1256,10 @@ void ClientSession::removeOutdatedTileSubscriptions()
{
double elapsedTime = docBroker->tileCache().getTileBeingRenderedElapsedTimeMs(*iterator);
if(elapsedTime < 0.0 && elapsedTime > 5000.0)
+ {
+ LOG_WRN("Tracked TileBeingRendered was dropped because of time out.");
_tilesBeingRendered.erase(iterator);
+ }
else
++iterator;
}
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 7e7fef7ab..6f55494b2 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -19,6 +19,7 @@
#include <Rectangle.hpp>
#include <deque>
#include <map>
+#include <unordered_map>
#include <unordered_set>
class DocumentBroker;
@@ -125,6 +126,7 @@ public:
void addTileOnFly(const TileDesc& tile);
void clearTilesOnFly();
size_t getTilesOnFlyCount() const { return _tilesOnFly.size(); }
+ void removeOutdatedTilesOnFly();
Util::Rectangle getVisibleArea() const { return _clientVisibleArea; }
int getTileWidthInTwips() const { return _tileWidthTwips; }
@@ -230,7 +232,7 @@ private:
bool _isTextDocument;
/// TileID's of the sent tiles. Push by sending and pop by tileprocessed message from the client.
- std::list<std::string> _tilesOnFly;
+ std::unordered_map<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)
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index b01d0753b..310eac031 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1378,6 +1378,8 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
// Update client's tilesBeingRendered list
session->removeOutdatedTileSubscriptions();
+ // Drop tiles which we are waiting for too long
+ session->removeOutdatedTilesOnFly();
// All tiles were processed on client side what we sent last time, so we can send a new banch of tiles
// which was invalidated / requested in the meantime
More information about the Libreoffice-commits
mailing list