[Libreoffice-commits] online.git: loolwsd/AdminModel.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLStress.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Aug 22 05:32:26 UTC 2016


 loolwsd/AdminModel.cpp |   26 +++++++++++++-------------
 loolwsd/LOOLKit.cpp    |    1 +
 loolwsd/LOOLStress.cpp |   10 ++++++++--
 3 files changed, 22 insertions(+), 15 deletions(-)

New commits:
commit 98db6b8518c7e7c374f539067ec819b6396fa157
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Aug 21 08:23:08 2016 -0400

    loolwsd: logging and comments
    
    Change-Id: If58cfd8ac60b95119bef752ff4ebae295fc564cc
    Reviewed-on: https://gerrit.libreoffice.org/28301
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/AdminModel.cpp b/loolwsd/AdminModel.cpp
index 556bbcc..aed2ebc 100644
--- a/loolwsd/AdminModel.cpp
+++ b/loolwsd/AdminModel.cpp
@@ -339,10 +339,10 @@ unsigned AdminModel::getTotalActiveViews()
     unsigned nTotalViews = 0;
     for (auto& it: _documents)
     {
-        if (it.second.isExpired())
-            continue;
-
-        nTotalViews += it.second.getActiveViews();
+        if (!it.second.isExpired())
+        {
+            nTotalViews += it.second.getActiveViews();
+        }
     }
 
     return nTotalViews;
@@ -356,18 +356,18 @@ std::string AdminModel::getDocuments()
         if (it.second.isExpired())
             continue;
 
-        std::string sPid = std::to_string(it.second.getPid());
-        std::string sFilename = it.second.getFilename();
-        std::string sViews = std::to_string(it.second.getActiveViews());
-        std::string sMem = std::to_string(Util::getMemoryUsage(it.second.getPid()));
-        std::string sElapsed = std::to_string(it.second.getElapsedTime());
+        const auto sPid = std::to_string(it.second.getPid());
+        const auto sFilename = it.second.getFilename();
+        const auto sViews = std::to_string(it.second.getActiveViews());
+        const auto sMem = std::to_string(Util::getMemoryUsage(it.second.getPid()));
+        const auto sElapsed = std::to_string(it.second.getElapsedTime());
 
         std::string encodedFilename;
         Poco::URI::encode(sFilename, " ", encodedFilename);
-        oss << sPid << " "
-            << encodedFilename << " "
-            << sViews << " "
-            << sMem << " "
+        oss << sPid << ' '
+            << encodedFilename << ' '
+            << sViews << ' '
+            << sMem << ' '
             << sElapsed << " \n ";
     }
 
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 806201c..a1df19f 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1345,6 +1345,7 @@ void lokit_main(const std::string& childRoot,
             requestUrl += "&version=" + encodedVersionStr;
             free(versionInfo);
         }
+
         HTTPRequest request(HTTPRequest::HTTP_GET, requestUrl);
         HTTPResponse response;
         auto ws = std::make_shared<WebSocket>(cs, request, response);
diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 380bb85..2514b14 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -88,7 +88,7 @@ public:
         std::unique_lock<std::mutex> lock(Mutex);
 
         // Load a document and get its status.
-        std::cerr << "NewSession [" << sessionId << "]: " << uri.toString() << "... ";
+        std::cout << "NewSession [" << sessionId << "]: " << uri.toString() << "... ";
         Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, "/lool/ws/" + documentURL);
         Poco::Net::HTTPResponse response;
         auto ws = helpers::connectLOKit(uri, request, response, "loolStress ");
@@ -98,7 +98,7 @@ public:
 
     void send(const std::string& data) const
     {
-        helpers::sendTextFrame(_ws, data, "loolstress ");
+        helpers::sendTextFrame(_ws, data, _sessionId + ' ');
     }
 
 private:
@@ -140,6 +140,10 @@ public:
             std::cerr << "Error: " << e.name() << ' '
                       << e.message() << std::endl;
         }
+        catch (const std::exception &e)
+        {
+            std::cerr << "Error: " << e.what() << std::endl;
+        }
     }
 
 private:
@@ -148,6 +152,7 @@ private:
     {
         auto epochFile(_traceFile.getEpoch());
         auto epochCurrent(std::chrono::steady_clock::now());
+
         for (;;)
         {
             const auto rec = _traceFile.getNextRecord();
@@ -233,6 +238,7 @@ private:
                         const auto sessionIt = it->second.find(rec.SessionId);
                         if (sessionIt != it->second.end())
                         {
+                            // Send the command.
                             sessionIt->second->send(rec.Payload);
                         }
                     }


More information about the Libreoffice-commits mailing list