loolwsd/LOOLKit.cpp      |   17 +++--------------
 loolwsd/MessageQueue.cpp |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 14 deletions(-)

New commits:
commit 0326aa4304e866bf346aaa90697a49b43f0d9d74
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Tue Sep 20 19:59:06 2016 -0400

    loolwsd: cancel individual tiles
    
    Change-Id: I18faee319fc12de2151460afbb054b8509578579
    Reviewed-on: https://gerrit.libreoffice.org/29120
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 3b4e39b..5eb7d42 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1547,7 +1547,7 @@ void lokit_main(const std::string& childRoot,
                             Log::debug("CreateSession failed.");
                         }
                     }
-                    else if (tokens[0] == "tile")
+                    else if (tokens[0] == "tile" || tokens[0] == "tilecombine" 
|| tokens[0] == "canceltiles")
                     {
                         if (document)
                         {
@@ -1555,18 +1555,7 @@ void lokit_main(const std::string& childRoot,
                         }
                         else
                         {
-                            Log::warn("No document while processing tile 
request.");
-                        }
-                    }
-                    else if (tokens[0] == "tilecombine")
-                    {
-                        if (document)
-                        {
-                            queue->put(message);
-                        }
-                        else
-                        {
-                            Log::warn("No document while processing 
tilecombine request.");
+                            Log::warn("No document while processing " + 
tokens[0] + " request.");
                         }
                     }
                     else if (document && document->canDiscard())
@@ -1576,7 +1565,7 @@ void lokit_main(const std::string& childRoot,
                     }
                     else
                     {
-                        Log::info("Bad or unknown token [" + tokens[0] + "]");
+                        Log::error("Bad or unknown token [" + tokens[0] + "]");
                     }
 
                     return true;
diff --git a/loolwsd/MessageQueue.cpp b/loolwsd/MessageQueue.cpp
index 7e81608..0a4c96d 100644
--- a/loolwsd/MessageQueue.cpp
+++ b/loolwsd/MessageQueue.cpp
@@ -11,9 +11,13 @@
 
 #include <algorithm>
 
+#include <Poco/StringTokenizer.h>
+
 #include <TileDesc.hpp>
 #include <Log.hpp>
 
+using Poco::StringTokenizer;
+
 MessageQueue::~MessageQueue()
 {
     clear();
@@ -102,6 +106,35 @@ void TileQueue::put_impl(const Payload& value)
 {
     const auto msg = std::string(value.data(), value.size());
     Log::trace() << "Putting [" << msg << "]" << Log::end;
+
+    if (msg.compare(0, 11, "canceltiles") == 0)
+    {
+        Log::trace("Processing " + msg);
+        Log::trace() << "Before canceltiles have " << _queue.size() << " in 
queue." << Log::end;
+        const auto seqs = msg.substr(12);
+        StringTokenizer tokens(seqs, ",", StringTokenizer::TOK_IGNORE_EMPTY | 
StringTokenizer::TOK_TRIM);
+        _queue.erase(std::remove_if(_queue.begin(), _queue.end(),
+                [&tokens](const Payload& v)
+                {
+                    const std::string s(v.data(), v.size());
+                    for (size_t i = 0; i < tokens.count(); ++i)
+                    {
+                        if (s.find("ver=" + tokens[i]) != std::string::npos)
+                        {
+                            Log::trace("Matched " + tokens[i] + ", Removing [" 
+ s + "]");
+                            return true;
+                        }
+                    }
+
+                    return false;
+
+                }), _queue.end());
+
+        // Don't push canceltiles into the queue.
+        Log::trace() << "After canceltiles have " << _queue.size() << " in 
queue." << Log::end;
+        return;
+    }
+
     if (!_queue.empty())
     {
         if (msg.compare(0, 4, "tile") == 0 || msg.compare(0, 10, 
"tilecombine") == 0)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to