[Libreoffice-commits] online.git: wsd/ClientSession.cpp wsd/DocumentBroker.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Jan 26 02:13:41 UTC 2017


 wsd/ClientSession.cpp  |   10 ++++------
 wsd/DocumentBroker.cpp |   10 ++++++++--
 2 files changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 6fe933b46678f3bf52a63f51890ac4c900989d3b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Jan 25 20:55:39 2017 -0500

    wsd: take lock to forward messages to clients
    
    Change-Id: I15888e4a5c35511c21f1e2d2bdd25ecbb16e80b9
    Reviewed-on: https://gerrit.libreoffice.org/33568
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 742bb07..63db162 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -583,13 +583,10 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
     }
     else if (tokens.size() == 2 && tokens[0] == "statechanged:")
     {
-        if (docBroker)
+        StringTokenizer stateTokens(tokens[1], "=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
+        if (stateTokens.count() == 2 && stateTokens[0] == ".uno:ModifiedStatus")
         {
-            StringTokenizer stateTokens(tokens[1], "=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-            if (stateTokens.count() == 2 && stateTokens[0] == ".uno:ModifiedStatus")
-            {
-                docBroker->setModified(stateTokens[1] == "true");
-            }
+            docBroker->setModified(stateTokens[1] == "true");
         }
     }
 
@@ -652,6 +649,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
                     stringToInteger(firstLineTokens[3], w);
                     stringToInteger(firstLineTokens[4], h);
                 }
+
                 docBroker->invalidateCursor(x, y, w, h);
             }
             else
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 7b3ee4c..91f3ce4 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -759,8 +759,6 @@ bool DocumentBroker::handleInput(const std::vector<char>& payload)
 
 void DocumentBroker::invalidateTiles(const std::string& tiles)
 {
-    std::unique_lock<std::mutex> lock(_mutex);
-
     // Remove from cache.
     _tileCache->invalidateTiles(tiles);
 }
@@ -904,6 +902,9 @@ void DocumentBroker::handleTileResponse(const std::vector<char>& payload)
             const auto tile = TileDesc::parse(firstLine);
             const auto buffer = payload.data();
             const auto offset = firstLine.size() + 1;
+
+            std::unique_lock<std::mutex> lock(_mutex);
+
             tileCache().saveTileAndNotify(tile, buffer + offset, length - offset);
         }
         else
@@ -931,6 +932,9 @@ void DocumentBroker::handleTileCombinedResponse(const std::vector<char>& payload
             const auto tileCombined = TileCombined::parse(firstLine);
             const auto buffer = payload.data();
             auto offset = firstLine.size() + 1;
+
+            std::unique_lock<std::mutex> lock(_mutex);
+
             for (const auto& tile : tileCombined.getTiles())
             {
                 tileCache().saveTileAndNotify(tile, buffer + offset, tile.getImgSize());
@@ -1015,6 +1019,8 @@ bool DocumentBroker::forwardToClient(const std::shared_ptr<Message>& payload)
     std::string sid;
     if (LOOLProtocol::parseNameValuePair(payload->forwardToken(), name, sid, '-') && name == "client")
     {
+        std::unique_lock<std::mutex> lock(_mutex);
+
         const auto it = _sessions.find(sid);
         if (it != _sessions.end())
         {


More information about the Libreoffice-commits mailing list