[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - kit/ForKit.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jul 31 21:01:12 UTC 2017


 kit/ForKit.cpp |   30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

New commits:
commit 2f8a74328cd68d7c4876dbb18f8dddc6d36ce66b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat May 6 22:13:02 2017 -0400

    wsd: use fast tokenizer
    
    Change-Id: I477bac24a5e944ce3d747db6e694f2766b44c7f3
    Reviewed-on: https://gerrit.libreoffice.org/37370
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit f062b2058ea97be06a40b9a159ad4de58c7a2dc9)
    Reviewed-on: https://gerrit.libreoffice.org/39771

diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index b678b1e5..9aa83a20 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -26,7 +26,6 @@
 
 #include <Poco/Path.h>
 #include <Poco/Process.h>
-#include <Poco/StringTokenizer.h>
 #include <Poco/Thread.h>
 #include <Poco/Util/Application.h>
 
@@ -43,7 +42,6 @@
 #include "security.h"
 
 using Poco::Process;
-using Poco::StringTokenizer;
 using Poco::Thread;
 #ifndef KIT_IN_PROCESS
 using Poco::Util::Application;
@@ -97,21 +95,27 @@ public:
         }
 
         LOG_INF("ForKit command: [" << message << "].");
-        StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-
-        if (tokens[0] == "spawn" && tokens.count() == 2)
+        try
         {
-            const auto count = std::stoi(tokens[1]);
-            if (count > 0)
-            {
-                LOG_INF("Setting to spawn " << tokens[1] << " child" << (count == 1 ? "" : "ren") << " per request.");
-                ForkCounter = count;
-            }
-            else
+            std::vector<std::string> tokens = LOOLProtocol::tokenize(message);
+            if (tokens.size() == 2 && tokens[0] == "spawn")
             {
-                LOG_WRN("Cannot spawn " << tokens[1] << " children as requested.");
+                const auto count = std::stoi(tokens[1]);
+                if (count > 0)
+                {
+                    LOG_INF("Setting to spawn " << tokens[1] << " child" << (count == 1 ? "" : "ren") << " per request.");
+                    ForkCounter = count;
+                }
+                else
+                {
+                    LOG_WRN("Cannot spawn " << tokens[1] << " children as requested.");
+                }
             }
         }
+        catch (const std::exception& exc)
+        {
+            LOG_ERR("Error while processing forkit request [" << message << "]: " << exc.what());
+        }
 
         return true;
     }


More information about the Libreoffice-commits mailing list