[Libreoffice-commits] online.git: loolwsd/TileCache.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun May 15 14:34:05 UTC 2016


 loolwsd/TileCache.cpp |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 57947dfd4d70bf4bdb0e443263dad39620838d43
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 15 10:19:49 2016 -0400

    loolwsd: timeout tile requests and reissue them
    
    Change-Id: I7dee06d905f59d73fdc9aa4e03831c5e5d16b9e3
    Reviewed-on: https://gerrit.libreoffice.org/25007
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index 9243e57..5cdeeb5 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -29,6 +29,7 @@
 #include <Poco/Timestamp.h>
 #include <Poco/URI.h>
 
+#include "Common.hpp"
 #include "Storage.hpp"
 #include "LOOLProtocol.hpp"
 #include "TileCache.hpp"
@@ -74,12 +75,20 @@ TileCache::~TileCache()
 
 struct TileCache::TileBeingRendered
 {
-    Poco::Timestamp _startTime;
     std::vector<std::weak_ptr<MasterProcessSession>> _subscribers;
     TileBeingRendered()
+     : _startTime(std::chrono::steady_clock::now())
     {
-        _startTime.update();
     }
+
+    std::chrono::steady_clock::time_point getStartTime() const { return _startTime; }
+    void resetStartTime()
+    {
+        _startTime = std::chrono::steady_clock::now();
+    }
+
+private:
+    std::chrono::steady_clock::time_point _startTime;
 };
 
 std::shared_ptr<TileCache::TileBeingRendered> TileCache::findTileBeingRendered(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight)
@@ -393,6 +402,13 @@ bool TileCache::isTileBeingRenderedIfSoSubscribe(int part, int width, int height
         }
         tileBeingRendered->_subscribers.push_back(subscriber);
 
+        const auto duration = (std::chrono::steady_clock::now() - tileBeingRendered->getStartTime());
+        if (std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() > COMMAND_TIMEOUT_MS)
+        {
+            // Tile painting has stalled. Reissue.
+            return false;
+        }
+
         return true;
     }
     else


More information about the Libreoffice-commits mailing list