[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp loolwsd/ChildProcessSession.hpp loolwsd/LOOLBroker.cpp loolwsd/LOOLKit.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu Jan 14 05:40:58 PST 2016


 loolwsd/ChildProcessSession.cpp |   19 ++++++++-----------
 loolwsd/ChildProcessSession.hpp |    1 -
 loolwsd/LOOLBroker.cpp          |    7 +++----
 loolwsd/LOOLKit.cpp             |    2 +-
 4 files changed, 12 insertions(+), 17 deletions(-)

New commits:
commit bdd3f73bd50199f2dc339e33f6db3d1ce242b71a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Jan 12 20:03:33 2016 -0500

    loolwsd: misc child cleanup
    
    Change-Id: I5ed100e053925264db2cb8f60de67cf6a536a65b
    Reviewed-on: https://gerrit.libreoffice.org/21470
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 2c10576..90ebb57 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -261,7 +261,7 @@ bool ChildProcessSession::loadDocument(const char * /*buffer*/, int /*length*/,
     }
 
     // Respond by the document status, which has no arguments.
-    if (!getStatus_Impl(nullptr, 0))
+    if (!getStatus(nullptr, 0))
         return false;
 
     Log::info("Loaded session " + getId());
@@ -310,19 +310,14 @@ void ChildProcessSession::sendFontRendering(const char* /*buffer*/, int /*length
     sendBinaryFrame(output.data(), output.size());
 }
 
-bool ChildProcessSession::getStatus(const char* buffer, int length)
+bool ChildProcessSession::getStatus(const char* /*buffer*/, int /*length*/)
 {
     std::unique_lock<std::recursive_mutex> lock(_mutex);
 
     if (_multiView)
         _loKitDocument->pClass->setView(_loKitDocument, _viewId);
 
-    return getStatus_Impl(buffer, length);
-}
-
-bool ChildProcessSession::getStatus_Impl(const char* /*buffer*/, int /*length*/)
-{
-    std::string status = "status: " + LOKitHelper::documentStatus(_loKitDocument);
+    const std::string status = "status: " + LOKitHelper::documentStatus(_loKitDocument);
     StringTokenizer tokens(status, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
     if (!getTokenString(tokens[1], "type", _docType))
     {
@@ -772,15 +767,17 @@ bool ChildProcessSession::unoCommand(const char* /*buffer*/, int /*length*/, Str
         _loKitDocument->pClass->setView(_loKitDocument, _viewId);
 
     // we need to get LOK_CALLBACK_UNO_COMMAND_RESULT callback when saving
-    bool bNotify = (tokens[1] == ".uno:Save");
+    const bool bNotify = (tokens[1] == ".uno:Save");
 
     if (tokens.count() == 2)
     {
-        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), 0, bNotify);
+        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), nullptr, bNotify);
     }
     else
     {
-        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(), bNotify);
+        _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(),
+                                               Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(),
+                                               bNotify);
     }
 
     return true;
diff --git a/loolwsd/ChildProcessSession.hpp b/loolwsd/ChildProcessSession.hpp
index 12d7d02..849457d 100644
--- a/loolwsd/ChildProcessSession.hpp
+++ b/loolwsd/ChildProcessSession.hpp
@@ -78,7 +78,6 @@ public:
     bool saveAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
     bool setClientPart(const char *buffer, int length, Poco::StringTokenizer& tokens);
     bool setPage(const char *buffer, int length, Poco::StringTokenizer& tokens);
-    bool getStatus_Impl(const char* buffer, int length);
 
 private:
 
diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index 515aa90..575338a 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -215,7 +215,6 @@ public:
     bool isOKResponse(int nPID)
     {
         std::string aResponse;
-
         if (getResponseLine(readerChild, aResponse) < 0)
         {
             Log::error("Error reading child response: " + std::to_string(nPID) + ". Clearing cache.");
@@ -225,7 +224,7 @@ public:
         }
 
         StringTokenizer tokens(aResponse, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
-        return (tokens[1] == "ok" ? true : false);
+        return (tokens.count() == 2 && tokens[1] == "ok");
     }
 
     ssize_t sendMessage(int nPipeWriter, const std::string& aMessage)
@@ -241,7 +240,7 @@ public:
 
     ssize_t createThread(Process::PID nPID, const std::string& aTID, const std::string& aURL)
     {
-        std::string aMessage = "thread " + aTID + " " + aURL + "\r\n";
+        const std::string aMessage = "thread " + aTID + " " + aURL + "\r\n";
         return sendMessage(_childProcesses[nPID], aMessage);
     }
 
@@ -262,7 +261,7 @@ public:
 
             if (!isOKResponse(it->second))
             {
-                Log::debug() << "Removed expired Kit [" + std::to_string(it->second) + "] hosts URL [" + it->first + "] -> " << Log::end;
+                Log::debug() << "Removed expired Kit [" << it->second << "] hosts URL [" << it->first << "]." << Log::end;
                 _cacheURL.erase(it++);
                 continue;
             }
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 2093825..30adb6b 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -855,7 +855,7 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s
                         aResponse = "bad \r\n";
                     }
 
-                    Util::writeFIFO(writerBroker, aResponse.c_str(), aResponse.length() );
+                    Util::writeFIFO(writerBroker, aResponse.c_str(), aResponse.length());
                     aMessage.clear();
                 }
             }


More information about the Libreoffice-commits mailing list